Example #1
0
        public void OnItem(GameObject butObj, int pointerID = -1)
        {
            int idx = GetItemIndex(butObj);

            selectedIdx = idx;

            selectHighlightT.localPosition = itemList[idx].rectT.localPosition - new Vector3(35, -35, 0);
            //Debug.Log(selectHighlightT.localPosition+"  "+itemList[idx].rectT.localPosition);

            Perk perk = PerkManager.GetPerkFromList(itemList[idx].linkedPerkIdx);

            lbPerkName.text        = perk.name;
            lbPerkDesp.text        = perk.desp;
            lbPerkUnavailable.text = perk.GetDespUnavailable();

            if (!PerkManager.UseRscManagerForCost())
            {
                int cost = perk.GetPurchaseCost();
                costItemList[0].lbMain.text = cost.ToString("f0");
            }
            else
            {
                List <float> cost = perk.GetPurchaseCostRsc();
                for (int i = 0; i < cost.Count; i++)
                {
                    costItemList[i].lbMain.text = cost[i].ToString("f0");
                }
            }

            buttonPurchase.SetActive(!perk.IsPurchased() & perk.IsAvailable());
        }
Example #2
0
        void UpdateDisplay()
        {
            lbPerkPoint.text = "Points: " + PerkManager.GetPerkPoint();

            Perk perk = PerkManager.GetPerk(perkItemList[selectID].perkID);

            lbPerkName.text = perk.name;
            lbPerkDesp.text = perk.desp;

            if (perk.purchased)
            {
                lbPerkReq.text = "";
                rscRootObj.SetActive(false);

                butPurchase.label.text          = "Purchased";
                butPurchase.button.interactable = false;
                return;
            }

            butPurchase.label.text = "Purchase";

            string text = perk.IsAvailable();

            if (text == "")
            {
                List <int> cost = perk.GetCost();
                for (int i = 0; i < rscItemList.Count; i++)
                {
                    rscItemList[i].label.text = cost[i].ToString();
                }

                lbPerkReq.text = "";
                rscRootObj.SetActive(true);
                butPurchase.button.interactable = true;
            }
            else
            {
                lbPerkReq.text = text;
                rscRootObj.SetActive(false);
                butPurchase.button.interactable = false;
            }
        }
Example #3
0
        public bool _PurchasePerk(Perk perk)
        {
            if (perk.IsAvailable() == false)
            {
                return(false);
            }

            if (perk.type == _PerkType.GainLife)
            {
                GameControl.GainLife((int)Random.Range(perk.perkLevel[perk.level].value, perk.perkLevel[perk.level].valueAlt));
            }
            else if (perk.type == _PerkType.LifeCap)
            {
                lifeCap += (int)perk.perkLevel[perk.level].value; GameControl.GainLife(0);
            }
            else if (perk.type == _PerkType.LifeRegen)
            {
                lifeRegen += perk.perkLevel[perk.level].value;
            }
            else if (perk.type == _PerkType.LifeWaveClearedBonus)
            {
                lifeWaveClearedBonus += (int)perk.perkLevel[perk.level].value;
            }

            else if (perk.type == _PerkType.RscCap)
            {
                int _value = (int)perk.perkLevel[perk.level].valueRsc;
                ResourceManager.GainResource(_value, 0, false); //dont pass multiplier and dont use multiplier
            }
            else if (perk.type == _PerkType.RscRegen)
            {
                rscRegen += perk.perkLevel[perk.level].valueRsc;
            }
            else if (perk.type == _PerkType.RscGain)
            {
                rscGain += perk.perkLevel[perk.level].valueRsc;
            }
            else if (perk.type == _PerkType.RscCreepKilledGain)
            {
                rscCreepKilledGain += perk.perkLevel[perk.level].valueRsc;
            }
            else if (perk.type == _PerkType.RscWaveClearedGain)
            {
                rscWaveClearedGain += perk.perkLevel[perk.level].valueRsc;
            }
            else if (perk.type == _PerkType.RscResourceTowerGain)
            {
                rscRscTowerGain += perk.perkLevel[perk.level].valueRsc;
            }

            else if (perk.type == _PerkType.Tower)
            {
                ModifyTowerModifier(globalTowerModifier, perk);
            }
            else if (perk.type == _PerkType.TowerSpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = TowerModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkTowerModifier towerModifier = new PerkTowerModifier();
                        towerModifier.prefabID = perk.itemIDList[i];
                        towerModifierList.Add(towerModifier);
                        ID = towerModifierList.Count - 1;
                    }
                    ModifyTowerModifierInList(ID, perk);
                }
            }
            else if (perk.type == _PerkType.Ability)
            {
                ModifyAbilityModifier(globalAbilityModifier, perk);
            }
            else if (perk.type == _PerkType.AbilitySpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = AbilityModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkAbilityModifier abilityModifier = new PerkAbilityModifier();
                        abilityModifier.abilityID = perk.itemIDList[i];
                        abilityModifierList.Add(abilityModifier);
                        ID = abilityModifierList.Count - 1;
                    }
                    ModifyAbilityModifierInList(ID, perk);
                }
            }

            else if (perk.type == _PerkType.EnergyRegen)
            {
                energyRegen += perk.perkLevel[perk.level].value;
            }
            else if (perk.type == _PerkType.EnergyIncreaseCap)
            {
                energyCap += perk.perkLevel[perk.level].value;
            }
            else if (perk.type == _PerkType.EnergyCreepKilledBonus)
            {
                energyCreepKilledBonus += perk.perkLevel[perk.level].value;
            }
            else if (perk.type == _PerkType.EnergyWaveClearedBonus)
            {
                energyWaveClearedBonus += perk.perkLevel[perk.level].value;
            }

            return(true);
        }