示例#1
0
        public void Run()
        {
            window.SetActive();

            bool gameIsOver = false;

            // Game.GetInstance( ).InitializeGame( paths[currentLevel] );
            while (window.IsOpen && !gameIsOver)
            {
                EndGameResult result = Game.GetInstance().Update();
                if (result == EndGameResult.Win)
                {
                    // Signaler la victoire
                    Game.GetInstance().HandleEndOfGame(result);
                }
                else if (result == EndGameResult.Lost)
                {
                    // Signaler la défaite
                    Game.GetInstance().HandleEndOfGame(result);
                }
                else
                {
                    // Effectuer le rendu
                    window.Clear(backgroundColor);
                    window.DispatchEvents();
                    Game.GetInstance().Draw(window);
                    window.Display();
                }
            }
        }
示例#2
0
        /// <summary>
        /// Fonction qui gère la fin de partie.
        /// </summary>
        public void HandleEndOfGame(EndGameResult result)
        {
            string message = "";
            string title   = "Partie Terminée";

            if (result == EndGameResult.Win)
            {
                message = "Bravo, vous avez survécu! Voulez-vous rejouer?";
            }
            else if (result == EndGameResult.Lost)
            {
                message = "Vous avez été mangé! Voulez-vous rejouer?";
            }
            DialogResult question = MessageBox.Show(message, title, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (DialogResult.No == question)
            {
                // Quitter le jeu
                System.Environment.Exit(0);
            }
            else
            {
                // Redémarrer
                InitializeNewGame();
            }
        }
示例#3
0
        public void EndGame(EndGameResult gameResult)
        {
            TickTimer.Stop();
            Projectiles.RemoveAll(x => true);
            Console.Clear();
            if (gameResult == EndGameResult.Win)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.SetCursorPosition(1, 1);
                Console.WriteLine("Congratulations, you've defeated all the alien ships!");
                Console.SetCursorPosition(1, 2);
                Console.WriteLine("A new game will start in 5 seconds...");
                Console.ForegroundColor = ConsoleColor.White;
            }
            if (gameResult == EndGameResult.GameOver)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.SetCursorPosition(1, 1);
                Console.WriteLine("GAME OVER!");
                Console.SetCursorPosition(1, 2);
                Console.WriteLine("A new game will start in 5 seconds...");
                Console.ForegroundColor = ConsoleColor.White;
            }

            System.Threading.Thread.Sleep(5000);
            Console.Clear();
            Start(new Player(this));
        }
示例#4
0
        public IGameState CreateGameOverState(IGameContext context, EndGameResult endGameResult)
        {
            var state = CreateAndInitState(_gameOverStateFactory, context);

            (state as GameOverState)?.SetGameResult(endGameResult);
            return(state);
        }
示例#5
0
    private async void OnGameEnded(EndGameResult endGameResult)
    {
        _scoreboardDataController.SaveResultToScoreboard(new GameResultDto {
            Score = _score, Timestamp = DateTime.Now, IsHighlighted = true
        });
        switch (endGameResult)
        {
        case EndGameResult.Win:
            await _endGameText.ShowWin(_score);

            break;

        case EndGameResult.Lose:
            await _endGameText.ShowLose(_score);

            break;

        default:
            throw new ArgumentOutOfRangeException(nameof(endGameResult), endGameResult, null);
        }

        _scoreboardDataController.ShowScoreboard();
        await Task.Delay(5000);

        if (_currentState is GameOverState)
        {
            SceneManager.LoadScene("Menu");
        }
    }
 public AfterGameScreenDataMessage(List <EndGamePartyMemberInfo> playerList, int endGameTimeSeconds, int gameMode,
                                   int winningGroup, EndGameResult gameResult, int eloChange, int meritPointsAwarded)
     : base(MessageType.AfterGameScreenData)
 {
     PlayerList         = playerList;
     EndGameTimeSeconds = endGameTimeSeconds;
     GameMode           = gameMode;
     WinningGroup       = winningGroup;
     GameResult         = gameResult;
     EloChange          = eloChange;
     MeritPointsAwarded = meritPointsAwarded;
 }
        /// <summary>
        /// Évènement appelé à chaque mis à jour du jeu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnTimer(object sender, EventArgs e)
        {
            //On affiche le score du joueur
            labelScore.Text = "Score : " + game.Score;

            //<Charles Lachance>
            //On met à jour le jeu et on récupère le résultat
            EndGameResult result = game.Update( );

            //On affiche le nombre de vies restantes au joueur
            lblVies.Text = "Vies : " + game.Player.NbLives;
            //On affiche le nombre de munitions restantes au joueur
            lblMunitions.Text = "Munitions : " + game.Player.Ammo;

            //Si la partie est finie...
            if (result == EndGameResult.GAME_LOST)
            {
                //On arrête le jeu
                mainTimer.Enabled = false;
                //<Tommy Bouffard>
                //On arrete la musique lorsque la partie se termine.
                MillipedeGame.sndTrack.Stop();
                //</Tommy Bouffard>

                //On passe le score du joueur au tableau des records
                leaderboard.Score = game.Score;
                //Si le joueur ne clique pas sur le bouton quitter...
                if (leaderboard.ShowDialog() != DialogResult.Abort)
                {
                    //On crée une nouvelle partie
                    game = new MillipedeGame();
                    //On reprend le jeu
                    mainTimer.Enabled = true;
                }
                else
                {
                    //On quitte le programme
                    Application.Exit();
                }
            }

            Invalidate( );
        }
        private async Task HandleGameEnd(EndGameResult endGameResult)
        {
            switch (endGameResult)
            {
            case EndGameResult.BlackWin:
                MessageBox.Show("Black win");
                break;

            case EndGameResult.WhiteWin:
                MessageBox.Show("White win");
                break;

            case EndGameResult.Draw:
                MessageBox.Show("Draw win");
                break;

            default:
                throw new NotImplementedException();
            }
        }
示例#9
0
 public void SetGameResult(EndGameResult endGameResult)
 {
     _gameResult = endGameResult;
 }
示例#10
0
        // </MikaGauthier>

        /// <summary>
        /// Met à jour la logique de jeu
        /// </summary>
        /// <param name="key">La touche entrée par le joueur pour contrôle le pacman</param>
        /// <returns>EndGameResult.NotFinished si la partie est toujours en cours, EndGameResult.Win
        /// si le joueur a mangé toutes les pastilles ou EndGameResult.Losse si le joueur s'est fait
        /// mangé par un fantôme</returns>
        public EndGameResult Update(Keyboard.Key key)
        {
            EndGameResult partieFinie = EndGameResult.NotFinished;

            //<AntoineRL>
            // Déplacement du joueur
            if (key == Keyboard.Key.Left)
            {
                // A COMPLETER
                pacman.Move(Direction.West, grid);
            }
            else if (key == Keyboard.Key.Right)
            {
                // A COMPLETER
                pacman.Move(Direction.East, grid);
            }
            else if (key == Keyboard.Key.Up)
            {
                // A COMPLETER
                pacman.Move(Direction.North, grid);
            }
            else if (key == Keyboard.Key.Down)
            {
                // A COMPLETER
                pacman.Move(Direction.South, grid);
            }
            //</AntoineRL>

            // <MikaGauthier>

            // Mise à jour des fantômes
            // A COMPLETER
            // Sleep a second
            if (updateCpt % 10 == 0)
            {
                if (updateSuperPillActive > SUPERPILL_ACTIVATION_TIME)
                {
                    SuperPillActive       = false;
                    updateSuperPillActive = 0;
                }
                else if (SuperPillActive)
                {
                    updateSuperPillActive++;
                }
                ghosts[0].Update(grid, new Vector2i(pacman.Row, pacman.Column), SuperPillActive);
                ghosts[1].Update(grid, new Vector2i(pacman.Row, pacman.Column), SuperPillActive);
                ghosts[2].Update(grid, new Vector2i(pacman.Row, pacman.Column), SuperPillActive);
                ghosts[3].Update(grid, new Vector2i(pacman.Row, pacman.Column), SuperPillActive);
            }
            updateCpt++;

            // Limitation de int
            if (updateCpt == 10000)
            {
                updateCpt = 0;
            }



            // Gestion des collisions avec le pacman
            // A COMPLETER
            for (int i = 0; i < NB_GHOSTS; i++)
            {
                if (pacman.Row == ghosts[i].Row && pacman.Column == ghosts[i].Column && SuperPillActive == false)
                {
                    partieFinie = EndGameResult.Losse;
                }
                else if (pacman.Row == ghosts[i].Row && pacman.Column == ghosts[i].Column && SuperPillActive == true)
                {
                    if (i == 0)
                    {
                        ghosts[i].Column = 10;
                        ghosts[i].Row    = 8;
                    }
                    else if (i == 1)
                    {
                        ghosts[i].Column = 10;
                        ghosts[i].Row    = 9;
                    }
                    else if (i == 2)
                    {
                        ghosts[i].Column = 9;
                        ghosts[i].Row    = 9;
                    }
                    else if (i == 3)
                    {
                        ghosts[i].Column = 11;
                        ghosts[i].Row    = 9;
                    }
                    partieFinie = EndGameResult.NotFinished;
                }
            }

            // </MikaGauthier>
            //<AntoineRL>

            // Vérification du ramassage d'une pastille
            // A COMPLETER
            if (grid.GetGridElementAt(pacman.Row, pacman.Column) == PacmanElement.Pill)
            {
                grid.SetGridElementAt(pacman.Row, pacman.Column, PacmanElement.None);
            }

            // </AntoineRL>
            // <MikaGauthier>

            // Vérification de l'activation d'un superpill
            // A COMPLETER
            if (grid.GetGridElementAt(pacman.Row, pacman.Column) == PacmanElement.SuperPill)
            {
                SuperPillActive       = true;
                updateSuperPillActive = 0;
                grid.SetGridElementAt(pacman.Row, pacman.Column, PacmanElement.None);
            }

            // Validations de fin de partie
            // A COMPLETER car il faut que la partie finisse s'il ne reste plus de pastille
            if (CountNbPillsRemaining() == 0)
            {
                partieFinie = EndGameResult.Win;
            }

            // ou si le pacman a été mangé par un fantôme
            return(partieFinie);

            // </MikaGauthier>
        }
示例#11
0
 public static void Prefix(AmongUsClient __instance, [HarmonyArgument(0)] ref EndGameResult endGameResult)
 {
     Munou.endGameFlag = true;
 }
示例#12
0
        /// <summary>
        /// Met à jour la logique de jeu
        /// </summary>
        /// <param name="key">La touche entrée par le joueur pour contrôle le pacman</param>
        /// <returns>EndGameResult.NotFinished si la partie est toujours en cours, EndGameResult.Win
        /// si le joueur a mangé toutes les pastilles ou EndGameResult.Losse si le joueur s'est fait
        /// mangé par un fantôme</returns>
        public EndGameResult Update(Keyboard.Key key)
        {
            //Position du pacman, transformé en vecteur.
            Vector2i pacmanPosition = new Vector2i(pacman.Column, pacman.Row);

            // Déplacement du joueur
            if (key == Keyboard.Key.Left)
            {
                if (grid.GetGridElementAt(pacman.Row, pacman.Column - 1) != PacmanElement.Wall)
                {
                    pacman.Column--;
                }
            }
            else if (key == Keyboard.Key.Right)
            {
                if (grid.GetGridElementAt(pacman.Row, pacman.Column + 1) != PacmanElement.Wall)
                {
                    pacman.Column++;
                }
            }
            else if (key == Keyboard.Key.Up)
            {
                if (grid.GetGridElementAt(pacman.Row - 1, pacman.Column) != PacmanElement.Wall)
                {
                    pacman.Row--;
                }
            }
            else if (key == Keyboard.Key.Down)
            {
                if (grid.GetGridElementAt(pacman.Row + 1, pacman.Column) != PacmanElement.Wall)
                {
                    pacman.Row++;
                }
            }
            // Mise à jour des fantômes
            for (int i = 0; i < ghosts.Length; i++)
            {
                ghosts[i].Update(grid, pacmanPosition, SuperPillActive);
            }

            // Vérification du ramassage d'une pastille
            if (grid.GetGridElementAt(pacman.Row, pacman.Column) == PacmanElement.Pill)
            {
                System.Media.SoundPlayer player = new System.Media.SoundPlayer("Assets/pacman_chomp.wav");
                player.Play();
                grid.SetGridElementAt(pacman.Row, pacman.Column, 0);
            }
            // Vérification de l'activation d'un superpill
            if (grid.GetGridElementAt(pacman.Row, pacman.Column) == PacmanElement.SuperPill)
            {
                System.Media.SoundPlayer player = new System.Media.SoundPlayer("Assets/pacman_chomp.wav");
                player.Play();
                durationSuperPill = 0;
                grid.SetGridElementAt(pacman.Row, pacman.Column, 0);
                SuperPillActive = true;
            }
            //Vérification de la durée d'un superpill.
            if (SuperPillActive)
            {
                if (durationSuperPill == SUPERPILL_ACTIVATION_TIME * Application.TARGET_FPS)
                {
                    SuperPillActive   = false;
                    durationSuperPill = 0;
                }
                else
                {
                    durationSuperPill++;
                }
                //Lorsque Pacman mange un fantôme, celui-ci retourne directement dans la cage.
                for (int i = 0; i < ghosts.Length; i++)
                {
                    Vector2i ghostPosition = new Vector2i(ghosts[i].Column, ghosts[i].Row);
                    if (pacmanPosition == ghostPosition)
                    {
                        System.Media.SoundPlayer player = new System.Media.SoundPlayer("Assets/pacman_eatghost.wav");
                        player.Play();
                        ghosts[i].Column = grid.GhostCagePositionColumn;
                        ghosts[i].Row    = grid.GhostCagePositionRow;
                    }
                }
            }
            // Validations de fin de partie
            EndGameResult gameResult = EndGameResult.NotFinished;

            //Il reste des pills, la partie n'est pas finie.
            for (int i = 0; i < DEFAULT_GAME_ELEMENT_WIDTH; i++)
            {
                for (int j = 0; j < DEFAULT_GAME_ELEMENT_HEIGHT; j++)
                {
                    if (grid.GetGridElementAt(j, i) == PacmanElement.Pill || grid.GetGridElementAt(j, i) == PacmanElement.SuperPill)
                    {
                        gameResult = EndGameResult.NotFinished;
                    }
                }
            }
            //Un fantôme a atteint pacman, la partie est perdue.
            for (int i = 0; i < ghosts.Length; i++)
            {
                Vector2i ghostPosition = new Vector2i(ghosts[i].Column, ghosts[i].Row);
                if (pacmanPosition == ghostPosition && SuperPillActive == false)
                {
                    gameResult = EndGameResult.Losse;
                }
            }
            //Il ne reste plus de pills, la partie est gagnée.
            int nbPillsRemaining = CountNbPillsRemaining();

            if (nbPillsRemaining == 0)
            {
                gameResult = EndGameResult.Win;
            }
            return(gameResult);
        }
示例#13
0
文件: Game.cs 项目: ZakenKenpachi/tp2
 public void HandleEndOfGame(EndGameResult result)
 {
 }