public static void SpawnTowerInGame(this GameLevel level, TowerType type, Vector2D gridPosition, float rotation = 0.0f) { var properties = ContentLoader.Load <TowerPropertiesXml>(Xml.TowerProperties.ToString()); if (IsCreepInTile(gridPosition) || Player.Current.Gold < properties.Get(type).Cost) { return; } var index = level.GetIndexForMapData(gridPosition); if (level.MapData[index] != LevelTileType.Placeable) { return; } level.SetUnreacheableTile(gridPosition, type); if (!level.IsPossibleAddTower(gridPosition)) { return; } var towerPosInWorldSpace = level.GetWorldCoordinates(gridPosition); var tower = new Tower(type, towerPosInWorldSpace, rotation); tower.RenderModel(); level.EarnGold(-properties.Get(type).Cost); }