public Intersection[] GetAllIntersections() { if (allIntersections == null) { List <Intersection> result = new List <Intersection>(22); for (int r = 0; r < 7; r++) { for (int c = 0; c < Board.GetRowLength(r); c++) { Intersection south = null; Intersection southeast = null; if (r % 2 == 0) { if (r + 1 < 7 && c + 1 < Board.GetRowLength(r + 1)) { south = new Intersection(GetTerrainIndex(r, c), GetTerrainIndex(r + 1, c), GetTerrainIndex(r + 1, c + 1)); } if (r + 1 < 7 && c + 1 < Board.GetRowLength(r)) { southeast = new Intersection(GetTerrainIndex(r, c), GetTerrainIndex(r, c + 1), GetTerrainIndex(r + 1, c + 1)); } } else { if (r + 1 < 7 && c - 1 >= 0 && c < 6) { south = new Intersection(GetTerrainIndex(r, c), GetTerrainIndex(r + 1, c - 1), GetTerrainIndex(r + 1, c)); } if (r + 1 < 7 && c < 6) { southeast = new Intersection(GetTerrainIndex(r, c), GetTerrainIndex(r, c + 1), GetTerrainIndex(r + 1, c)); } } if (south != null && (GetTile(south.FirstTile).Terrain != Terrain.Water || GetTile(south.SecondTile).Terrain != Terrain.Water)) { result.Add(south); } if (southeast != null && (GetTile(southeast.FirstTile).Terrain != Terrain.Water || GetTile(southeast.SecondTile).Terrain != Terrain.Water)) { result.Add(southeast); } } } allIntersections = result.ToArray(); } return(allIntersections.ToArray()); }
public MapScreen(GameState initial) { latestGameState = initial; for (int i = 0; i < board.Length; i++) { board[i] = new GUITile[Board.GetRowLength(i)]; for (int j = 0; j < board[i].Length; j++) { bool omit = OmittedTile(GetTerrainIndex(i, j)); GUITile tile = new GUITile(j, i, latestGameState.Board.GetTile(i, j), omit); AddDrawableComponent(tile); board[i][j] = tile; } } //Entire Screen size: GraphicsAdapter.DefaultAdapter.CurrentDisplayMode const int logWidth = 350; //int gameH = graphics.Viewport.Height; //int gameW = graphics.Viewport.Width; const int screenWidth = 1280; const int screenHeight = 720; //Debug.WriteLine(string.Format("width {0}, height {1}", gameW, gameH)); gamelog = new GUILogList <GUIBufferTextBlock>(new Vector2((screenWidth - logWidth) / TXAGame.SCALE, 1 / TXAGame.SCALE), screenHeight - 2, logWidth - 1); //AddButton(new TXAButton(new Vector2(750 / TXAGame.SCALE, 50 / TXAGame.SCALE), "Debug Log"), InsertText); AddDrawableComponent(gamelog); robber = new GUIRobber(GetRobberPos()); AddDrawableComponent(robber); latestGameState.GetLatestEvents(int.MaxValue).Skip(gamelog.Count).ForEach(a => InsertLogEvent(a.ToString())); //lastLogPoll = DateTime.Now; //Test Roads and pieces UpdateGameState(initial); }