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; } } }
public void NewGame() { projectile = new Projectile(); packman = new Packman(sizeField); tanks = new List<Tank>(); fireTank = new List<FireTank>(); apples = new List<Apple>(); collectedApples = 0; gameStatus = GameStatus.stopping; wall =new Wall(); CreateTanks(); CreateApples(0); step = -30; }
private void CreateBorder() { for (int i = 0; i < m_n; i++) { m_field[i, 0] = new Wall(i, 0); m_field[i, m_m - 1] = new Wall(i, m_m - 1); } for (int i = 1; i < m_m - 1; i++) { m_field[0, i] = new Wall(0, i); m_field[m_n - 1, i] = new Wall(m_n - 1, i); } }
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); } }
//рисует стену public static void paint(Wall wall) { throw new NotImplementedException(); }