Esempio n. 1
0
        private static void LoadFPSWeapon()
        {
            fpsWeaponDBPrefab = FPSWeaponDB.LoadDB();
            weaponList        = fpsWeaponDBPrefab.weaponList;

            for (int i = 0; i < weaponList.Count; i++)
            {
                //weaponList[i].prefabID=i;
                if (weaponList[i] != null)
                {
                    weaponIDList.Add(weaponList[i].prefabID);
                    if (weaponList[i].stats.Count == 0)
                    {
                        weaponList[i].stats.Add(new UnitStat());
                    }
                }
                else
                {
                    weaponList.RemoveAt(i);
                    i -= 1;
                }
            }

            UpdateWeaponNameList();
        }
Esempio n. 2
0
        public static void InitDB()
        {
            if (init)
            {
                return;
            }
            init = true;

            towerDBList     = TowerDB.Load();
            abilityDBList   = AbilityDB.Load();
            perkDBList      = PerkDB.Load();
            fpsWeaponDBList = FPSWeaponDB.Load();
        }
Esempio n. 3
0
        public static List <FPSWeapon> Load()
        {
            GameObject obj = Resources.Load("DB_TDTK/FPSWeaponDB", typeof(GameObject)) as GameObject;

                        #if UNITY_EDITOR
            if (obj == null)
            {
                obj = CreatePrefab();
            }
                        #endif

            FPSWeaponDB instance = obj.GetComponent <FPSWeaponDB>();
            return(instance.weaponList);
        }
Esempio n. 4
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]);
            }
        }
Esempio n. 5
0
        public static void LoadFPSWeapon()
        {
            fpsWeaponDB = FPSWeaponDB.LoadDB();

            for (int i = 0; i < fpsWeaponDB.weaponList.Count; i++)
            {
                if (fpsWeaponDB.weaponList[i] != null)
                {
                    fpsWeaponIDList.Add(fpsWeaponDB.weaponList[i].prefabID);
                }
                else
                {
                    fpsWeaponDB.weaponList.RemoveAt(i);       i -= 1;
                }
            }

            UpdateLabel_FPSWeapon();

            TDEditorWindow.SetFPSWeaponDB(fpsWeaponDB, fpsWeaponIDList, fpsWeaponLabel);
            TDEditorInspector.SetFPSWeaponDB(fpsWeaponDB, fpsWeaponIDList, fpsWeaponLabel);
        }
		private static void LoadFPSWeapon(){
			fpsWeaponDBPrefab=FPSWeaponDB.LoadDB();
			weaponList=fpsWeaponDBPrefab.weaponList;
			
			for(int i=0; i<weaponList.Count; i++){
				//weaponList[i].prefabID=i;
				if(weaponList[i]!=null){
					weaponIDList.Add(weaponList[i].prefabID);
					if(weaponList[i].stats.Count==0) weaponList[i].stats.Add(new UnitStat());
				}
				else{
					weaponList.RemoveAt(i);
					i-=1;
				}
			}
			
			UpdateWeaponNameList();
		}
Esempio n. 7
0
 public static void SetFPSWeaponDB(FPSWeaponDB db, List <int> IDList, string[] label)
 {
     fpsWeaponDB     = db;
     fpsWeaponIDList = IDList;
     fpsWeaponLabel  = label;
 }
Esempio n. 8
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("");
        }