/// <summary> /// Monsters list init /// </summary> /// <param name="pattern">Level pattern</param> public void InitMonsters(LevelPattern pattern) { foreach (var monster in pattern.MonsterSpawns) { Monsters.Add(monster); } }
/// <summary> /// Wall list init /// </summary> /// <param name="pattern">Level patter</param> private void InitWalls(LevelPattern pattern) { foreach (var wall in pattern.Walls) { Walls.Add(wall); } }
/// <summary> /// Init big yellow points /// </summary> /// <param name="pattern">Level pattern</param> public void InitEnergizers(LevelPattern pattern) { foreach (var energizer in pattern.Energizers) { Energizers.Add(energizer); } }
/// <summary> /// Init small yellow points /// </summary> /// <param name="pattern">Level pattern</param> public void InitSmallPoints(LevelPattern pattern) { foreach (var point in pattern.SmallPoints) { Points.Add(point); } }
/// <summary> /// Init all lists of game objects and game stats /// </summary> /// <param name="pattern">Pattern of current level</param> private void InitAllLists(LevelPattern pattern) { Walls = new List <Wall>(); Monsters = new List <Monster>(); Points = new List <SmallPoint>(); Energizers = new List <Energizer>(); LevelScheme = pattern.LevelScheme; WorldStat = new WorldStat(); }
/// <summary> /// Прочитать файл-паттерн и создать на основе этого файла /// описание объектов уровня /// </summary> /// <returns>Объект-уровень</returns> public LevelPattern ParseFile() { //Читаем файл и создаем объект PatternStruct var reader = new StreamReader(PathToPattern); var pattern = new LevelPattern(); var line = ""; //Координаты var x = 0; var y = 0; while (!reader.EndOfStream) { x = 0; line = reader.ReadLine(); for (int i = 0; i < line.Length; i++) { switch (line[i]) { case LevelParser.WallSign: pattern.AddWall(x, y); break; case LevelParser.BlinkySpawnSign: pattern.AddMonsterSpawn(x, y, MonsterTypes.BLINKY); pattern.AddFloor(x, y); break; case LevelParser.PinkySpawnSign: pattern.AddMonsterSpawn(x, y, MonsterTypes.PINKY); pattern.AddFloor(x, y); break; case LevelParser.InkySpawnSign: pattern.AddMonsterSpawn(x, y, MonsterTypes.INKY); pattern.AddFloor(x, y); break; case LevelParser.ClydeSpawnSign: pattern.AddMonsterSpawn(x, y, MonsterTypes.CLYDE); pattern.AddFloor(x, y); break; case LevelParser.PacmanSpawnSign: Pacman.StartX = x; Pacman.StartY = y; pattern.AddFloor(x, y); break; case LevelParser.ScorePointSpawnSign: pattern.AddSmallPoint(x, y); pattern.AddFloor(x, y); break; case LevelParser.EnergizerSpawnSign: pattern.AddEnergizer(x, y); pattern.AddFloor(x, y); break; case LevelParser.EmptySpaceSign: pattern.AddFloor(x, y); break; } x++; } y++; } return(pattern); }
/// <summary> /// Player (pacman) init /// </summary> /// <param name="pattern">LevelPacman</param> public void InitPlayer(LevelPattern pattern) { Pacman = new Pacman(Pacman.StartX, Pacman.StartY, 10); }