public void DrawLayer(SpriteBatch spriteBatch, IMapLayer layer) { int x = 0; int y = 0; foreach (var tile in layer.Tiles()) { var mapStructs = layer.Controller.GetMapStructsAt(layer.LayerName, tile.MapSpot); Texture2D tileText = null; Color grassColor = Color.White; if (Console.BackgroundColor == ConsoleColor.Green) { var time = GameMaster.GetController <ITimeKeeper>(); var season = time.Time.GetValue("SEAS"); if (season == 0) { grassColor = Color.White; } if (season == 1) { grassColor = Color.Yellow; } if (season == 2) { grassColor = Color.Red; } if (season == 3) { grassColor = Color.White; } } spriteBatch.Draw(TileToSprite[tile.TileType], new Vector2(x, y), tile.TileType == TileType.Grass ? grassColor : Color.White); if (mapStructs.Any()) { var sprite = mapStructs.Single().GetSprite(); if (string.IsNullOrEmpty(sprite)) { tileText = TileToSprite[TileType.DirtXXX]; } else { tileText = Sprites[sprite]; } } if (tileText != null) { spriteBatch.Draw(tileText, new Vector2(x, y), Color.White); } x = x + TileSize; if (tile.X == layer.MaxWidth - 1) { x = 0; y = y + TileSize; } } }
public void DrawLayer(IMapLayer layer) { foreach (var tile in layer.Tiles()) { if (tile != null) { Console.BackgroundColor = TileToColor[tile.TileType]; } else { Console.BackgroundColor = ConsoleColor.Cyan; } var text = ""; var mapStructs = layer.Controller.GetMapStructsAt(layer.LayerName, tile.MapSpot); if (mapStructs.Any()) { var sprite = mapStructs.Single().GetSprite() as FakeSprite; if (sprite == null) { Console.BackgroundColor = ConsoleColor.Red; text = text + "XX"; } else { Console.BackgroundColor = sprite.BackColor; Console.ForegroundColor = sprite.MainColor; text = text + sprite.Text; } } else { text = text + " ";// (tile.X % 10).ToString() + (tile.Y % 10).ToString(); } if (Console.BackgroundColor == ConsoleColor.Green) { var time = GameMaster.GetController <ITimeKeeper>(); var season = time.Time.GetValue("SEAS"); if (season == 0) { Console.BackgroundColor = ConsoleColor.Green; } if (season == 1) { Console.BackgroundColor = ConsoleColor.Yellow; } if (season == 2) { Console.BackgroundColor = ConsoleColor.DarkYellow; } if (season == 3) { Console.BackgroundColor = ConsoleColor.White; } } Console.Write(text); if (tile.X == layer.MaxWidth - 1) { Console.WriteLine(""); } } Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; }