public GameEngine() { NeedsRedrawing = true; //when loading a new map we trigger redrawing map MaxPlayers = 1; ThePlayer = new Player(); MonsterMgr = new MonsterManager(); }
public GameEngine() { NeedsRedrawing = true; //when loading a new map we trigger redrawing map MaxPlayers = 1; ThePlayer = new Player(); MonsterMgr = new MonsterManager(); MessageBrd = new MessageBoard(); MessageBrd.Add("Welcome to Mud2D"); }
static GameEngine() { Dirty = true; //when loading a new map we trigger redrawing map MaxPlayers = 1; ThePlayer = new Player(); MonsterMgr = new MonsterManager(); ObjectMgr = new ObjectManager(); ScoreCard = new ScoreCard(); MessageBrd = new MessageBoard(); MessageBrd.Add("Welcome to Mud2D"); }
/// <summary> /// Constructor creates the map tiles array by dimensions /// </summary> /// <param name="width"></param> /// <param name="height"></param> public Map(string mapFilename) { string[] mapLines = System.IO.File.ReadAllLines(mapFilename); NeedsRedrawing = true; //when loading a new map we trigger redrawing map MaxPlayers = 1; Width = mapLines[0].Length; Height = mapLines.Length; Tiles = new MapTile[Height, Width]; ThePlayer = new Player(); MonsterMgr = new MonsterManager(); for (int yPos = 0; yPos < Height; yPos++) { string currentLine = mapLines[yPos]; //SAFETY CHECK if (string.IsNullOrEmpty(currentLine)) { continue; } //create the Map 2d array data from the current line char by char for (int xPos = 0; xPos < Width; xPos++) { CreateTile(currentLine[xPos], xPos, yPos); } //check if player 1 is in this line int foundp1 = currentLine.IndexOf('1'); if (foundp1 != -1) { ThePlayer.X = foundp1; ThePlayer.Y = yPos; } } MonsterMgr.AddMonster(Tiles, 3); }