public void Cleared() { cleared = true; GameControl.GainLife(PerkManager.GetLifeGainOnWaveCleared(lifeGainOnCleared)); RscManager.GainRsc(rscGainOnCleared, RscManager._GainType.WaveCleared); PerkManager.GainRsc(perkRscGainOnCleared); AbilityManager.GainRsc(PerkManager.GetAbRscGainOnWaveCleared(abilityRscGainOnCleared)); PerkManager.WaveCleared(waveIdx + 1); }
public override void Destroyed(bool spawnEffDestroyed = true) { path.OnCreepExit(this); if (spawnEffDestroyed) { effectDestroyed.Spawn(GetPos(), Quaternion.identity); AudioManager.PlaySound(soundDestroyed); } if (IsSupport()) { SupportClearAllTarget(); } if (spawnOnDestroyed != null && sodCount > 0) { float oHP = sodOverride.GetHP(this); float oSH = sodOverride.GetSH(this); float oSpd = sodOverride.GetSpd(this); int oExp = sodOverride.GetExp(this); List <int> oRsc = sodOverride.GetRsc(this, rscGainOnDestroyed); for (int i = 0; i < sodCount; i++) { SpawnSubCreep(spawnOnDestroyed, oHP, oSH, oSpd, oExp, oRsc); } } ClearAllEffect(); if (Random.value < lifeGainedOnDestroyedChance) { GameControl.GainLife(lifeGainedOnDestroyed); } RscManager.GainRsc(rscGainOnDestroyed, RscManager._GainType.CreepKilled); float animDuration = AnimPlayDestroyed(); SpawnManager.CreepDestroyed(this); ObjectPoolManager.Unspawn(thisObj, animDuration); //Destroy(thisObj); }
public override void Destroyed(float delay = 0) { if (destroyed) { return; } destroyed = true; List <int> rscGain = new List <int>(); for (int i = 0; i < valueRscMin.Count; i++) { rscGain.Add(Random.Range(valueRscMin[i], valueRscMax[i])); } ResourceManager.GainResource(rscGain, PerkManager.GetRscCreepKilled()); AbilityManager.GainEnergy(valueEnergyGain + (int)PerkManager.GetEnergyWaveClearedModifier()); if (lifeValue > 0) { GameControl.GainLife(lifeValue); } if (spawnUponDestroyed != null && spawnUponDestroyedCount > 0) { for (int i = 0; i < spawnUponDestroyedCount; i++) { Vector3 posOffset = new Vector3(Random.Range(-0.5f, 0.5f), 0, Random.Range(-0.5f, 0.5f)); GameObject obj = ObjectPoolManager.Spawn(spawnUponDestroyed.gameObject, thisT.position + posOffset, thisT.rotation); UnitCreep unit = obj.GetComponent <UnitCreep>(); unit.waveID = waveID; int ID = SpawnManager.AddDestroyedSpawn(unit); unit.Init(path, ID, waveID, this); } } SpawnManager.OnUnitDestroyed(this); TDTK.OnUnitCreepDestroyed(this); base.Destroyed(PlayAnimDestroyed()); }
void OnUnitCleared(UnitCreep creep) { int waveID = creep.waveID; activeUnitCount -= 1; Wave wave = waveList[waveID]; wave.activeUnitCount -= 1; if (wave.spawned && wave.activeUnitCount == 0) { wave.cleared = true; waveClearedCount += 1; Debug.Log("wave" + (waveID + 1) + " is cleared"); ResourceManager.GainResource(wave.rscGainList); GameControl.GainLife(wave.lifeGain); if (IsAllWaveCleared()) { GameControl.GameWon(); } else { if (spawnMode == _SpawnMode.Round && onEnableSpawnE != null) { onEnableSpawnE(); } } } if (!IsAllWaveCleared() && activeUnitCount == 0 && !spawning) { if (spawnMode == _SpawnMode.WaveCleared) { SpawnWaveFinite(); } } }
void OnUnitCleared(UnitCreep creep) { int waveID = creep.waveID; activeUnitCount -= 1; Wave wave = null; if (spawnLimit == _SpawnLimit.Finite) { wave = waveList[waveID]; } else if (spawnLimit == _SpawnLimit.Infinite) { for (int i = 0; i < waveList.Count; i++) { if (waveList[i].waveID == waveID) { wave = waveList[i]; break; } } if (wave == null) { Debug.Log("error!"); return; } } wave.activeUnitCount -= 1; if (wave.spawned && wave.activeUnitCount == 0) { wave.cleared = true; waveClearedCount += 1; Debug.Log("wave" + (waveID + 1) + " is cleared"); ResourceManager.GainResource(wave.rscGain, PerkManager.GetRscWaveKilled()); GameControl.GainLife(wave.lifeGain + PerkManager.GetLifeWaveClearedModifier()); AbilityManager.GainEnergy(wave.energyGain + (int)PerkManager.GetEnergyWaveClearedModifier()); if (spawnLimit == _SpawnLimit.Infinite) { waveList.Remove(wave); } if (IsAllWaveCleared()) { GameControl.GameWon(); } else { if (spawnMode == _SpawnMode.Round && onEnableSpawnE != null) { onEnableSpawnE(); } } } if (!IsAllWaveCleared() && activeUnitCount == 0 && !spawning) { if (spawnMode == _SpawnMode.WaveCleared) { SpawnWaveFinite(); } } }
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(""); }
public bool _PurchasePerk(Perk perk) { if (perk.IsAvailable() == false) { return(false); } if (perk.type == _PerkType.GainLife) { GameControl.GainLife((int)Random.Range(perk.perkLevel[perk.level].value, perk.perkLevel[perk.level].valueAlt)); } else if (perk.type == _PerkType.LifeCap) { lifeCap += (int)perk.perkLevel[perk.level].value; GameControl.GainLife(0); } else if (perk.type == _PerkType.LifeRegen) { lifeRegen += perk.perkLevel[perk.level].value; } else if (perk.type == _PerkType.LifeWaveClearedBonus) { lifeWaveClearedBonus += (int)perk.perkLevel[perk.level].value; } else if (perk.type == _PerkType.RscCap) { int _value = (int)perk.perkLevel[perk.level].valueRsc; ResourceManager.GainResource(_value, 0, false); //dont pass multiplier and dont use multiplier } else if (perk.type == _PerkType.RscRegen) { rscRegen += perk.perkLevel[perk.level].valueRsc; } else if (perk.type == _PerkType.RscGain) { rscGain += perk.perkLevel[perk.level].valueRsc; } else if (perk.type == _PerkType.RscCreepKilledGain) { rscCreepKilledGain += perk.perkLevel[perk.level].valueRsc; } else if (perk.type == _PerkType.RscWaveClearedGain) { rscWaveClearedGain += perk.perkLevel[perk.level].valueRsc; } else if (perk.type == _PerkType.RscResourceTowerGain) { rscRscTowerGain += perk.perkLevel[perk.level].valueRsc; } 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.EnergyRegen) { energyRegen += perk.perkLevel[perk.level].value; } else if (perk.type == _PerkType.EnergyIncreaseCap) { energyCap += perk.perkLevel[perk.level].value; } else if (perk.type == _PerkType.EnergyCreepKilledBonus) { energyCreepKilledBonus += perk.perkLevel[perk.level].value; } else if (perk.type == _PerkType.EnergyWaveClearedBonus) { energyWaveClearedBonus += perk.perkLevel[perk.level].value; } return(true); }
public _Status Purchase(bool useRsc = true) { if (useRsc) { if (PerkManager.UseRscManagerForCost()) { RscManager.SpendRsc(GetPurchaseCostRsc()); } else { PerkManager.SpendRsc(GetPurchaseCost()); } } status = _Status.Purchased; if (PerkManager.InGameScene()) { if (type == _PerkType.NewTower) { TowerManager.AddBuildable(newTowerPID, replaceTowerPID); } if (type == _PerkType.NewAbility) { AbilityManager.AddAbility(newAbilityPID, replaceAbilityPID); } else if (type == _PerkType.ModifyTower) // || type==_PerkType.TowerAll){ { PerkManager.AddUnitPerkID(prefabID); SetupCallback(); } else if (type == _PerkType.ModifyAbility) // || type==_PerkType.AbilityAll){ { PerkManager.AddAbilityPerkID(prefabID); SetupCallback(); } else if (type == _PerkType.ModifyEffect) { PerkManager.AddEffectPerkID(prefabID); SetupCallback(); } else if (type == _PerkType.ModifyPerkCost) { PerkManager.AddPerkPerkID(prefabID); } else if (type == _PerkType.LifeCap) { GameControl.ModifyLifeCap((int)gain); } else if (type == _PerkType.GainLife) { GameControl.GainLife((int)gain); } else if (type == _PerkType.LifeRegen) { if (!IsMultiplier()) { GameControl.ModifyLifeRegen(gain); } else { GameControl.ModifyLifeRegenMultiplier(gain); } } else if (type == _PerkType.LifeGainWaveCleared) { if (!IsMultiplier()) { PerkManager.lifeGainOnWaveClearedMod += (int)Mathf.Round(gain); } else { PerkManager.lifeGainOnWaveClearedMul *= gain; } } else if (type == _PerkType.GainRsc) { RscManager.GainRsc(gainList); } else if (type == _PerkType.RscRegen) { if (!IsMultiplier()) { RscManager.ModifyRegenModRate(gainList); } else { RscManager.ModifyRegenMulRate(gainList); } } else if (type == _PerkType.RscGain) { if (!IsMultiplier()) { PerkManager.AddRscGainMod((int)gain); PerkManager.AddRscGainModList(gainList); } else { PerkManager.AddRscGainMul(gain); PerkManager.AddRscGainMulList(gainList); } } else if (type == _PerkType.RscGainCreepDestroyed) { if (!IsMultiplier()) { PerkManager.AddRscGainModCreepKilled((int)gain); PerkManager.AddRscGainModCreepKilledList(gainList); } else { PerkManager.AddRscGainMulCreepKilled(gain); PerkManager.AddRscGainMulCreepKilledList(gainList); } } else if (type == _PerkType.RscGainWaveCleared) { if (!IsMultiplier()) { PerkManager.AddRscGainModWaveCleared((int)gain); PerkManager.AddRscGainModWaveClearedList(gainList); } else { PerkManager.AddRscGainMulWaveCleared(gain); PerkManager.AddRscGainMulWaveClearedList(gainList); } } else if (type == _PerkType.RscGainResourceTower) { if (!IsMultiplier()) { PerkManager.AddRscGainModRscTower((int)gain); PerkManager.AddRscGainModRscTowerList(gainList); } else { PerkManager.AddRscGainMulRscTower(gain); PerkManager.AddRscGainMulRscTowerList(gainList); } } else if (type == _PerkType.AbilityRscCap) { if (!IsMultiplier()) { AbilityManager.MultiplyRscCap((int)Mathf.Round(gain)); } else { AbilityManager.ModifyRscCap((int)Mathf.Round(gain)); } } else if (type == _PerkType.AbilityRscRegen) { if (!IsMultiplier()) { AbilityManager.ModifyRscRegen(gain); } else { AbilityManager.ModifyRscRegenMultiplier(gain); } } else if (type == _PerkType.AbilityRscGainWaveCleared) { if (!IsMultiplier()) { PerkManager.abRscGainOnWaveClearedMod += (int)Mathf.Round(gain); } else { PerkManager.abRscGainOnWaveClearedMul *= gain; } } } return(status); }