Exemple #1
0
    /// <summary>
    /// Stops listening to the old game once a new game is started
    /// </summary>

    private static void EndGame()
    {
        //RemoveHandler _human.PlayerGrid.Changed, AddressOf GridChanged
        _ai.PlayerGrid.Changed   -= GridChanged;
        _theGame.AttackCompleted -= AttackCompleted;
        EndingGameController.DrawEndOfGame();
    }
    /// <summary>
    /// Draws the current state of the game to the screen.
    /// </summary>
    /// <remarks>
    /// What is drawn depends upon the state of the game.
    /// </remarks>
    public static void DrawScreen()
    {
        UtilityFunctions.DrawBackground();

        switch (CurrentState)
        {
        case GameState.ViewingMainMenu:
        {
            MenuController.DrawMainMenu();
            break;
        }

        case GameState.ViewingGameMenu:
        {
            MenuController.DrawGameMenu();
            break;
        }

        case GameState.AlteringSettings:
        {
            MenuController.DrawSettings();
            break;
        }

        case GameState.Deploying:
        {
            DeploymentController.DrawDeployment();
            break;
        }

        case GameState.Discovering:
        {
            DiscoveryController.DrawDiscovery();
            break;
        }

        case GameState.EndingGame:
        {
            EndingGameController.DrawEndOfGame();
            break;
        }

        case GameState.ViewingHighScores:
        {
            HighScoreController.DrawHighScores();
            break;
        }
        }

        UtilityFunctions.DrawAnimations();

        SwinGame.RefreshScreen();
    }
    /// <summary>
    /// Draws the current state of the game to the screen.
    /// </summary>
    /// <remarks>
    /// What is drawn depends upon the state of the game.
    /// </remarks>
    public static void DrawScreen()
    {
        UtilityFunctions.DrawBackground();

        switch (CurrentState)
        {
        case GameState.ViewingMainMenu:
            MenuController.DrawMainMenu();
            SwinGame.StopTimer(Timer);
            break;

        case GameState.ViewingGameMenu:
            MenuController.DrawGameMenu();
            SwinGame.StopTimer(Timer);
            break;

        case GameState.AlteringSettings:
            MenuController.DrawSettings();
            SwinGame.StopTimer(Timer);
            break;

        case GameState.Deploying:
            DeploymentController.DrawDeployment();
            SwinGame.ResetTimer(Timer);
            break;

        case GameState.Discovering:
            DiscoveryController.DrawDiscovery();
            if (SwinGame.TimerTicks(Timer) == 0)
            {
                SwinGame.StartTimer(Timer);
            }
            break;

        case GameState.EndingGame:
            EndingGameController.DrawEndOfGame();
            break;

        case GameState.ViewingHighScores:
            HighScoreController.DrawHighScores();
            SwinGame.StopTimer(Timer);
            break;

        case GameState.ViewInstruction:
            Instruction.WriteInstruction();
            break;
        }

        UtilityFunctions.DrawAnimations();

        SwinGame.RefreshScreen();
    }
    /// <summary>
    /// Draws the current state of the game to the screen.
    /// </summary>
    /// <remarks>
    /// What is drawn depends upon the state of the game.
    /// </remarks>
    public static void DrawScreen()
    {
        UtilityFunctions.DrawBackground();

        if (CurrentState == GameState.ViewingMainMenu)
        {
            SwinGame.StopTimer(GameTimer);
            MenuController.DrawMainMenu();
        }
        else if (CurrentState == GameState.ViewingGameMenu)
        {
            SwinGame.StopTimer(GameTimer);
            MenuController.DrawGameMenu();
        }
        else if (CurrentState == GameState.AlteringSettings)
        {
            SwinGame.StopTimer(GameTimer);
            MenuController.DrawSettings();
        }
        else if (CurrentState == GameState.AlterMusics)
        {
            SwinGame.StopTimer(GameTimer);
            MenuController.DrawMusicSettings();
        }
        else if (CurrentState == GameState.Deploying)
        {
            SwinGame.ResetTimer(GameTimer);
            DeploymentController.DrawDeployment();
        }
        else if (CurrentState == GameState.Discovering)
        {
            if (SwinGame.TimerTicks(GameTimer) == 0)
            {
                SwinGame.StartTimer(GameTimer);
            }
            DiscoveryController.DrawDiscovery();
        }
        else if (CurrentState == GameState.EndingGame)
        {
            EndingGameController.DrawEndOfGame();
        }
        else if (CurrentState == GameState.ViewingHighScores)
        {
            HighScoreController.DrawHighScores();
        }

        UtilityFunctions.DrawAnimations();

        SwinGame.RefreshScreen(120);
    }
Exemple #5
0
    /// <summary>
    /// Draws the current state of the game to the screen.
    /// </summary>
    /// <remarks>
    /// What is drawn depends upon the state of the game.
    /// </remarks>
    public static void DrawScreen()
    {
        UtilityFunctions.DrawBackground();

        switch (CurrentState)
        {
        case GameState.ViewingMainMenu:
            MenuController.DrawMainMenu();
            break;

        case GameState.ViewingGameMenu:
            MenuController.DrawGameMenu();
            break;

        case GameState.AlteringSettings:
            MenuController.DrawSettings();
            break;

        // Added Function: Change Music Function
        // Author: Ernest Soo
        case GameState.AlteringMusic:
            MenuController.DrawMusic();
            break;

        // Added Function: Change Background Function // Author: Jacky Ten
        case GameState.AlteringBackground:
            MenuController.DrawBackground();
            break;

        case GameState.Deploying:
            DeploymentController.DrawDeployment();
            break;

        case GameState.Discovering:
            DiscoveryController.DrawDiscovery();
            break;

        case GameState.EndingGame:
            EndingGameController.DrawEndOfGame();
            break;

        case GameState.ViewingHighScores:
            HighScoreController.DrawHighScores();
            break;
        }

        UtilityFunctions.DrawAnimations();

        SwinGame.RefreshScreen();
    }
Exemple #6
0
    /// <summary>
    /// Draws the current state of the game to the screen.
    /// </summary>
    /// <remarks>
    /// What is drawn depends upon the state of the game.
    /// </remarks>
    public static void DrawScreen()
    {
        UtilityFunctions.DrawBackground();

        switch (CurrentState)
        {
        case GameState.ViewingMainMenu:
            MenuController.DrawMainMenu();
            break;

        case GameState.ViewingGameMenu:
            MenuController.DrawGameMenu();
            break;

        case GameState.AlteringSettings:
            MenuController.DrawSettings();
            break;

        case GameState.ChangingMusic:
            MenuController.DrawMusicMenu();
            break;

        case GameState.Deploying:
            DeploymentController.DrawDeployment();
            break;

        case GameState.Discovering:
            DiscoveryController.DrawDiscovery();
            break;

        case GameState.EndingGame:
            EndingGameController.DrawEndOfGame();
            break;

        case GameState.ViewingHighScores:
            HighScoreController.DrawHighScores();
            break;

        case GameState.ShowingHint:
            // ShowingHint state draws the Hints on top of the regular grid
            DiscoveryController.DrawDiscovery();
            DiscoveryController.DrawHint();
            break;
        }

        UtilityFunctions.DrawAnimations();

        SwinGame.RefreshScreen();
    }
Exemple #7
0
    /// <summary>
    /// Draws the current state of the game to the screen.
    /// </summary>
    /// <remarks>
    /// What is drawn depends upon the state of the game.
    /// </remarks>
    public static void DrawScreen()
    {
        if (SwinGame.KeyTyped(KeyCode.vk_m))
        {
            GameResources.Mute();
        }
        if (SwinGame.KeyTyped(KeyCode.vk_p))
        {
            GameResources.Play();
        }
        UtilityFunctions.DrawBackground();

        switch (CurrentState)
        {
        case GameState.ViewingMainMenu:
            MenuController.DrawMainMenu();
            break;

        case GameState.ViewingGameMenu:
            MenuController.DrawGameMenu();
            break;

        case GameState.AlteringSettings:
            MenuController.DrawSettings();
            break;

        case GameState.Deploying:
            DeploymentController.DrawDeployment();
            break;

        case GameState.Discovering:
            DiscoveryController.DrawDiscovery();
            break;

        case GameState.EndingGame:
            EndingGameController.DrawEndOfGame();
            break;

        case GameState.ViewingHighScores:
            HighScoreController.DrawHighScores();
            break;
        }

        UtilityFunctions.DrawAnimations();

        SwinGame.RefreshScreen();
    }
Exemple #8
0
    /// <summary>
    /// Draws the current state of the game to the screen.
    /// </summary>
    /// <remarks>
    /// What is drawn depends upon the state of the game.
    /// </remarks>
    public static void DrawScreen()
    {
        UtilityFunctions.DrawBackground();

        switch (CurrentState)
        {
        case GameState.ViewingMainMenu:
            MenuController.DrawMainMenu();
            break;

        case GameState.ViewingGameMenu:
            MenuController.DrawGameMenu();
            break;

        case GameState.AlteringSettings:
            MenuController.DrawSettings();
            break;

        case GameState.Deploying:
            DeploymentController.DrawDeployment();
            MenuController.DrawCommonMenu();                      // Aerisha Changes/Additions
            break;

        case GameState.Discovering:
            DiscoveryController.DrawDiscovery();
            MenuController.DrawCommonMenu();                      // Aerisha Changes/Additions
            break;

        case GameState.EndingGame:
            EndingGameController.DrawEndOfGame();
            break;

        case GameState.ViewingHighScores:
            HighScoreController.DrawHighScores();
            MenuController.DrawScoresPage();                            // Aerisha Changes/Additions
            break;

        case GameState.ViewingInstructMenu:
            Instructions.DrawInstruct();
            break;
        }

        UtilityFunctions.DrawAnimations();

        SwinGame.RefreshScreen();
    }
Exemple #9
0
    /// <summary>
    ///     ''' Draws the current state of the game to the screen.
    ///     ''' </summary>
    ///     ''' <remarks>
    ///     ''' What is drawn depends upon the state of the game.
    ///     ''' </remarks>
    public static void DrawScreen()
    {
        UtilityFunctions.DrawBackground();

        if (CurrentState == GameState.ViewingMainMenu)
        {
            MenuController.DrawMainMenu();
        }
        else if (CurrentState == GameState.ViewingGameMenu)
        {
            MenuController.DrawGameMenu();
        }
        else if (CurrentState == GameState.AlteringSettings)
        {
            MenuController.DrawSettings();
        }
        else if (CurrentState == GameState.ChangingMusic)          //Recently Added
        {
            MenuController.DrawMusicMenu();
        }
        else if (CurrentState == GameState.Deploying)
        {
            DeploymentController.DrawDeployment();
        }
        else if (CurrentState == GameState.AlteringOption)
        {
            MenuController.DrawOption();              //RECENTLY ADDED
        }
        else if (CurrentState == GameState.Discovering)
        {
            DiscoveryController.DrawDiscovery();
        }
        else if (CurrentState == GameState.EndingGame)
        {
            EndingGameController.DrawEndOfGame();
        }
        else if (CurrentState == GameState.ViewingHighScores)
        {
            HighScoreController.DrawHighScores();
        }

        UtilityFunctions.DrawAnimations();

        SwinGame.RefreshScreen();
    }
Exemple #10
0
    /// <summary>
    /// Draws the current state of the game to the screen.
    /// </summary>
    /// <remarks>
    /// What is drawn depends upon the state of the game.
    /// </remarks>
    public static void DrawScreen()
    {
        UtilityFunctions.DrawBackground();

        switch (CurrentState)
        {
        case GameState.ViewingMainMenu:
            MenuController.DrawMainMenu();
            break;

        case GameState.ViewingGameMenu:
            MenuController.DrawGameMenu();
            break;

        case GameState.AlteringSettings:
            MenuController.DrawSettings();
            break;

        case GameState.Deploying:
            DeploymentController.DrawDeployment();
            break;

        case GameState.Discovering:
            DiscoveryController.DrawDiscovery();
            break;

        case GameState.EndingGame:
            EndingGameController.DrawEndOfGame();
            break;

        case GameState.ViewingHighScores:
            HighScoreController.DrawHighScores();
            break;
        }

        UtilityFunctions.DrawAnimations();

        //Lowered to 30 frames per second to see the splash and explosion animations

        SwinGame.RefreshScreen(60);
    }
    /// <summary>
    /// Draws the current state of the game to the screen.
    /// </summary>
    /// <remarks>
    /// What is drawn depends upon the state of the game.
    /// </remarks>
    public static void DrawScreen()
    {
        UtilityFunctions.DrawBackground();

        switch (CurrentState)
        {
        case GameState.ViewingMainMenu:
            MenuController.DrawMainMenu();
            break;

        case GameState.ViewingGameMenu:
            MenuController.DrawGameMenu();
            break;

        case GameState.AlteringSettings:
            MenuController.DrawSettings();
            break;

        case GameState.Deploying:
            DeploymentController.DrawDeployment();
            break;

        case GameState.Discovering:
            DiscoveryController.DrawDiscovery();
            SwinGame.DrawBitmap(GameResources.GameImage("HomeButton"), HOME_BUTTON_LEFT, TOP_BUTTONS_TOP);
            break;

        case GameState.EndingGame:
            EndingGameController.DrawEndOfGame();
            break;

        case GameState.ViewingHighScores:
            HighScoreController.DrawHighScores();
            break;
        }

        UtilityFunctions.DrawAnimations();

        SwinGame.RefreshScreen();
    }
Exemple #12
0
    /// <summary>
    /// Draws the current state of the game to the screen.
    /// </summary>
    /// <remarks>
    /// What is drawn depends upon the state of the game.
    /// </remarks>
    public void DrawScreen()
    {
        screenController.DrawBackground();

        switch (CurrentState)
        {
        case GameState.ViewingMainMenu:
            _menuController.DrawMainMenu();
            break;

        case GameState.ViewingGameMenu:
            _menuController.DrawGameMenu();
            break;

        case GameState.AlteringSettings:
            _menuController.DrawSettings();
            break;

        case GameState.Deploying:
            _deploymentController.DrawDeployment();
            break;

        case GameState.Discovering:
            _discoveryController.DrawDiscovery();
            break;

        case GameState.EndingGame:
            _endingGameController.DrawEndOfGame();
            break;

        case GameState.ViewingHighScores:
            highScoreController.DrawHighScores();
            break;
        }

        screenController.DrawAnimations();

        SwinGame.RefreshScreen();
    }
Exemple #13
0
    /// <summary>
    /// Draws the current state of the game to the screen.
    /// </summary>
    /// <remarks>
    /// What is drawn depends upon the state of the game.
    /// </remarks>
    public static void DrawScreen()
    {
        UtilityFunctions.DrawBackground();

        switch (CurrentState)
        {
        case GameState.ViewingMainMenu:
            SwinGame.StopTimer(Timer);
            MenuController.DrawMainMenu();
            break;

        case GameState.ViewingInstruction:
            SwinGame.StopTimer(Timer);
            Rules.DrawInstruction();
            break;

        case GameState.ViewingGameMenu:
            SwinGame.StopTimer(Timer);
            MenuController.DrawGameMenu();
            break;

        case GameState.AlteringSettings:
            SwinGame.StopTimer(Timer);
            MenuController.DrawSettings();
            break;

        case GameState.Deploying:
            SwinGame.ResetTimer(Timer);
            DeploymentController.DrawDeployment();
            MenuController.DrawMenuBackButton();
            break;

        case GameState.Discovering:
            if (SwinGame.TimerTicks(Timer) == 0)
            {
                SwinGame.StartTimer(Timer);
            }
            DiscoveryController.DrawDiscovery();
            break;

        case GameState.EndingGame:
            EndingGameController.DrawEndOfGame();
            break;

        case GameState.ViewingHighScores:
            SwinGame.StopTimer(Timer);
            HighScoreController.DrawHighScores();
            break;

        case GameState.AlteringOption:
            SwinGame.StopTimer(Timer);
            MenuController.DrawOption();
            break;

        case GameState.ChangingMusic:
            SwinGame.StopTimer(Timer);
            MenuController.DrawMusicMenu();
            break;

            /*case GameState.changebg:
             *      MenuController.DrawBGOption ();
             *      break;*/
        }

        UtilityFunctions.DrawAnimations();

        SwinGame.RefreshScreen();
    }
Exemple #14
0
    // <summary>
    // Listens for attacks to be completed.
    // </summary>
    // <param name="sender">the game</param>
    // <param name="result">the result of the attack</param>
    // <remarks>
    // Displays a message, plays sound and redraws the screen
    // </remarks>
    private static void AttackCompleted(object sender, AttackResult result)
    {
        bool isHuman;

        isHuman = _theGame.Player == HumanPlayer;

        if (isHuman)
        {
            UtilityFunctions.Message = "You " + result.ToString();
        }
        else
        {
            UtilityFunctions.Message = "The AI " + result.ToString();
        }

        switch (result.Value)
        {
        case var @case when @case == ResultOfAttack.Destroyed:
        {
            PlayHitSequence(result.Row, result.Column, isHuman);
            Audio.PlaySoundEffect(GameResources.GameSound("Sink"));
            break;
        }

        case var case1 when case1 == ResultOfAttack.GameOver:
        {
            PlayHitSequence(result.Row, result.Column, isHuman);
            Audio.PlaySoundEffect(GameResources.GameSound("Sink"));

            while (Audio.SoundEffectPlaying(GameResources.GameSound("Sink")))
            {
                SwinGame.Delay(3);
                SwinGame.RefreshScreen();
                EndingGameController.DrawEndOfGame();        // fixed the delay issue with the audio sound effect when the game ends
            }

            if (HumanPlayer.IsDestroyed)
            {
                Audio.PlaySoundEffect(GameResources.GameSound("Lose"));
            }
            else
            {
                Audio.PlaySoundEffect(GameResources.GameSound("Winner"));
            }
            break;
        }

        case var case2 when case2 == ResultOfAttack.Hit:
        {
            PlayHitSequence(result.Row, result.Column, isHuman);
            break;
        }

        case var case3 when case3 == ResultOfAttack.Miss:
        {
            PlayMissSequence(result.Row, result.Column, isHuman);
            break;
        }

        case var case4 when case4 == ResultOfAttack.ShotAlready:
        {
            Audio.PlaySoundEffect(GameResources.GameSound("Error"));
            break;
        }
        }
    }