public void CreateNewLvl(GameLvl lvl) //метод для создания нового уровня { Alive = true; if (lvl == GameLvl.first) { snake = new Snake(new Point { X = 17, Y = 16 }, ConsoleColor.Black, 'o'); food = new Food(new Point { X = -1, Y = -1 }, ConsoleColor.Black, '@'); wall = new Wall(null, ConsoleColor.Black, '#'); score = 0; } else { score += (snake.body.Count - 1) * coef; snake.body.Clear(); snake.body.Add(new Point { X = 17, Y = 16 }); wall.body.Clear(); } wall.LoadLevel(lvl); }
static int Level(GameLvl lvl) //возвращает номер уровня { int a = 1; if (lvl == GameLvl.first) { a = 1; } else if (lvl == GameLvl.second) { a = 2; } else if (lvl == GameLvl.third) { a = 3; } else if (lvl == GameLvl.fourth) { a = 4; } else if (lvl == GameLvl.fifth) { a = 5; } return(a); }
public void LoadLevel(GameLvl lvl) //метод для загрузки стенок уровня { string path = ""; switch (lvl) { case GameLvl.first: path = @"LVLs\lvl1.txt"; break; case GameLvl.second: path = @"LVLs\lvl2.txt"; break; case GameLvl.third: path = @"LVLs\lvl3.txt"; break; case GameLvl.fourth: path = @"LVLs\lvl4.txt"; break; case GameLvl.fifth: path = @"LVLs\lvl5.txt"; break; } body.Clear(); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs); string line; int y = 0; while ((line = sr.ReadLine()) != null) { for (int x = 0; x < line.Length; ++x) { if (line[x] == c) { body.Add(new Point { X = x, Y = y }); } } y++; } sr.Close(); fs.Close(); }
public Engine() { Switch = true; mode = Mode.menu; menumode = MenuMode.main; lvl = GameLvl.first; obj = Obj.snake; menu = new Menu(null, ConsoleColor.Blue, '#'); menu.LoadRamp(); game = new Game(lvl); menu.DrawAll(); }
void ProceedLevel() { if (lvl == GameLvl.first) { lvl = GameLvl.second; } else if (lvl == GameLvl.second) { lvl = GameLvl.third; } else if (lvl == GameLvl.third) { lvl = GameLvl.fourth; } else if (lvl == GameLvl.fourth) { lvl = GameLvl.fifth; } }
void MenuAction() { switch (menu.ind) { case 0: mode = Mode.play; lvl = GameLvl.first; game.lvl = lvl; game.CreateNewLvl(game.lvl); game.LoadColors(snakecolor, headcolor, wallcolor, foodcolor); game.CreateNewFood(); game.Draw(); break; case 1: mode = Mode.play; game = Game.Load(); game.LoadColors(snakecolor, headcolor, wallcolor, foodcolor); game.Draw(); game.StopSnake(); break; case 2: menu.ChangeOptions(); menumode = menu.menumode; menu.DrawAll(); break; case 3: break; case 4: Switch = false; EndProcess(); break; } }
public GameLvl lvl; //текущий уровень public Game(GameLvl lvl) //конструктор { CreateNewLvl(lvl); }