//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); } }
public Ground(MapMatrix parent,string groundtype, Point coord) : base() { Ramdom gui = new Ramdom(); groundID = gui.RandomString(32); _parent = parent; _groundtype = groundtype; switch (groundtype) { case "W": _damage=10; _absortion= 0.3; break; case "D": _damage=30; _absortion= 0.1; break; case "S": _damage=15; _absortion= 0.7; break; case "P": _damage=2; _absortion= 1; break; } coordenate = coord; }
public AbtractPlant(DNA dna, Ground parent) { Ramdom gui = new Ramdom(); aliveID = gui.RandomString(32); _dna = new DNAPlant(dna, aliveID); _parent = parent; }