public static void InitDB() { if (init) { return; } init = true; towerDBList = TowerDB.Load(); abilityDBList = AbilityDB.Load(); perkDBList = PerkDB.Load(); fpsWeaponDBList = FPSWeaponDB.Load(); }
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); } }