public void InitTower(int ID) { Init(); instanceID = ID; value = stats[currentActiveStat].cost; int rscCount = ResourceManager.GetResourceCount(); for (int i = 0; i < stats.Count; i++) { UnitStat stat = stats[i]; stat.slow.effectID = instanceID; stat.dot.effectID = instanceID; stat.buff.effectID = instanceID; if (stat.rscGain.Count != rscCount) { while (stat.rscGain.Count < rscCount) { stat.rscGain.Add(0); } while (stat.rscGain.Count > rscCount) { stat.rscGain.RemoveAt(stat.rscGain.Count - 1); } } } if (type == _TowerType.Turret) { StartCoroutine(ScanForTargetRoutine()); StartCoroutine(TurretRoutine()); } if (type == _TowerType.AOE) { StartCoroutine(AOETowerRoutine()); } if (type == _TowerType.Support) { StartCoroutine(SupportRoutine()); } if (type == _TowerType.Resource) { StartCoroutine(ResourceTowerRoutine()); } if (type == _TowerType.Mine) { StartCoroutine(MineRoutine()); } }
public void Init() { int rscCount = ResourceManager.GetResourceCount(); while (rscSettingList.Count < rscCount) { rscSettingList.Add(new ProceduralVariable(0, 0)); } while (rscSettingList.Count > rscCount) { rscSettingList.RemoveAt(rscSettingList.Count - 1); } CheckPathList(); }
public void SetAsSampleTower(UnitTower tower) { isSampleTower = true; srcTower = tower; thisT.position = new Vector3(0, 99999, 0); int rscCount = ResourceManager.GetResourceCount(); for (int i = 0; i < stats.Count; i++) { if (stats[i].cost.Count != rscCount) { while (stats[i].cost.Count < rscCount) { stats[i].cost.Add(0); } while (stats[i].cost.Count > rscCount) { stats[i].cost.RemoveAt(stats[i].cost.Count - 1); } } } }
//parent unit is for unit which is spawned from destroyed unit public void Init(PathTD p, int ID, int wID, UnitCreep parentUnit = null) { Init(); path = p; instanceID = ID; waveID = wID; float dynamicX = Random.Range(-path.dynamicOffset, path.dynamicOffset); float dynamicZ = Random.Range(-path.dynamicOffset, path.dynamicOffset); pathDynamicOffset = new Vector3(dynamicX, 0, dynamicZ); thisT.position += pathDynamicOffset; if (parentUnit == null) { waypointID = 1; subWaypointID = 0; subPath = path.GetWPSectionPath(waypointID); } else { //inherit stats and path from parent unit waypointID = parentUnit.waypointID; subWaypointID = parentUnit.subWaypointID; subPath = parentUnit.subPath; defaultHP = parentUnit.defaultHP * parentUnit.spawnUnitHPMultiplier; HP = GetFullHP(); defaultShield = parentUnit.defaultShield * parentUnit.spawnUnitHPMultiplier; shield = GetFullShield(); } distFromDestination = CalculateDistFromDestination(); if (type == _CreepType.Offense) { maskTarget = 1 << TDTK.GetLayerTower(); StartCoroutine(ScanForTargetRoutine()); StartCoroutine(TurretRoutine()); } if (type == _CreepType.Support) { LayerMask mask1 = 1 << TDTK.GetLayerCreep(); LayerMask mask2 = 1 << TDTK.GetLayerCreepF(); maskTarget = mask1 | mask2; StartCoroutine(SupportRoutine()); } int rscCount = ResourceManager.GetResourceCount(); while (valueRscMin.Count < rscCount) { valueRscMin.Add(0); } while (valueRscMin.Count > rscCount) { valueRscMin.RemoveAt(valueRscMin.Count - 1); } while (valueRscMax.Count < rscCount) { valueRscMax.Add(0); } while (valueRscMax.Count > rscCount) { valueRscMax.RemoveAt(valueRscMax.Count - 1); } PlayAnimSpawn(); }
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); } } }
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); } }