internal Task StartNewGame() { blinky = new GhostBlinky(); pinky = new GhostPinky(); clyde = new GhostClyde(); inky = new GhostInky(); _pacman.isMoving = false; _pacman.position_x = 1; _pacman.position_y = 1; _pacman.move_X = 0; _pacman.move_Y = 1; level = 1; _pacman.lifes = 3; score.coin_sum = 0; score.game_finish = 0; score.sum_bonus_coin = 0; CountDown(); eated_coin.Clear(); eated_energizer.Clear(); _pacman.isMoving = true; PacmanTimer.Change(0, 100); InkyTimer.Change(0, 120); ClydeTimer.Change(0, 120); PinkyTimer.Change(0, 120); BlinkyTimer.Change(0, 120); blinky.StartMoving(); _gameMap.RestorMap(); return(Task.CompletedTask); }
private void NextLevel() { blinky = new GhostBlinky(); pinky = new GhostPinky(); clyde = new GhostClyde(); inky = new GhostInky(); _pacman.isMoving = false; _pacman.position_x = 1; _pacman.position_y = 1; _pacman.move_X = 0; _pacman.move_Y = 1; _pacman.lifes++; level++; score.game_finish = 0; CountDown(); eated_coin.Clear(); eated_energizer.Clear(); _pacman.isMoving = true; PacmanTimer.Change(0, 100); InkyTimer.Change(0, 120); ClydeTimer.Change(0, 120); PinkyTimer.Change(0, 120); BlinkyTimer.Change(0, 120); blinky.StartMoving(); score.ghost_start = 0; _gameMap.RestorMap(); }
public void UpdateCloudy(object state) { if (clyde.IsMoving) { //Clyde logic if (clyde.MovingToHome) { clyde.IsFrightened = false; ClydeTimer.Change(50, 50); var qwerty = new Init().Inite(11, 14, clyde.position_x, clyde.position_y); clyde.move_X = qwerty.Item1; clyde.move_Y = qwerty.Item2; if ((clyde.position_x == 11) && (clyde.position_y == 14)) { clyde.MovingToHome = false; ClydeTimer.Change(120, 120); } } else if (!clyde.IsFrightened) { if (clyde.PersecutionOrRunaway) { //рух в кут, в точку розбігання clyde.finish_point_x = clyde.run_point_x; clyde.finish_point_y = clyde.run_point_y; } else if (!clyde.PersecutionOrRunaway) { // переслідування пакмена if (_gameMap.map[clyde.position_x, clyde.position_y] == 'c') { int shot_way; shot_way = new Init().Shortest_way(_pacman.position_x, _pacman.position_y, clyde.position_x, clyde.position_y, clyde.move_X, clyde.move_Y); if (shot_way <= 15) { clyde.finish_point_x = clyde.run_point_x; clyde.finish_point_y = clyde.run_point_y; } else { clyde.finish_point_x = _pacman.position_x; clyde.finish_point_y = _pacman.position_y; } } } if (clyde.TimerType) { ClydeTimer.Change(120, 120); clyde.TimerType = false; } if (_gameMap.map[clyde.position_x, clyde.position_y] == 'c') { var qwerty = new Init().Inite2(clyde.finish_point_x, clyde.finish_point_y, clyde.position_x, clyde.position_y, clyde.move_X, clyde.move_Y); clyde.move_X = qwerty.Item1; clyde.move_Y = qwerty.Item2; } } else { // клуді переходить у режим страху: зменшення швидкості, миттєво змінює напрямок, випадково визначає напрямок руху if (_gameMap.map[clyde.position_x, clyde.position_y] == 'c') { clyde.RandomMove(); clyde.TimerType = true; } } if (_gameMap.map[clyde.position_x + clyde.move_X, clyde.position_y + clyde.move_Y] != 'w') { clyde.position_x += clyde.move_X; clyde.position_y += clyde.move_Y; } // перевірка чи клуді не зловив пакмена CheckPacmanTouchGhost(clyde); hub.Clients.Clients(clients).SendAsync("ChangeClydePosition", clyde.position_x, clyde.position_y, clyde.IsFrightened, clyde.MovingToHome); } }