Exemplo n.º 1
0
		public void Init(){
			if(init) return;
			
			init=true;
			
			if(instance!=null){
				Destroy(gameObject);
				return;
			}
			
			instance=this;
			
			//load your custom/saved purchasedIDList here if you are doing a persistent perk system
			
			List<Perk> dbList=PerkDB.Load();
			for(int i=0; i<dbList.Count; i++){
				if(!unavailableIDList.Contains(dbList[i].ID)){
					Perk perk=dbList[i].Clone();
					perkList.Add(perk);
				}
			}
			
			globalTowerModifier=new PerkTowerModifier();
			globalAbilityModifier=new PerkAbilityModifier();
			globalFPSWeaponModifier=new PerkFPSWeaponModifier();
			
			emptyTowerModifier=new PerkTowerModifier();
			emptyAbilityModifier=new PerkAbilityModifier();
			emptyFPSWeaponModifier=new PerkFPSWeaponModifier();
			
			int rscCount=ResourceManager.GetResourceCount();
			for(int i=0; i<rscCount; i++){
				rscRegen.Add(0);
				rscGain.Add(0);
				rscCreepKilledGain.Add(0);
				rscWaveClearedGain.Add(0);
				rscRscTowerGain.Add(0);
			}
			
			for(int i=0; i<perkList.Count; i++){
				if(purchasedIDList.Contains(perkList[i].ID)){
					if(perkList[i].type==_PerkType.NewTower || perkList[i].type==_PerkType.NewAbility || perkList[i].type==_PerkType.NewFPSWeapon){
						StartCoroutine(DelayPurchasePerk(perkList[i]));
					}
					else _PurchasePerk(perkList[i], false);	//dont use rsc since these are pre-purchased perk
				}
			}
			
			if(persistantProgress){
				transform.parent=null;
				DontDestroyOnLoad(gameObject);
			}
		}
Exemplo n.º 2
0
 private void ModifyFPSWeaponModifier(PerkFPSWeaponModifier weaponModifier, Perk perk)
 {
     ModifyUnitStats(weaponModifier.stats, perk.stats);
 }
Exemplo n.º 3
0
        public void Init()
        {
            if (init)
            {
                return;
            }

            init = true;

            if (instance != null)
            {
                Destroy(gameObject);
                return;
            }

            instance = this;

            availableIDList = new List <int>();
            List <Perk> dbList = TDTK.GetPerkDBList();          //PerkDB.Load();

            for (int i = 0; i < dbList.Count; i++)
            {
                if (!unavailableIDList.Contains(dbList[i].ID))
                {
                    perkList.Add(dbList[i].Clone());
                    availableIDList.Add(dbList[i].ID);
                }
            }

            globalTowerModifier     = new PerkTowerModifier();
            globalAbilityModifier   = new PerkAbilityModifier();
            globalFPSWeaponModifier = new PerkFPSWeaponModifier();

            emptyTowerModifier     = new PerkTowerModifier();
            emptyAbilityModifier   = new PerkAbilityModifier();
            emptyFPSWeaponModifier = new PerkFPSWeaponModifier();


            int rscCount = ResourceManager.GetResourceCount();

            for (int i = 0; i < rscCount; i++)
            {
                rscRegen.Add(0);
                rscGain.Add(0);
                rscCreepKilledGain.Add(0);
                rscWaveClearedGain.Add(0);
                rscRscTowerGain.Add(0);
            }

            for (int i = 0; i < perkList.Count; i++)
            {
                while (perkList[i].cost.Count < rscCount)
                {
                    perkList[i].cost.Add(0);
                }
                while (perkList[i].cost.Count > rscCount)
                {
                    perkList[i].cost.RemoveAt(perkList[i].cost.Count - 1);
                }

                while (perkList[i].valueRscList.Count < rscCount)
                {
                    perkList[i].valueRscList.Add(0);
                }
                while (perkList[i].valueRscList.Count > rscCount)
                {
                    perkList[i].valueRscList.RemoveAt(perkList[i].valueRscList.Count - 1);
                }
            }

            Debug.Log("mod repetable perk");

            //load your custom/saved purchasedIDList here if you are doing a persistent perk system
            LoadPurchasedPerk();

            for (int i = 0; i < perkList.Count; i++)
            {
                if (purchasedIDList.Contains(perkList[i].ID))
                {
                    _PurchasePerk(perkList[i], false);
                }
            }
        }
Exemplo n.º 4
0
        public string _PurchasePerk(Perk perk, bool useRsc = true)
        {
            string text = perk.Purchase(useRsc);

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

            if (!purchasedIDList.Contains(perk.ID))
            {
                purchasedIDList.Add(perk.ID);
            }
            SavePurchasedPerk();

            TDTK.OnPerkPurchased(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;
            TDTK.OnPerkPoint();

            if (perk.type == _PerkType.NewTower)
            {
                UnitTower tower = TDTK.GetDBTower(perk.itemIDList[0]);
                unlockedTowerList.Add(tower);
                BuildManager.AddNewTower(tower);
            }
            else if (perk.type == _PerkType.NewAbility)
            {
                Ability ability = TDTK.GetDBAbility(perk.itemIDList[0]);
                unlockedAbilityList.Add(ability);
                AbilityManager.AddNewAbility(ability);
            }
            else if (perk.type == _PerkType.NewFPSWeapon)
            {
                FPSWeapon weapon = TDTK.GetDBFpsWeapon(perk.itemIDList[0]);
                unlockedWeaponList.Add(weapon);
                FPSControl.AddNewWeapon(weapon);
            }

            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("");
        }
Exemplo n.º 5
0
		private void ModifyFPSWeaponModifier(PerkFPSWeaponModifier weaponModifier, Perk perk){ ModifyUnitStats(weaponModifier.stats, perk.stats); }
Exemplo n.º 6
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 "";
		}
Exemplo n.º 7
0
        public void Init()
        {
            if (init)
            {
                return;
            }

            init = true;

            if (instance != null)
            {
                Destroy(gameObject);
                return;
            }

            instance = this;

            //load your custom/saved purchasedIDList here if you are doing a persistent perk system

            List <Perk> dbList = PerkDB.Load();

            for (int i = 0; i < dbList.Count; i++)
            {
                if (!unavailableIDList.Contains(dbList[i].ID))
                {
                    Perk perk = dbList[i].Clone();
                    perkList.Add(perk);
                }
            }

            globalTowerModifier     = new PerkTowerModifier();
            globalAbilityModifier   = new PerkAbilityModifier();
            globalFPSWeaponModifier = new PerkFPSWeaponModifier();

            emptyTowerModifier     = new PerkTowerModifier();
            emptyAbilityModifier   = new PerkAbilityModifier();
            emptyFPSWeaponModifier = new PerkFPSWeaponModifier();

            int rscCount = ResourceManager.GetResourceCount();

            for (int i = 0; i < rscCount; i++)
            {
                rscRegen.Add(0);
                rscGain.Add(0);
                rscCreepKilledGain.Add(0);
                rscWaveClearedGain.Add(0);
                rscRscTowerGain.Add(0);
            }

            for (int i = 0; i < perkList.Count; i++)
            {
                if (purchasedIDList.Contains(perkList[i].ID))
                {
                    if (perkList[i].type == _PerkType.NewTower || perkList[i].type == _PerkType.NewAbility || perkList[i].type == _PerkType.NewFPSWeapon)
                    {
                        StartCoroutine(DelayPurchasePerk(perkList[i]));
                    }
                    else
                    {
                        _PurchasePerk(perkList[i], false);                      //dont use rsc since these are pre-purchased perk
                    }
                }
            }

            if (persistantProgress)
            {
                transform.parent = null;
                DontDestroyOnLoad(gameObject);
            }
        }