public static void EndGame() { if (instance.gameState == _GameState.Over) { return; } instance.playerWon = instance.life > 0; instance.gameState = _GameState.Over; if (instance.playerWon) { RscManager.GainRsc(instance.rscGainOnWin); PerkManager.GainRsc(instance.perkRscGainOnWin); RscManager.CachedRsc(); //for rsc to be carry forth to next level PerkManager.CachedProgress(); //for perk progress to be carry forth to next level AudioManager.OnPlayerWon(); } else { AudioManager.OnPlayerLost(); } Debug.Log("Game Over " + instance.playerWon + " " + instance.gameState); TDTK.OnGameOver(instance.playerWon); }
void Construction() { if (constructRemained < 0) { return; } constructRemained -= Time.fixedDeltaTime; if (constructRemained <= 0) { if (constructState == _ConstructState.Sell) { RscManager.GainRsc(GetSellValue()); effectSold.Spawn(GetPos(), Quaternion.identity); Destroyed(false); } if (constructState == _ConstructState.Upgrade) { effectBuilt.Spawn(GetPos(), Quaternion.identity); level += 1; AudioManager.OnUpgradeComplete(); AudioManager.PlaySound(soundBuilt); } if (constructState == _ConstructState.Build) { effectBuilt.Spawn(GetPos(), Quaternion.identity); AudioManager.OnBuildComplete(); AudioManager.PlaySound(soundUpgraded); } } }
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); }
//fixed update for resource, aoe and mine, check '#region support tower' for support void TowerFunction() { if (!GameControl.HasGameStarted()) { return; } if (InConstruction() || IsStunned() || IsDestroyed()) { return; } //if(GameControl.HasGameStarted() && !GameControl.IsGamePaused()) cooldown-=Time.fixedDeltaTime; if (cooldown > 0) { return; } if (IsResource()) // && cooldownRsc<0){ { RscManager.GainRsc(GetRscGain(), RscManager._GainType.RscTower); cooldown = GetCooldown(); //cooldownRsc=GetCooldown(); } if (IsAOE()) // && cooldownAOE<0){ { List <Unit> tgtList = SpawnManager.GetUnitsWithinRange(this, GetAttackRange(), GetTargetGroup()); if (tgtList.Count > 0) { cooldown = GetCooldown(); //cooldownAOE=GetCooldown(); for (int i = 0; i < tgtList.Count; i++) { tgtList[i].ApplyAttack(new AttackInfo(this, tgtList[i])); } } else { cooldown = 0.1f; //cooldownAOE=0.1f; } } if (IsMine()) // && cooldownAttack<0){ { List <Unit> tgtList = SpawnManager.GetUnitsWithinRange(this, TowerManager.GetGridSize() * .25f, GetTargetGroup()); if (tgtList.Count > 0) { tgtList[0].ApplyAttack(new AttackInfo(this, tgtList[0])); Destroyed(); } cooldown = 0.1f; //cooldownAttack=0.1f; } }
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 _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); }