//Initialize the matrix reading the type of ground from the file mapname and creating the ground elements public MapMatrix(int x, int y, string mapname) { _x = x; _y = y; Ramdom gui = new Ramdom(); mapID = gui.RandomString(32); screen = Screen.Instance; _mapname = mapname; try { string[] lines = System.IO.File.ReadAllLines(mapname.ToString()); int Index_x; int Limit = x - 1; int Index_y; int Limit_Y = y - 1; for (Index_x = 0; Index_x <= Limit; Index_x++) { for (Index_y = 0; Index_y <= Limit_Y; Index_y++) { Ground NewGround = new Ground(this, lines[Index_x].Substring(Index_y, 1), new Point(Index_x, Index_y)); _mapM.Add(NewGround); screen.paint(NewGround.coordn, NewGround.groundtype, NewGround.ListPlant.Count); } } } catch (Exception e) { Console.Write("Error in MapMatrix constructor"); Console.Write(e.Message); } }
//Load from database. It will retrieve the information from the database public MapMatrix(string savegame,string mapID) { screen = Screen.Instance; _savegame = savegame; this.mapID = mapID; RePaint(); }