public Vik AddPlayer(string id, string nickName, string villageName, Map map) { Vik vik = new Vik(id, nickName, villageName); vik.map = map; //start with a building. TileType theLongHouse = (from t in TileTypes where t.kind == TileType.Kind.The_Long_House select t).First(); /// Fint it on the map int theLongHouseTileid = -1; foreach (var l in vik.map) { IEnumerable<PlayerTile> playerTiles = (from t in l where t.TileType.kind == TileType.Kind.The_Long_House select t); if (playerTiles.Count()==1) { theLongHouseTileid = playerTiles.First().Id; break; } } vik.buildings.Add(new PlayerTile(theLongHouse, theLongHouseTileid)); Viks.Add(vik); return vik; }
public void BuildOnBuildings(Vik vik) { var uncomplete = (from b in vik.buildings where b.TicksLeftToCompleteion > 0 select b); foreach (PlayerTile building in uncomplete) { building.TicksLeftToCompleteion--; if (building.TicksLeftToCompleteion == 0) { // BUILDING COMPLETE foreach (List<PlayerTile> tiles in vik.map) { foreach (PlayerTile playerTile in tiles) { if (playerTile.Id == building.Id) { playerTile.TileType = (from t in TileTypes where t.kind == building.TileType.kind select t).First(); Debug.WriteLine("build new building :" + playerTile.TileType.ToString()); break; } } } vik.resources.UpdateProduction(building.TileType.FoodProduction, building.TileType.StoneProduction, building.TileType.WoodProduction, building.TileType.GoldProduction); if (building.TileType.kind.Equals(TileType.Kind.House)) { vik.resources.maxWorkers += 5; } } } }