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(); }
private void UpdateBlinky(object state) { //blinky_logic if (blinky.IsMoving) { if (blinky.MovingToHome) { blinky.IsFrightened = false; BlinkyTimer.Change(50, 50); var qwerty = new Init().Inite(11, 14, blinky.position_x, blinky.position_y); blinky.move_X = qwerty.Item1; blinky.move_Y = qwerty.Item2; if ((blinky.position_x == 11) && (blinky.position_y == 14)) { blinky.MovingToHome = false; BlinkyTimer.Change(120, 120); } } else if (!blinky.IsFrightened) { if (blinky.PersecutionOrRunaway) { blinky.finish_point_x = blinky.run_point_x; blinky.finish_point_y = blinky.run_point_y; } else if (!blinky.PersecutionOrRunaway) { blinky.finish_point_x = _pacman.position_x; blinky.finish_point_y = _pacman.position_y; } if (blinky.TimerType) { BlinkyTimer.Change(120, 120); blinky.TimerType = false; } // визначення напрямку через граф if (_gameMap.map[blinky.position_x, blinky.position_y] == 'c') { var qwerty = new Init().Inite2(blinky.finish_point_x, blinky.finish_point_y, blinky.position_x, blinky.position_y, blinky.move_X, blinky.move_Y); blinky.move_X = qwerty.Item1; blinky.move_Y = qwerty.Item2; } } else if (blinky.IsFrightened) { // блінкі переходить у режим страху: зменшення швидкості, миттєво змінює напрямок, випадково визначає напрямок руху if (_gameMap.map[blinky.position_x, blinky.position_y] == 'c') { blinky.RandomMove(); blinky.TimerType = true; } } if (_gameMap.map[blinky.position_x + blinky.move_X, blinky.position_y + blinky.move_Y] != 'w') { blinky.position_x += blinky.move_X; blinky.position_y += blinky.move_Y; } // перевірка чи пінкі не зловив пакмена CheckPacmanTouchGhost(blinky); hub.Clients.Clients(clients).SendAsync("ChangeBlinkyPosition", blinky.position_x, blinky.position_y, blinky.IsFrightened, blinky.MovingToHome); } }