Beispiel #1
0
        public void Init()
        {
            if (Application.isPlaying && init)
            {
                return;
            }

            init = true;

            int count = RscManager.GetResourceCount();

            if (attRscGainOnCleared.Count < count)
            {
                while (attRscGainOnCleared.Count < count)
                {
                    attRscGainOnCleared.Add(new GenAttribute(true));
                }
            }
            else if (attRscGainOnCleared.Count > count)
            {
                while (attRscGainOnCleared.Count > count)
                {
                    attRscGainOnCleared.RemoveAt(attRscGainOnCleared.Count - 1);
                }
            }

            for (int i = 0; i < genItemList.Count; i++)
            {
                genItemList[i].VerifyRsc(count);
            }
        }
Beispiel #2
0
        public void _Show(Ability ability, Vector3 pos, int pivotCorner = 2, Vector3 offset = default(Vector3))
        {
            SetPivot(pivotCorner);

            labelName.text = ability.name;
            labelDesp.text = ability.desp;    labelDesp.enabled = true;

            if (AbilityManager.UseRscManagerForCost())
            {
                List <float> cost = ability.GetCostRsc();
                for (int i = 0; i < RscManager.GetResourceCount(); i++)
                {
                    rscItemList[i].imgMain.sprite = RscManager.GetRscIcon(i);
                    rscItemList[i].lbMain.text    = cost[i].ToString("f0");
                    rscItemList[i].SetActive(true);
                }
            }
            else
            {
                rscItemList[0].imgMain.sprite = AbilityDB.GetRscIcon();
                rscItemList[0].lbMain.text    = ability.GetCost().ToString("f0");
                for (int i = 1; i < RscManager.GetResourceCount(); i++)
                {
                    rscItemList[i].SetActive(false);
                }
            }

            minHeight = 120;

            rectT.position = pos + offset;

            canvasGroup.alpha = 1;
            thisObj.SetActive(true);
        }
Beispiel #3
0
        public void _ShowUpgrade(UnitTower tower, int uIdx, Vector3 pos, int pivotCorner = 2, Vector3 offset = default(Vector3))
        {
            SetPivot(pivotCorner);

            if (tower.GetUpgradeType() == 0)
            {
                labelName.text = "Upgrade";
            }
            else
            {
                labelName.text = "Upgrade to" + tower.GetUpgradeTower(uIdx).unitName;
            }

            labelDesp.enabled = false;

            List <float> cost = tower.GetUpgradeCost(uIdx);

            for (int i = 0; i < RscManager.GetResourceCount(); i++)
            {
                rscItemList[i].imgMain.sprite = RscManager.GetRscIcon(i);
                rscItemList[i].lbMain.text    = cost[i].ToString("f0");
            }

            minHeight      = -1;
            rectT.position = pos + offset;

            canvasGroup.alpha = 1;
            thisObj.SetActive(true);
        }
Beispiel #4
0
        void Start()
        {
            defaultRsclistMod = new List <float>();
            defaultRsclistMul = new List <float>();

            rscGainModList            = new List <int>();
            rscGainModCreepKilledList = new List <int>();
            rscGainModWaveClearedList = new List <int>();
            rscGainModRscTowerList    = new List <int>();

            rscGainMulList            = new List <float>();
            rscGainMulCreepKilledList = new List <float>();
            rscGainMulWaveClearedList = new List <float>();
            rscGainMulRscTowerList    = new List <float>();

            for (int i = 0; i < RscManager.GetResourceCount(); i++)
            {
                defaultRsclistMod.Add(0);
                defaultRsclistMul.Add(1);

                rscGainModList.Add(0);
                rscGainModCreepKilledList.Add(0);
                rscGainModWaveClearedList.Add(0);
                rscGainModRscTowerList.Add(0);

                rscGainMulList.Add(1);
                rscGainMulCreepKilledList.Add(1);
                rscGainMulWaveClearedList.Add(1);
                rscGainMulRscTowerList.Add(1);
            }

            for (int i = 0; i < perkList.Count; i++)
            {
                if (!purchasedPrefabIDList.Contains(perkList[i].prefabID))
                {
                    continue;
                }
                _PurchasePerk(i, false);
            }

            WaveCleared(0);
        }
Beispiel #5
0
        public void _ShowSell(UnitTower tower, Vector3 pos, int pivotCorner = 2, Vector3 offset = default(Vector3))
        {
            SetPivot(pivotCorner);

            labelName.text    = "Sell " + tower.unitName;
            labelDesp.enabled = false;

            List <float> cost = tower.GetSellValue();

            for (int i = 0; i < RscManager.GetResourceCount(); i++)
            {
                rscItemList[i].imgMain.sprite = RscManager.GetRscIcon(i);
                rscItemList[i].lbMain.text    = cost[i].ToString("f0");
            }

            minHeight      = -1;
            rectT.position = pos + offset;

            canvasGroup.alpha = 1;
            thisObj.SetActive(true);
        }
Beispiel #6
0
        public override void Start()
        {
            base.Start();

            for (int i = 0; i < RscManager.GetResourceCount(); i++)
            {
                if (i > 0)
                {
                    rscItemList.Add(new UIObject(UI.Clone(rscItemList[0].rootObj)));
                }
                rscItemList[i].Init();
                rscItemList[i].imgMain.sprite = RscManager.GetRscIcon(i);
            }

            rectName = labelName.gameObject.GetComponent <RectTransform>();
            rectDesp = labelDesp.gameObject.GetComponent <RectTransform>();

            canvasGroup.alpha          = 0;
            canvasGroup.interactable   = false;
            canvasGroup.blocksRaycasts = false;
            //thisObj.SetActive(false);
        }
Beispiel #7
0
 //~ public GenItem(int ID){ unitPrefabID=ID; }
 public GenItem(UnitCreep unit)
 {
     prefab = unit; unitPrefabID = unit.prefabID;
     VerifyRsc(RscManager.GetResourceCount());
 }
Beispiel #8
0
        public override void Start()
        {
            base.Start();

            if (!PerkManager.IsEnabled())
            {
                thisObj.SetActive(false);
                return;
            }

            if (PerkManager.UseRscManagerForCost())
            {
                for (int i = 0; i < RscManager.GetResourceCount(); i++)
                {
                    if (i > 0)
                    {
                        costItemList.Add(new UIObject(UI.Clone(costItemList[0].rootObj)));
                    }
                    costItemList[i].Init();
                    costItemList[i].imgMain.sprite = RscManager.GetRscIcon(i);
                }
            }
            else
            {
                costItemList[0].Init();
                costItemList[0].imgMain.sprite = PerkDB.GetRscIcon();
            }

            if (customLayout)
            {
                List <Perk> perkList = PerkManager.GetPerkList();
                for (int i = 0; i < itemList.Count; i++)
                {
                    itemList[i].Init();
                    itemList[i].SetCallback(null, null, this.OnItem, null);

                    bool matched = false;
                    for (int n = 0; n < perkList.Count; n++)
                    {
                        if (itemList[i].linkedPerkPID == perkList[n].prefabID)
                        {
                            itemList[i].linkedPerkIdx  = n;    matched = true;
                            itemList[i].imgMain.sprite = perkList[n].icon;
                        }
                    }

                    if (!matched)
                    {
                        Debug.LogWarning("No perk with matching prefab found");
                        itemList[i].rootObj.SetActive(false);
                        continue;
                    }

                    itemList[i].UnparentConnector();
                    itemList[i].UnparentConnectorBase();
                }
            }
            else
            {
                List <Perk> perkList = PerkManager.GetPerkList();
                for (int i = 0; i < perkList.Count; i++)
                {
                    if (i > 0)
                    {
                        itemList.Add(UIPerkItem.Clone(itemList[0].rootObj, "Item" + (i)));
                    }
                    itemList[i].Init();
                    itemList[i].SetCallback(null, null, this.OnItem, null);
                    itemList[i].linkedPerkIdx  = i;
                    itemList[i].imgMain.sprite = perkList[i].icon;
                }
            }

            buttonPurchase.Init();
            buttonPurchase.SetCallback(null, null, this.OnPurchaseButton, null);

            if (UIControl.IsGameScene())
            {
                buttonClose.Init();
                buttonClose.SetCallback(null, null, this.OnCloseButton, null);
            }

            if (!UIControl.IsGameScene())
            {
                canvasGroup.alpha = 1;
                thisObj.SetActive(true);
                StartCoroutine(DelayUpdateList());
            }
            else
            {
                thisObj.SetActive(false);
            }

            OnItem(itemList[0].rootObj);
        }
Beispiel #9
0
        // Use this for initialization
        void Start()
        {
            GameObject lastSpaceObj = null;

            if (UIControl.IsGameScene())
            {
                lifeItem.Init();
                waveItem.Init();

                UpdateLifeDisplay(GameControl.GetLife());
                UpdateWaveDisplay(1);

                lastSpaceObj = spaceObjLife;
            }
            else
            {
                waveItem.rootObj.SetActive(false);
                spaceObjWave.SetActive(false);

                lifeItem.rootObj.SetActive(false);
                spaceObjLife.SetActive(false);
            }


            if (UIControl.IsGameScene() || PerkManager.UseRscManagerForCost())
            {
                for (int i = 0; i < RscManager.GetResourceCount(); i++)
                {
                    if (i > 0)
                    {
                        rscItemList.Add(new UIObject(UI.Clone(rscItemList[0].rootObj)));
                    }
                    rscItemList[i].Init();
                    rscItemList[i].imgMain.sprite = RscManager.GetRscIcon(i);

                    rscItemList[i].rectT.SetSiblingIndex(rscItemList[0].rectT.GetSiblingIndex() + i);
                }
                UpdateResourceDisplay(RscManager.GetResourceList());

                lastSpaceObj = spaceObjRsc;
            }
            else
            {
                rscItemList[0].rootObj.SetActive(false);
                spaceObjRsc.SetActive(false);
            }


            if (!UIControl.IsGameScene() || !AbilityManager.IsEnabled() || AbilityManager.UseRscManagerForCost())
            {
                sliderAbilityRsc.gameObject.SetActive(false);
                spaceObjAbility.SetActive(false);
            }
            else
            {
                imgAbilityRsc.sprite = AbilityDB.GetRscIcon();
                UpdateAbilityRscDisplay(AbilityManager.GetRsc());
                lastSpaceObj = spaceObjAbility;
            }

            if (!PerkManager.IsEnabled() || PerkManager.UseRscManagerForCost())
            {
                perkRscItem.rootObj.SetActive(false);
                //spaceObjPerk.SetActive(false);
                lastSpaceObj.SetActive(false);
            }
            else
            {
                perkRscItem.Init();
                perkRscItem.imgMain.sprite = PerkDB.GetRscIcon();
                UpdatePerkRscDisplay(PerkManager.GetRsc());
            }



            //~ if(!UIControl.DisablePerkScreen()){
            //~ buttonPerk.Init();
            //~ buttonPerk.SetCallback(null, null, this.OnPerkButton, null);
            //~ }
            //~ else{
            //~ if(buttonPerk.rootObj!=null) buttonPerk.rootObj.SetActive(false);
            //~ }


            //~ buttonFF.Init();
            //~ buttonFF.SetCallback(null, null, this.OnFFButton, null);

            //~ buttonPause.Init();
            //~ buttonPause.SetCallback(null, null, this.OnPauseButton, null);
        }