public void OnHoverBuildButton(GameObject butObj) { Debug.Log(butObj); if (!ValidForInteraction()) { return; } int idx = UI.GetItemIndex(butObj, buildButtons); if (UIControl.UseDragNDropMode()) { UITooltip.Show(buildableList[idx], UI.GetCorner(buildButtons[idx].rectT, 1), 0, new Vector3(0, .25f, 0)); } else { if (UIControl.UsePieMenuForBuild()) { UITooltip.Show(sInfo.buildableList[idx]); } else { UITooltip.Show(sInfo.buildableList[idx], UI.GetCorner(buildButtons[idx].rectT, 1), 0, new Vector3(0, .25f, 0)); } } if (UIControl.UsePointNBuildMode()) { TowerManager.ShowSampleTower(sInfo.buildableList[idx].prefabID, sInfo); } }
public void ForceAltPath() { if (flying && AStar.EnableFlyingBypass()) { return; } if (!path.GetWpSec(wpIdx).isPlatform) { return; } if (altPath.Count <= 0) { altPath = path.GetWpSec(wpIdx).GetPathForUnit(this, !reverse); } if (altPath.Count <= 0) { return; } subPath = new List <Vector3>(altPath); subWpIdx = subWpIdx > 1 ? 1 : 0; if (subWpIdx >= 1 && subPath.Count > 1) { if (Vector3.Distance(GetPos(), subPath[1]) > TowerManager.GetGridSize()) { subWpIdx = 0; } } altPath = new List <Vector3>(); }
void UpdateBuildableStatus() { for (int i = 0; i < buildButtons.Count; i++) { buildButtons[i].button.interactable = TowerManager.CheckTowerCounterLimit(buildableList[i].prefabID, buildableList[i].limitInScene); } }
void Update() { if (TowerManager.InDragNDropPhase()) { if (TowerManager.GetDragNDropTower() != null) { Vector3 towerPos = TowerManager.GetDragNDropTower().GetPos(); Vector3 screenPos = Camera.main.WorldToScreenPoint(towerPos) * UI.GetScaleFactor(); screenPos.z = 0; screenPos.y += 50; dndLabelRectT.localPosition = screenPos; if (TowerManager.DnDHasValidPos()) { dndLabel.text = ""; } else { dndLabel.gameObject.SetActive(true); dndLabel.text = "Invalid Pos"; } } else { dndLabel.text = ""; } } else { if (dndLabel.gameObject.activeInHierarchy) { dndLabel.gameObject.SetActive(false); } } }
private void OnCursorDown() { SelectInfo sInfo = TowerManager.GetSelectInfo(Input.mousePosition); bool select = false; bool build = false; if (sInfo.HasValidPoint()) { if (sInfo.GetTower() != null) { select = true; SelectControl.SelectUnit(sInfo.GetTower()); UITowerSelect.Show(sInfo.GetTower()); } else if (buildMode == _BuildMode.PointNBuild && sInfo.AvailableForBuild()) { build = true; UIBuildButton.Show(sInfo); SelectControl.SelectNode(sInfo.platform, sInfo.nodeID); } } if (buildMode == _BuildMode.PointNBuild && !build) { SelectControl.ClearNode(); UIBuildButton.Hide(); } if (!select) { SelectControl.ClearUnit(); UITowerSelect.Hide(); } }
// Use this for initialization void Awake() { instance = this; List <UnitTower> dbList = TowerDB.GetList(); for (int i = 0; i < dbList.Count; i++) { if (!unavailablePrefabIDList.Contains(dbList[i].prefabID) && !dbList[i].hideInInspector) { buildableList.Add(dbList[i]); } } for (int i = 0; i < buildableList.Count; i++) { GameObject obj = (GameObject)Instantiate(buildableList[i].gameObject); sampleList.Add(obj.GetComponent <UnitTower>()); sampleList[sampleList.Count - 1].isPreview = true; sampleList[sampleList.Count - 1].gameObject.layer = TDTK.GetLayerTerrain(); sampleList[sampleList.Count - 1].transform.parent = transform; obj.SetActive(false); } //Debug.Log("remove this"); //for(int i=0; i<buildableList.Count; i++) buildableList[i].prefabID=i; }
public Vector3 GetPos() { if (TowerManager.UseFreeFormMode()) { return(buildPoint); } return(HasValidPoint() ? platform.GetNode(nodeID).pos : buildPoint); }
public bool AvailableForBuild() { if (TowerManager.UseFreeFormMode()) { return(!invalidPoint); } return(!platform.GetNode(nodeID).IsBlockedForTower() && GetTower() == null && !platform.GetNode(nodeID).IsOccupied()); }
void Start() { float gridSize = TowerManager.GetGridSize(); nIndicatorT = nIndicator.transform; nIndicatorT.localScale = new Vector3(gridSize, gridSize, gridSize); _ClearAll(); }
public Quaternion GetRot() { if (TowerManager.UseFreeFormMode()) { return(Quaternion.identity); } Quaternion rot = Quaternion.Euler(0, platform.transform.rotation.eulerAngles.y, 0); return(rot); }
public void OnBuildButton(GameObject butObj, int pointerID = -1) { if (!ValidForInteraction()) { return; } int idx = UI.GetItemIndex(butObj, buildButtons); if (UIControl.UsePointNBuildMode() && UIControl.InTouchMode()) { if (touchModeButtonIdx != idx) { if (touchModeButtonIdx >= 0) { ClearTouchModeSelect(); } touchModeButtonIdx = idx; buildButtons[touchModeButtonIdx].imgHighlight.gameObject.SetActive(true); OnHoverBuildButton(butObj); return; } ClearTouchModeSelect(); } if (UIControl.UsePointNBuildMode()) { if (!CheckCost(sInfo.buildableList[idx].GetCost())) { return; } TowerManager.BuildTower(sInfo.buildableList[idx], sInfo.platform, sInfo.nodeID); SelectControl.ClearNode(); OnExitBuildButton(null); Hide(); TowerManager.HideSampleTower(); } if (UIControl.UseDragNDropMode()) { if (!CheckCost(buildableList[idx].GetCost())) { return; } SelectControl.ClearUnit(); UITowerSelect.Hide(); TowerManager.CreateDragNDropTower(buildableList[idx]); } }
public static void Init() { if (instance == null) { instance = (TowerManager)FindObjectOfType(typeof(TowerManager)); } if (instance != null) { instance.InitPlatform(); } }
public void ClearTouchModeSelect() { if (touchModeButtonIdx < 0) { return; } TowerManager.HideSampleTower(); buildButtons[touchModeButtonIdx].imgHighlight.gameObject.SetActive(false); touchModeButtonIdx = -1; OnExitBuildButton(null); }
public void OnExitBuildButton(GameObject butObj) { if (!ValidForInteraction()) { return; } UITooltip.Hide(); if (UIControl.UsePointNBuildMode()) { TowerManager.HideSampleTower(); } }
// Use this for initialization void Start() { if (!isGameScene) { return; } if (TowerManager.UseFreeFormMode() && buildMode == _BuildMode.PointNBuild) { Debug.LogWarning("PointNBuild mode is not supported when using FreeFormMode in TowerManager, changed to DragNDrop instead"); buildMode = _BuildMode.DragNDrop; } }
//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; } }
void Awake() { instance = this; ObjectPoolManager.Init(); TowerManager.Init(); Path.Init(); SpawnManager.Init(); if (highestLevelID < levelID) { highestLevelID = levelID; } }
public bool CanBuildTower(int towerPID) { if (TowerManager.UseFreeFormMode()) { return(true); } for (int i = 0; i < buildableList.Count; i++) { if (buildableList[i].prefabID == towerPID) { return(true); } } return(false); }
//~ void OnGUI(){ //~ GUI.Label(new Rect(10, Screen.height/2, 130, 35), "ability:"); //~ if(GUI.Button(new Rect(80, Screen.height/2, 130, 35), ""+targetMode)){ //~ if(targetMode==_TargetMode.DragNDrop) targetMode=_TargetMode.SelectNDeploy; //~ else if(targetMode==_TargetMode.SelectNDeploy) targetMode=_TargetMode.DragNDrop; //~ } //~ GUI.Label(new Rect(10, Screen.height/2+40, 130, 35), "build:"); //~ if(GUI.Button(new Rect(80, Screen.height/2+40, 130, 35), ""+buildMode)){ //~ if(buildMode==_BuildMode.DragNDrop) buildMode=_BuildMode.PointNBuild; //~ else if(buildMode==_BuildMode.PointNBuild) buildMode=_BuildMode.PointNBuild; //~ } //~ } void Update() { if (!isGameScene) { return; } if (TowerManager.InDragNDropPhase()) { //for mobile, to prevent getting stuck in DnD phase if user click but not drag the button //if(Input.touchCount==0) TowerManager.ExitDragNDropPhase(); return; } //for mobile, to prevent getting stuck in target select phase if user click but not drag the button //if(AbilityManager.InTargetSelectionMode()){ // if(Input.touchCount==0) AbilityManager.ClearSelect(); //} int pointerID = Input.touchCount == 0 ? -1 : 0; if (Input.GetMouseButtonDown(0) && !UI.IsCursorOnUI(pointerID)) { if (!InTargetSelectionMode()) { OnCursorDown(); } } if (Input.GetMouseButtonUp(0) && !wasCursorOnUI) { if (AbilityManager.InTargetSelectionMode()) { OnCursorDownAbilityTargetMode(); } else if (pendingAbilityIdx >= 0) { OnCursorDownAbilityTargetMode(pendingAbilityIdx); pendingAbilityIdx = -1; } } if (Input.GetMouseButtonDown(1)) { UIAbilityButton.ClearSelect(); //ClearSelectedAbility(); } wasCursorOnUI = UI.IsCursorOnUI(pointerID); //to be used for next frame }
public void Upgrade(int upgradeIdx = 0) { if (GetUpgradeType() == 0) { RscManager.SpendRsc(GetUpgradeCost(0)); Build(true); } else { TowerManager.RemoveTower(this); if (buildPlatform != null) { buildPlatform.RemoveTower(nodeID); } TowerManager.BuildTower(upgradeTowerList[upgradeIdx], buildPlatform, nodeID); Destroy(thisObj); } }
public override void Start() { base.Start(); buildableList = TowerManager.GetBuildableList(); for (int i = 0; i < buildableList.Count; i++) { AddBuildButton(i, buildableList[i].icon, buildableList[i].GetCost()[0].ToString("f0")); } if (UIControl.UsePointNBuildMode()) { thisObj.SetActive(false); } else if (UIControl.UseDragNDropMode()) { UpdateBuildableStatus(); canvasGroup.alpha = 1; thisObj.SetActive(true); } }
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 Init() { if (!isPreview) { if (instanceID < 0) { TowerManager.PreBuildTower(this); } else { Build(); } } if (IsResource()) { cooldown = GetCooldown(); } }
public SelectInfo(BuildPlatform p, int ID) { platform = p; nodeID = ID; if (AvailableForBuild()) { buildableList = new List <UnitTower>(TowerManager.GetBuildableList()); //for limiting amount of tower in the scene according to prefabID for (int i = 0; i < buildableList.Count; i++) { if (TowerManager.CheckTowerCounterLimit(buildableList[i].prefabID, buildableList[i].limitInScene)) { continue; } buildableList.RemoveAt(i); i -= 1; } for (int i = 0; i < platform.unavailablePrefabIDList.Count; i++) { for (int n = 0; n < buildableList.Count; n++) { if (buildableList[n].prefabID == platform.unavailablePrefabIDList[i]) { buildableList.RemoveAt(n); break; } } } if (PathBlocked()) //can only build mine { for (int i = 0; i < buildableList.Count; i++) { if (!buildableList[i].IsMine()) { buildableList.RemoveAt(i); i -= 1; } } } } }
public void Test() { if (m_TowerManager.dndTower != null) { if (RscManager.HasSufficientRsc(m_TowerManager.dndTower.GetCost())) { RscManager.SpendRsc(m_TowerManager.dndTower.GetCost()); Debug.Log("buy"); m_TSC = m_TowerManager.dndTower.gameObject.GetComponent <TowerSoliderController>(); SelectControl.ClearUnit(); TowerManager.AddTower(m_TowerManager.dndTower, TowerManager.CreatePlatformForTower(m_TowerManager.dndTower, TowerManager.GetGridSize()), 0); m_TowerManager.dndTower.Build(); m_TowerManager.dndTower = null; //TowerManager.dndCooldown=Time.time; if (m_TSC != null) { m_TSC.ShowSolider(); } } else { GameControl.InvalidAction("Insufficient Resources"); m_TowerManager._ExitDragNDropPhase(); } } }
public static void NewTower(UnitTower tower) { if (tower.IsSupport()) { List <UnitTower> allTowerList = TowerManager.GetActiveTowerList(); for (int i = 0; i < allTowerList.Count; i++) { if (allTowerList[i].IsSupport()) { continue; } if (allTowerList[i] == tower) { continue; } float dist = Vector3.Distance(allTowerList[i].GetPos(), tower.GetPos()); if (dist < tower.GetAttackRange()) { tower.SupportBuffTower(allTowerList[i]); } } } else { List <UnitTower> supportTowerList = TowerManager.GetSupportTowerList(); for (int i = 0; i < supportTowerList.Count; i++) { float dist = Vector3.Distance(supportTowerList[i].GetPos(), tower.GetPos()); if (dist < supportTowerList[i].GetAttackRange()) { supportTowerList[i].SupportBuffTower(tower); } } } }
public static NodeTD[] GenerateNode(BuildPlatform platform, float gridSize = 1, float heightOffset = 0) { if (refT == null) { refT = new GameObject("RefT").transform; refT.parent = TowerManager.GetInstance().transform; } Transform platformT = platform.transform; float scaleX = platformT.localScale.x; float scaleZ = platformT.localScale.y; int countX = (int)(scaleX / gridSize); int countZ = (int)(scaleZ / gridSize); float x = -scaleX / 2 / scaleX; float z = -scaleZ / 2 / scaleZ; Vector3 point = platformT.TransformPoint(new Vector3(x, z, 0)); refT.position = point; refT.rotation = platformT.rotation * Quaternion.Euler(-90, 0, 0); refT.position = refT.TransformPoint(new Vector3(gridSize / 2, heightOffset, gridSize / 2)); NodeTD[] nodeGraph = new NodeTD[countZ * countX]; int counter = 0; for (int i = 0; i < countZ; i++) { for (int j = 0; j < countX; j++) { nodeGraph[counter] = new NodeTD(refT.position, counter); counter += 1; refT.position = refT.TransformPoint(new Vector3(gridSize, 0, 0)); } refT.position = refT.TransformPoint(new Vector3(-(countX) * gridSize, 0, gridSize)); } refT.position = Vector3.zero; refT.rotation = Quaternion.identity; LayerMask mask = 1 << TDTK.GetLayerPlatform() | 1 << TDTK.GetLayerTower() | 1 << TDTK.GetLayerTerrain() | 1 << TDTK.GetLayerNoBuild(); LayerMask maskTowerBlock = 1 << TDTK.GetLayerNoBuild(); counter = 0; foreach (NodeTD cNode in nodeGraph) { //check if there's anything within the point Collider[] cols = Physics.OverlapSphere(cNode.pos, gridSize * 0.45f, ~mask); if (cols.Length > 0) { cNode.SetWalkable(false); counter += 1; } cols = Physics.OverlapSphere(cNode.pos, gridSize * 0.45f, maskTowerBlock); if (cols.Length > 0) { cNode.SetBlockedForTower(true); } } float neighbourDistance = 0; float neighbourRange = gridSize * 1.1f; //if(instance.connectDiagonalNeighbour) neighbourRange=gridSize*1.5f; //else neighbourRange=gridSize*1.1f; counter = 0; //assign the neighouring node for each node in the grid foreach (NodeTD currentNode in nodeGraph) { //only if that node is walkable if (currentNode.IsWalkable()) { //create an empty array List <NodeTD> neighbourNodeList = new List <NodeTD>(); List <float> neighbourCostList = new List <float>(); NodeTD[] neighbour = new NodeTD[8]; int id = currentNode.ID; if (id > countX - 1 && id < countX * countZ - countX) { //print("middle rows"); if (id != countX) { neighbour[0] = nodeGraph[id - countX - 1]; } neighbour[1] = nodeGraph[id - countX]; neighbour[2] = nodeGraph[id - countX + 1]; neighbour[3] = nodeGraph[id - 1]; neighbour[4] = nodeGraph[id + 1]; neighbour[5] = nodeGraph[id + countX - 1]; neighbour[6] = nodeGraph[id + countX]; if (id != countX * countZ - countX - 1) { neighbour[7] = nodeGraph[id + countX + 1]; } } else if (id <= countX - 1) { //print("first row"); if (id != 0) { neighbour[0] = nodeGraph[id - 1]; } if (nodeGraph.Length > id + 1) { neighbour[1] = nodeGraph[id + 1]; } if (countZ > 0) { if (nodeGraph.Length > id + countX - 1) { neighbour[2] = nodeGraph[id + countX - 1]; } if (nodeGraph.Length > id + countX) { neighbour[3] = nodeGraph[id + countX]; } if (nodeGraph.Length > id + countX + 1) { neighbour[4] = nodeGraph[id + countX + 1]; } } } else if (id >= countX * countZ - countX) { //print("last row"); neighbour[0] = nodeGraph[id - 1]; if (id != countX * countZ - 1) { neighbour[1] = nodeGraph[id + 1]; } if (id != countX * (countZ - 1)) { neighbour[2] = nodeGraph[id - countX - 1]; } neighbour[3] = nodeGraph[id - countX]; neighbour[4] = nodeGraph[id - countX + 1]; } //scan through all the node in the grid foreach (NodeTD node in neighbour) { //if this the node is not currentNode if (node != null && node.IsWalkable()) { //if this node is within neighbour node range neighbourDistance = GetHorizontalDistance(currentNode.pos, node.pos); if (neighbourDistance < neighbourRange) { //if nothing's in the way between these two if (!Physics.Linecast(currentNode.pos, node.pos, ~mask)) { //if the slop is not too steep //if(Mathf.Abs(GetSlope(currentNode.pos, node.pos))<=maxSlope){ //add to list //if(!node.walkable) Debug.Log("error"); neighbourNodeList.Add(node); neighbourCostList.Add(neighbourDistance); //}//else print("too steep"); } //else print("something's in the way"); } //else print("out of range "+neighbourDistance); } //else print("unwalkable"); } //set the list as the node neighbours array currentNode.SetNeighbour(neighbourNodeList, neighbourCostList); //if(neighbourNodeList.Count==0) //Debug.Log("no heighbour. node number "+counter+" "+neighbourNodeList.Count); } counter += 1; } return(nodeGraph); }
public static void NewBuildable(UnitTower tower) { instance.AddBuildButton(instance.buildButtons.Count, tower.icon, tower.GetCost()[0].ToString("f0")); instance.buildableList = TowerManager.GetBuildableList(); }
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); }
//fixed update for resource, aoe and mine, check '#region support tower' for support void CreepFunction() { if (!GameControl.HasGameStarted()) { return; } if (IsStunned()) { return; } if (cooldown > 0) { return; } if (IsAOE()) { List <Unit> tgtList = TowerManager.GetUnitsWithinRange(this, GetAttackRange()); if (tgtList.Count > 0) { cooldown = GetCooldown(); for (int i = 0; i < tgtList.Count; i++) { tgtList[i].ApplyAttack(new AttackInfo(this, tgtList[i])); } } else { cooldown = 0.1f; } } if (IsSupport()) { float range = GetAttackRange(); for (int i = 0; i < supportTgtList.Count; i++) { if (Vector3.Distance(GetPos(), supportTgtList[i].GetPos()) <= range) { continue; } ClearBuffOnTarget(supportTgtList[i]); supportTgtList.RemoveAt(i); i -= 1; } List <Unit> tgtList = SpawnManager.GetUnitsWithinRange(this, range); for (int i = 0; i < tgtList.Count; i++) { if (tgtList[i] == GetUnit() || tgtList[i].IsSupport()) { continue; } if (supportTgtList.Contains(tgtList[i].GetCreep())) { continue; } Effect effect = GetEffectOnHit(); //.Clone(); effect.duration = Mathf.Infinity; tgtList[i].ApplyEffect(effect); tgtList[i].GetCreep().supportSrcList.Add(this); supportTgtList.Add(tgtList[i].GetCreep()); } cooldown = 0.1f; } if (IsSpawner() && spawnerCount > 0 && spawnerPrefab != null) { float oHP = spawnerOverride.GetHP(this); float oSH = spawnerOverride.GetSH(this); float oSpd = spawnerOverride.GetSpd(this); int oExp = spawnerOverride.GetExp(this); List <int> oRsc = spawnerOverride.GetRsc(this, rscGainOnDestroyed); for (int i = 0; i < spawnerCount; i++) { SpawnSubCreep(spawnerPrefab, oHP, oSH, oSpd, oExp, oRsc); } cooldown = GetCooldown(); } }