// returns true when tower was built successfully public static bool BuildTower(Tower tower, int x, int y) { bool succesBuild = false; if (!Presentation.Background.IsOnCity(tower)) { if (!Presentation.Background.IsOnWalkPath(tower)) { if (!IsAnyTowerInRange(x, y)) { int cost = tower.Cost, gold = Player.Gold; if (gold >= cost) { tower.Move(x, y); tower.TowerState = TowerState.Bought; tower.AttackState = AttackState.Shooting; Player.Gold -= cost; Tower.PlacingTower = false; succesBuild = true; Console.WriteLine("Building tower"); } else { Console.WriteLine("Error: Player does not have enough gold"); } } else { Console.WriteLine("Error: Cannot place tower, another tower in range"); } } else { Console.WriteLine("Error: Cannot place towers on path"); } } else { Console.WriteLine("Error: Tower cannot be placed on city"); } return succesBuild; }