Example #1
0
        public static void InitDB()
        {
            if (init)
            {
                return;
            }
            init = true;

            towerDBList     = TowerDB.Load();
            abilityDBList   = AbilityDB.Load();
            perkDBList      = PerkDB.Load();
            fpsWeaponDBList = FPSWeaponDB.Load();
        }
Example #2
0
        public void InitWeapon()
        {
            List <FPSWeapon> dbList = FPSWeaponDB.Load();

            weaponList = new List <FPSWeapon>();
            for (int i = 0; i < dbList.Count; i++)
            {
                if (!unavailableIDList.Contains(dbList[i].prefabID))
                {
                    weaponList.Add(dbList[i]);
                }
            }

            List <FPSWeapon> newList = PerkManager.GetUnlockedWeapon();

            for (int i = 0; i < newList.Count; i++)
            {
                weaponList.Add(newList[i]);
            }
        }
Example #3
0
        public string _PurchasePerk(Perk perk, bool useRsc = true)
        {
            string text = perk.Purchase(useRsc);

            if (text != "")
            {
                return(text);
            }

            if (onPerkPurchasedE != null)
            {
                onPerkPurchasedE(perk);
            }

            //process the prereq for other perk
            for (int i = 0; i < perkList.Count; i++)
            {
                Perk perkTemp = perkList[i];
                if (perkTemp.purchased || perkTemp.prereq.Count == 0)
                {
                    continue;
                }
                perkTemp.prereq.Remove(perk.ID);
            }


            perkPoint += 1;
            if (onPerkPointE != null)
            {
                onPerkPointE(perkPoint);
            }

            if (perk.type == _PerkType.NewTower)
            {
                List <UnitTower> towerList = TowerDB.Load();
                for (int i = 0; i < towerList.Count; i++)
                {
                    if (towerList[i].prefabID == perk.itemIDList[0])
                    {
                        unlockedTower.Add(towerList[i]);
                        BuildManager.AddNewTower(towerList[i]);
                    }
                }
            }
            else if (perk.type == _PerkType.NewAbility)
            {
                List <Ability> abilityList = AbilityDB.Load();
                for (int i = 0; i < abilityList.Count; i++)
                {
                    if (abilityList[i].ID == perk.itemIDList[0])
                    {
                        unlockedAbility.Add(abilityList[i]);
                        AbilityManager.AddNewAbility(abilityList[i]);
                    }
                }
            }
            else if (perk.type == _PerkType.NewFPSWeapon)
            {
                List <FPSWeapon> FPSWeaponList = FPSWeaponDB.Load();
                for (int i = 0; i < FPSWeaponList.Count; i++)
                {
                    if (FPSWeaponList[i].prefabID == perk.itemIDList[0])
                    {
                        unlockedWeapon.Add(FPSWeaponList[i]);
                        FPSControl.AddNewWeapon(FPSWeaponList[i]);
                    }
                }
            }

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

            else if (perk.type == _PerkType.GainRsc)
            {
                List <int> valueList = new List <int>();
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    valueList.Add((int)perk.valueRscList[i]);
                }
                ResourceManager.GainResource(valueList, null, false);                   //dont pass multiplier and dont use multiplier
            }
            else if (perk.type == _PerkType.RscRegen)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscRegen[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscGain[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscCreepKilledGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscCreepKilledGain[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscWaveClearedGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscWaveClearedGain[i] += perk.valueRscList[i];
                }
            }
            else if (perk.type == _PerkType.RscResourceTowerGain)
            {
                for (int i = 0; i < perk.valueRscList.Count; i++)
                {
                    rscRscTowerGain[i] += perk.valueRscList[i];
                }
            }

            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.FPSWeapon)
            {
                ModifyFPSWeaponModifier(globalFPSWeaponModifier, perk);
            }
            else if (perk.type == _PerkType.FPSWeaponSpecific)
            {
                for (int i = 0; i < perk.itemIDList.Count; i++)
                {
                    int ID = FPSWeaponModifierExist(perk.itemIDList[i]);
                    if (ID == -1)
                    {
                        PerkFPSWeaponModifier weaponModifier = new PerkFPSWeaponModifier();
                        weaponModifier.prefabID = perk.itemIDList[i];
                        FPSWeaponModifierList.Add(weaponModifier);
                        ID = FPSWeaponModifierList.Count - 1;
                    }
                    ModifyFPSWeaponModifierInList(ID, perk);
                }
            }

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

            return("");
        }