public void SpawnEnemy(EnemyFinal EnemyToSpawn) { Temp = Instantiate(EnemyToSpawn, new Vector3(spawnCoordinate_x, spawnCoordinate_y, 0), Quaternion.identity); if (round > 5) //Make the enemies faster after round 5 { Temp.enemySpeed = Temp.enemySpeed * 1.15f; } enemyList.Add(Temp); }
public int SearchEnemy(EnemyFinal Enemy) { for (int i = 0; i < enemyList.Count; i++) { if (Enemy == enemyList[i]) { return(i); } } return(-1); }
public void SearchDeadEnemy() { for (int i = 0; i < enemyList.Count; i++) { if (enemyList[i].dead) { EnemyFinal Temp = enemyList[i]; // RemoveFromList(Temp); enemyList.Remove(Temp); } if (enemyList.Count == 0) { nextRoundStart = true; round++; } } }
public void InstantiateProjectile(List <EnemyFinal> TargetList, DamageTower currTower) { if (TargetList.Count > 0) { currTarget = TargetList[0]; } parentTower = currTower; if (currTarget != null) { shotDirection = currTarget.transform.position - parentTower.towerPosition; shotDirection.Normalize(); //shotDirection = shotDirection / 10f; startPosition = parentTower.transform.position + shotDirection / 10f; this.transform.position = startPosition; projectileSpeed = 2f + parentTower.fireRate / 50f; } else { Destroy(this.gameObject); } }
public void HitTarget() { if (currTarget != null) { shotDirection = currTarget.transform.position - this.transform.position; if ((this.transform.position - currTarget.transform.position).magnitude > 0.15f) { this.transform.Translate(shotDirection.normalized * Time.deltaTime * projectileSpeed, Space.World); } else if ((this.transform.position - currTarget.transform.position).magnitude < 0.15f) { enemyReference = currTarget; enemyReference.health = enemyReference.health - damage; hit = true; parentTower.UpdateShot(false); Destroy(this.gameObject); } } else { parentTower.UpdateShot(false); Destroy(this.gameObject); } }