Example #1
0
 public void LoadLevel(string path)
 {
     using(StreamReader sr = new StreamReader(path))
     {
         m_n = Convert.ToInt32(sr.ReadLine());
         m_m = Convert.ToInt32(sr.ReadLine());
         while (!sr.EndOfStream)
         {
             string type = sr.ReadLine();
             ISerializable unit;
             switch (type)
             {
                 case "floor":
                     unit = new Floor();
                     break;
                 case "wall":
                     unit = new Wall();
                     break;
                 case "tank":
                     unit = new Tank();
                     break;
                 default:
                     unit = new Floor();
                     break;
             }
             unit.Load(sr);
             IPositionable positionOfUnit = unit as IPositionable;
             m_field[positionOfUnit.Position.X, positionOfUnit.Position.Y] = positionOfUnit;
         }
     }
 }
Example #2
0
 private void FillLevel()
 {
     for (int i = 0; i < m_n; i++)
     {
         for (int j = 0; j < m_m; j++)
         {
             m_field[i, j] = new Floor(i, j);
         }
     }
 }
Example #3
0
 public void CheckWall(int x, int y)
 {
     int curX = x / Width;
     int curY = y / Height;
     //int curX = (x - x % Width);
     //int curY = (y - y % Height);
     //Wall wall = new Wall(curX, curY);
     if (m_field[curX, curY] is Floor)
     {
         m_field[curX, curY] = new Wall(curX, curY);
     }
     else
     {
         m_field[curX, curY] = new Floor(curX, curY);
     }
 }