/// <summary> /// Constructor, with required parts to run /// </summary> public MapViewElement(AtlasWarriorsGame.Game Game, GraphicsDevice Device, ContentManager Content) { this.Game = Game; this.Content = Content; this.Device = Device; // Initialise bits for drawing MapFont = Content.Load <SpriteFont>("GameMapState/MapFont"); // W tends to be widest - hence, if not monospace - will still be OK TileWidth = MapFont.MeasureString("W").X; // f tends to be tallest - hence, if not monospace - will still be OK TileHeight = MapFont.MeasureString("f").Y; // Populate sprite list using (var spriteFileReader = new System.IO.StreamReader(Game.GetAssetStream("sprites_mgui.json"))) { var spriteFileText = spriteFileReader.ReadToEnd(); Sprites = JsonConvert.DeserializeObject <Dictionary <String, ConsoleCell> > (spriteFileText); } // Initialise last dungeon to initial dungeon LastTurnDungeon = Game.CurrentDungeon; ResetRenderTargetAndConsole(); }
/// <summary> /// Constructor, with required parts to run /// </summary> public MapViewElement(AtlasWarriorsGame.Game Game, GraphicsDevice Device, ContentManager Content) { this.Game = Game; this.Content = Content; this.Device = Device; // Initialise bits for drawing MapFont = Content.Load <SpriteFont>("GameMapState/MapFont"); // W tends to be widest - hence, if not monospace - will still be OK TileWidth = MapFont.MeasureString("W").X; // f tends to be tallest - hence, if not monospace - will still be OK TileHeight = MapFont.MeasureString("f").Y; // Initialise last dungeon to initial dungeon LastTurnDungeon = Game.CurrentDungeon; ResetRenderTargetAndConsole(); }
/// <summary> /// Remove the item from the collection on the basis of instance of the field. /// </summary> /// <param name="mapField"></param> public void Remove(MapFont mapField) { this.InnerList.Remove(mapField); }
/// <summary> /// Move the field on the top of the collection. /// </summary> /// <param name="mapField"></param> private void MoveToTop(MapFont mapField) { this.InnerList.Remove(mapField); this.InnerList.Insert(0, mapField); }
/// <summary> /// Add the details into the collection /// </summary> /// <param name="map"></param> public void Add(MapFont map) { bool NewField = true; foreach (MapFont MapField in this.InnerList) { if (MapField.FontName == map.FontName && MapField.CharacterIndex == map.CharacterIndex && MapField.FontColor == map.FontColor && MapField.FontSize == map.FontSize) { NewField = false; //-- If the item already exists, then it send that item onto the top this.MoveToTop(MapField); break; } } // -- Font list add only 15 items. 1st item will remove if user want to add more items into the collection. It works on FIFO basis. if (this.InnerList.Count > 15 && NewField) { this.InnerList.RemoveAt(0); this.InnerList.Add(map); } else if (NewField) { this.InnerList.Add(map); } }