private void CreateTower() { Rectangle tempRect = new Rectangle(tileX, tileY, Engine.TileWidth, Engine.TileHeight); if (!towerManager.IsOnTower(tileX, tileY)) { if (tower is ArrowTower) { ArrowTower arrow = new ArrowTower(arrowTower, new Vector2(tileX, tileY), bullet, 1, soundBank); towerManager.AddTower(arrow); money -= tower.Cost; tower = null; } else if (tower is SpikeTower) { SpikeTower spike = new SpikeTower(spikeTower, new Vector2(tileX, tileY), bullet, 1, soundBank); towerManager.AddTower(spike); //money -= tower.Cost; money -= 1; tower = null; } else if (tower is BombTower) { BombTower bomb = new BombTower(bombTower, new Vector2(tileX, tileY), bullet, 1, soundBank); towerManager.AddTower(bomb); //money -= tower.Cost; money -= 1; tower = null; } else if (tower is OneandOneTower) { OneandOneTower oneandone = new OneandOneTower(bombTower, new Vector2(tileX, tileY), bullet, 1, soundBank); towerManager.AddTower(oneandone); money -= tower.Cost; tower = null; } if (tower is ofLoveTower) { ofLoveTower love = new ofLoveTower(ofLoveTower, new Vector2(tileX, tileY), bullet, 1, soundBank); towerManager.AddTower(love); money -= tower.Cost; soundBank.PlayCue("liebe2"); tower = null; } } }
public void Update(GameTime gameTime, List <Enemy> enemies) { foreach (Tower tower in towers) { tower.Update(gameTime); if (tower is ArrowTower) { if (tower.Target == null || tower.Target.IsDead) { tower.Target = tower.GetClosestEnemy(enemies); } if (tower.Target != null) { tower.Attack(tower.Target); if (tower.Target.AtEnd) { tower.Target = null; } } } else if (tower is SpikeTower) { SpikeTower spike = tower as SpikeTower; spike.Targets.Clear(); spike.Targets.AddRange(spike.GetEnemies(enemies)); spike.Attack(); } else if (tower is OneandOneTower) { OneandOneTower oneandone = tower as OneandOneTower; oneandone.UpdateSplashDamage(enemies, gameTime); if (tower.Target == null || tower.Target.IsDead) { tower.Target = tower.GetClosestEnemy(enemies); } if (tower.Target != null) { tower.Attack(tower.Target); if (tower.Target.AtEnd) { tower.Target = null; } } } else if (tower is ofLoveTower) { break; /* * if (tower.Target == null || tower.Target.IsDead) * tower.Target = tower.GetClosestEnemy(enemies); * if (tower.Target != null) * { * tower.Attack(tower.Target); * if (tower.Target.AtEnd) * tower.Target = null; * }*/ } else { BombTower bomb = tower as BombTower; bomb.UpdateSplashDamage(enemies, gameTime); if (tower.Target == null || tower.Target.IsDead) { tower.Target = tower.GetClosestEnemy(enemies); } if (tower.Target != null) { tower.Attack(tower.Target); if (tower.Target.AtEnd) { tower.Target = null; } } } } }