Exemplo n.º 1
0
    private GameObject _gameObject; // generic for prefabs that have data dispersed

    public void SetInfo(GameObject currentGameObject)
    {
        _destroyInfoInstances();

        if (!currentGameObject)
        {
            return;
        }

        _gameObject = currentGameObject;

        var shooter           = currentGameObject.GetComponent <Shooter>();
        var defender          = currentGameObject.GetComponent <Defender>();
        var attacker          = currentGameObject.GetComponent <Attacker>();
        var currencyButton    = currentGameObject.GetComponent <CurrencyButton>();
        var _currencyProducer = currentGameObject.GetComponent <CurrencyProducer>();

        _defenderButton = currentGameObject.GetComponent <DefenderButton>();
        _controlTower   = currentGameObject.GetComponent <ControlTower>();

        if (shooter)
        {
            _currentInfoShooter = Instantiate(infoShooter, transform.position, Quaternion.identity);
            _currentInfoShooter.transform.SetParent(transform);
        }
        else if (_controlTower || currencyButton)
        {
            _currentInfoResources = Instantiate(infoResources, transform.position, Quaternion.identity);
            _currentInfoResources.transform.SetParent(transform);
        }
        else if (_defenderButton)
        {
            _currentInfoDefenderButton = Instantiate(infoDefenderButton, transform.position, Quaternion.identity);
            _currentInfoDefenderButton.transform.SetParent(transform);
        }
        else if (attacker || _currencyProducer)
        {
            _currentInfoDamageHealthBar = Instantiate(infoDamageHealthBar, transform.position, Quaternion.identity);
            _currentInfoDamageHealthBar.transform.SetParent(transform);
        }
        else if (defender)     // Box
        {
            _currentInfoBox = Instantiate(infoBox, transform.position, Quaternion.identity);
            _currentInfoBox.transform.SetParent(transform);
        }
    }
Exemplo n.º 2
0
    public void LevelBossResult()
    {
        levelBossResult = Instantiate(ResManager.instance.levelBossResult, canvas);
        Button принять = levelBossResult.transform.GetChild(0).GetComponent <Button>();

        принять.onClick.AddListener(delegate { Принять(); });
        Text             resultText   = levelBossResult.transform.GetChild(1).GetComponent <Text>();
        Transform        trophysPanel = levelBossResult.transform.GetChild(2);
        List <Transform> trophys      = new List <Transform>();

        for (int i = 0; i < trophysPanel.childCount; i++)
        {
            trophys.Add(trophysPanel.GetChild(i));
            trophys[i].gameObject.SetActive(false);
        }
        if (isWinner)
        {
            resultText.text = GameText.VictoryText();
            List <TrophyRes> tRes = Trophy.GetRes(levelName);
            Debug.Log("tResCount: " + tRes.Count);
            List <TrophyRes> tResSort = new List <TrophyRes>();
            for (int i = 0; i < tRes.Count; i++)
            {
                if (tRes[i].count > 0)
                {
                    tResSort.Add(tRes[i]);
                }
            }
            Debug.Log("tResSortCount: " + tResSort.Count);
            for (int i = 0; i < tResSort.Count; i++)
            {
                InfoResources res = GetInfoResources.GetInfo(tResSort[i].num);
                trophys[i].GetChild(0).GetComponent <Image>().sprite = res.img;
                trophys[i].GetChild(1).GetComponent <Text>().text    = tResSort[i].count.ToString();
                GameManager.resource[tResSort[i].num]               += tResSort[i].count;
                trophys[i].transform.GetComponent <ResBtn>().Name    = res.name;
                trophys[i].transform.GetComponent <ResBtn>().message = this;
                trophys[i].gameObject.SetActive(true);
            }
        }
        else
        {
            resultText.text = GameText.LoseText();
        }
    }
Exemplo n.º 3
0
    public void ЗаполнениеРесурсов()
    {
        rNCU.Clear();
        for (int i = 0; i < ресурсы.transform.childCount; i++)
        {
            GameObject gO = ресурсы.transform.GetChild(i).gameObject;
            gO.SetActive(false);
            кнопкиРесурсов.Add(gO.GetComponent <NeedResources>());
        }
        Resource             res = NeedResToUnit.GetRes(создающийся.type);
        List <InfoResources> ir  = new List <InfoResources>();

        for (int i = 0; i < res.resource.Length; i++)
        {
            if (res.resource[i] != 0)
            {
                InfoResources ires = GetInfoResources.GetInfo(i);
                ir.Add(ires);
                RNCU temp = new RNCU();
                temp.num   = i;
                temp.count = res.resource[i] * currentCountUnit;
                rNCU.Add(temp);
            }
        }
        CheckAvaibelUnitCreate(ir, res);
        for (int i = 0; i < ir.Count; i++)
        {
            кнопкиРесурсов[i].img.sprite = ir[i].img;
            кнопкиРесурсов[i].text.text  = (res.resource[ir[i].num] * currentCountUnit).ToString();
            if (GameManager.resource[ir[i].num] >= res.resource[ir[i].num])
            {
                canBuy = true;
                кнопкиРесурсов[i].text.color = Colors.GreenColor;
            }
            else
            {
                кнопкиРесурсов[i].text.color = Colors.RedColor;
                canBuy = false;
            }
            кнопкиРесурсов[i].resource = ir[i].num;
            кнопкиРесурсов[i].count    = res.resource[ir[i].num];
            кнопкиРесурсов[i].gameObject.SetActive(true);
        }
    }
Exemplo n.º 4
0
    public static InfoResources GetInfo(int resNum)
    {
        InfoResources res = new InfoResources();

        switch (resNum)
        {
        case GOLD:
            res.img = ResManager.instance.imgRes[0];
            if (GameManager.instance.isRussian)
            {
                res.name = "Золото";
            }
            else
            {
                res.name = "Gold";
            }
            break;

        case BONES:
            res.img = ResManager.instance.imgRes[1];
            if (GameManager.instance.isRussian)
            {
                res.name = "Кости";
            }
            else
            {
                res.name = "Bones";
            }
            break;

        case BODY:
            res.img = ResManager.instance.imgRes[2];
            if (GameManager.instance.isRussian)
            {
                res.name = "Плоть";
            }
            else
            {
                res.name = "Body";
            }
            break;

        case WOOD:
            res.img = ResManager.instance.imgRes[3];
            if (GameManager.instance.isRussian)
            {
                res.name = "Дерево";
            }
            else
            {
                res.name = "Wood";
            }
            break;

        case IRON:
            res.img = ResManager.instance.imgRes[6];
            if (GameManager.instance.isRussian)
            {
                res.name = "Железо";
            }
            else
            {
                res.name = "Iron";
            }
            break;

        case SOULS:
            res.img = ResManager.instance.imgRes[5];
            if (GameManager.instance.isRussian)
            {
                res.name = "Души";
            }
            else
            {
                res.name = "Souls";
            }
            break;

        case REAL:
            res.img = ResManager.instance.imgRes[4];
            if (GameManager.instance.isRussian)
            {
                res.name = "Кристаллы";
            }
            else
            {
                res.name = "Real";
            }
            break;

        default:
            res.img = ResManager.instance.imgRes[7];
            if (GameManager.instance.isRussian)
            {
                res.name = "Хрень";
            }
            else
            {
                res.name = "Gadget";
            }
            break;
        }
        res.num = resNum;
        return(res);
    }