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 Build(bool isUpgrade = false) { if (!isUpgrade) { constructState = _ConstructState.Build; AudioManager.OnBuildStart(); AudioManager.PlaySound(soundBuilding); } else { constructState = _ConstructState.Upgrade; AudioManager.OnUpgradeStart(); AudioManager.PlaySound(soundUpgrading); } float buildDuration = GetBuildDuration(level + (isUpgrade ? 1 : 0)); constructDuration = buildDuration; constructRemained = buildDuration; effectBuilding.Spawn(GetPos(), Quaternion.identity); AnimPlayConstruct(); TDTK.OnTowerConstructing(this); }
public void Activate(Vector3 pos = default(Vector3)) { useCount += 1; currentCD = GetCooldown(); if (AbilityManager.UseRscManagerForCost()) { RscManager.SpendRsc(GetCostRsc()); } else { AbilityManager.SpendRsc(GetCost()); } effectOnActivate.Spawn(pos, Quaternion.identity); AudioManager.PlaySound(soundOnActivate); //activateCallback(); if (effectType != _EffectType.Default) { return; } AbilityManager.GetInstance().StartCoroutine(AbilityEffect(pos)); }
void Hit(Vector3 hitPos) { if (hit) { return; } hit = true; effectHit.Spawn(hitPos, Quaternion.identity); AudioManager.PlaySound(hitSound); if (attackInfo != null && tgtUnit != null) { tgtUnit.ApplyAttack(attackInfo); } ObjectPoolManager.Unspawn(thisObj); }
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(bool spawnEffDestroyed = true) { if (spawnEffDestroyed) { effectDestroyed.Spawn(GetPos(), Quaternion.identity); AudioManager.PlaySound(soundDestroyed); } float animDuration = AnimPlayDestroyed(); ClearAllEffect(); TowerManager.RemoveTower(this); if (buildPlatform != null) { buildPlatform.RemoveTower(nodeID); } Destroy(thisObj, animDuration); }
public void InitShoot(Unit tUnit) { tgtUnit = tUnit; tgtRadius = tgtUnit.GetRadius(); targetPos = tgtUnit.GetTargetPoint(); shot = true; hit = false; shootTime = Time.time; if (type == _Type.Projectile) { //estimate the time taken to reach the target (roughly) and calculate the effective elevation based on falloffRange float dist = Vector3.Distance(GetPos(), targetPos); eta = dist / speed; effElevation = elevation * Mathf.Clamp((dist - (falloffRange * .5f)) / falloffRange, 0, 1); } else if (type == _Type.Beam) { if (shootPoint != null) { thisT.parent = shootPoint; } } else if (type == _Type.Effect) { thisT.LookAt(targetPos); } /* * else if(type==_Type.Missile){ * float dist=Vector3.Distance(GetPos(), targetPos); * eta=dist/speed; * * if(shootPoint!=null) thisT.rotation=shootPoint.rotation; * * float rotX=maxDeviation;//Random.Range(0, maxDeviation); * float rotY=Random.value>.5f ? -maxDeviation : maxDeviation; //Random.Range(-maxDeviation, maxDeviation); * missileOffset=thisT.rotation*Quaternion.Euler(-rotX, rotY, 0)*Vector3.forward*dist*0.65f; * } */ effectShoot.Spawn(GetPos(), GetRot()); AudioManager.PlaySound(shootSound); }
private void ReachDestination() { effectDestination.Spawn(GetPos(), Quaternion.identity); AudioManager.PlaySound(soundDestination); GameControl.LostLife(lifeLostOnDestination); if (path.loop) { wpIdx = 0; subWpIdx = 0; SpawnManager.ClearCleanWaveFlag(waveIdx); ResetPathOffset(); if (path.warpToStart) { thisT.position = path.GetWP(0)[0] + pathOffsetV; if (faceTravelingDir) { thisT.rotation = Quaternion.LookRotation(path.GetWP(1)[0] + pathOffsetV - GetPos()); } } } else { path.OnCreepExit(this); path = null; AnimPlayMove(0); float animDuration = AnimPlayDestination(); SpawnManager.CreepDestroyed(this, true); ObjectPoolManager.Unspawn(thisObj, animDuration); } //Destroy(thisObj); }
public void Init(int waveIndex, Path p, int wpIndex = -1, int subWpIndex = -1, bool resetPos = true, bool rr = false, List <Path> prevP = null, List <Vector3> sPath = null) { waveIdx = waveIndex; wpIdx = wpIndex >= 0 ? wpIndex : 0; subWpIdx = subWpIndex >= 0 ? subWpIndex : 0; reverse = rr; prevPathList = prevP != null ? prevP : new List <Path>(); path = p; path.OnCreepEnter(this); if (sPath == null) { subPath = path.GetWP(wpIdx, EnableBypass()); } else { subPath = sPath; } if (pathOffsetMode == _PathOffsetMode.None) { pathOffsetV = Vector3.zero; pathOffset = 0; } else if (pathOffsetMode == _PathOffsetMode.Simple) { float x = Random.Range(-path.dynamicOffset, path.dynamicOffset); float z = Random.Range(-path.dynamicOffset, path.dynamicOffset); pathOffsetV = new Vector3(x, 0, z); } else if (pathOffsetMode == _PathOffsetMode.AlignToPath) { pathOffset = Random.Range(-path.dynamicOffset, path.dynamicOffset); lastTargetPos = subPath[subWpIdx]; ResetPathOffset(); } if (resetPos) { thisT.position = path.GetWP(0)[0] + pathOffsetV; if (faceTravelingDir) { thisT.rotation = Quaternion.LookRotation(path.GetWP(1)[0] + pathOffsetV - GetPos()); } } lastTargetPos = thisT.position; hp = GetFullHP(); sh = GetFullSH(); cooldown = GetCooldown(); effectSpawn.Spawn(GetPos(), Quaternion.identity); AudioManager.PlaySound(soundSpawn); AnimReset(); AnimPlaySpawn(); //UIHPOverlay.AddUnit(this); TDTK.OnNewUnit(this); }
IEnumerator AbilityEffect(Vector3 pos) { if (effectDelay > 0) { yield return(new WaitForSeconds(effectDelay)); } List <Unit> tgtList = new List <Unit>(); if (targetType == _TargetType.Hostile) { if (!requireTargetSelection) { tgtList = SpawnManager.GetActiveUnitList(); } else { tgtList = SpawnManager.GetUnitsWithinRange(pos, stats.aoeRange); } } else if (targetType == _TargetType.Friendly) { if (!requireTargetSelection) { tgtList = TowerManager.GetActiveUnitList(); } else { tgtList = TowerManager.GetUnitsWithinRange(pos, stats.aoeRange); } } else { if (!requireTargetSelection) { tgtList = SpawnManager.GetActiveUnitList(); List <Unit> towerList = TowerManager.GetActiveUnitList(); for (int i = 0; i < towerList.Count; i++) { tgtList.Add(towerList[i]); } } else { tgtList = SpawnManager.GetUnitsWithinRange(pos, stats.aoeRange); List <Unit> towerList = TowerManager.GetUnitsWithinRange(pos, stats.aoeRange); for (int i = 0; i < towerList.Count; i++) { tgtList.Add(towerList[i]); } } } for (int i = 0; i < tgtList.Count; i++) { tgtList[i].ApplyAttack(new AttackInfo(this, tgtList[i], false)); effectOnTarget.Spawn(tgtList[i].GetTargetPoint(), Quaternion.identity); } yield return(null); }