public void AddTower() { Tower nt = null; switch (this.TowerType) { case TowerTypes.ARROW_TOWER: nt = new ArrowTower(this.towertextures[(int)TowerTypes.ARROW_TOWER - 1], this.bullettextures[(int)TowerTypes.ARROW_TOWER - 1], this.Tile); break; case TowerTypes.SPIKE_TOWER: nt = new SpikeTower(this.towertextures[(int)TowerTypes.SPIKE_TOWER - 1], this.bullettextures[(int)TowerTypes.SPIKE_TOWER - 1], this.Tile); break; case TowerTypes.SPEED_TOWER: nt = new SpeedTower(this.towertextures[(int)TowerTypes.SPEED_TOWER - 1], this.bullettextures[(int)TowerTypes.SPEED_TOWER - 1], this.Tile); break; case TowerTypes.CANNON_TOWER: nt = new CannonTower(this.towertextures[(int)TowerTypes.CANNON_TOWER - 1], this.bullettextures[(int)TowerTypes.CANNON_TOWER - 1], this.Tile); break; } if (nt != null && this.CanPlaceTower() && nt.Cost <= this.coins) { this.towers.Add(nt); this.coins -= nt.Cost; this.TowerType = TowerTypes.TOWER_NONE; } this.TowerType = TowerTypes.TOWER_NONE; }
public void AddTower(Tile tile) { Tower towertoadd = null; switch (newtowertype) { case "Arrow Tower": towertoadd = new ArrowTower(towerTexture[0], bulletTexture, new Vector2(tile.TileRec.X, tile.TileRec.Y)); break; case "Spike Tower": towertoadd = new SpikeTower(towerTexture[1], bulletTexture, new Vector2(tile.TileRec.X, tile.TileRec.Y)); break; case "Slow Tower": towertoadd = new SlowTower(towerTexture[2], bulletTexture, new Vector2(tile.TileRec.X, tile.TileRec.Y)); break; } if (IsCellclear(tile) && towertoadd.Cost <= money) { towers.Add(towertoadd); money -= towertoadd.Cost; newtowertype = string.Empty; tile.HasTower = true; } }
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; } } }