public void Update() { //update cooldown cooldown = Math.Max(0, cooldown - 1); if (tower is AttackTower) { Collider ac = (tower as AttackTower).GetAttackCollider(); if (ac != null) { if (follow != null) { float angle = Vector3.SignedAngle(Vector3.forward, new Vector3(ac.transform.position.x - follow.transform.position.x, 0f, ac.transform.position.z - follow.transform.position.z), Vector3.up); follow.transform.eulerAngles = new Vector3(-90, 0, angle); } } } //then act if (cooldown <= 0) { int attackSpeed = (int)Math.Round(tower.GetAttackSpeed() * GetTotalUpgrades(Upgrade.UpgradeType.AttackSpeed)); cooldown = (int)Math.Round(120 / ((30 + attackSpeed / 3) * 0.01)); tower.Act(this); } }
public void Update() { //update cooldown cooldown = Math.Max(0, cooldown - 1); //then act if (cooldown <= 0) { tower.Act(this); cooldown = (int)Math.Round(120 / ((30 + tower.GetAttackSpeed() / 3) * 0.01)); } //check for death if (health <= 0) { tile.Hold(null); tile.SetUsed(false); } }