Example #1
0
 public override void HandleInput(Arcade stateMachine, string input)
 {
     if (input == "1")
     {
         // Unpause and resume gameplay
         stateMachine.SetBool(ParamId.IsPaused, false);
     }
     else if (input == "2")
     {
         // Exit to the start screen
         stateMachine.SetTrigger(ParamId.ExitToStartScreen);
     }
 }
Example #2
0
 public override void HandleInput(Arcade stateMachine, string input)
 {
     if (input == "1")
     {
         // Insert a coin
         int coinsInserted = arcade.GetInt(ParamId.CoinsInserted);
         coinsInserted++;
         stateMachine.SetInt(ParamId.CoinsInserted, coinsInserted);
     }
     else if (input == "2")
     {
         // Stop the state machine
         stateMachine.Stop();
     }
 }
Example #3
0
        public void Draw(Arcade arcade)
        {
            // Do not clear the console if logging is enabled so we
            // can see the internal flow of the state machine
            if (!arcade.LogFlow)
            {
                Console.Clear();
            }

            // Print the title, description, and options
            Print.Log(Title.ToUpper());
            Print.Log("-----------------------");
            if (!string.IsNullOrEmpty(Description))
            {
                Print.Log(Description);
                Print.Log("-----------------------");
            }
            Print.Log("What do you want to do?");
            for (int i = 0; i < Options.Length; i++)
            {
                Print.Log($"{i + 1}) {Options[i]}");
            }
        }
Example #4
0
 public override void HandleInput(Arcade stateMachine, string input)
 {
     if (input == "1")
     {
         // Kill a zombie
         int zombiesKilled = stateMachine.GetInt(ParamId.ZombiesKilled);
         zombiesKilled++;
         stateMachine.SetInt(ParamId.ZombiesKilled, zombiesKilled);
     }
     else if (input == "2")
     {
         // Lose a heart/life
         int hearts = stateMachine.GetInt(ParamId.Hearts);
         hearts--;
         stateMachine.SetInt(ParamId.Hearts, hearts);
     }
     else if (input == "3")
     {
         // Open the pause menu. Remember that we configured this as a Push
         // transition meaning that the game screen retains it state so when
         // we unpause (aka Pop the pause menu
         stateMachine.SetBool(ParamId.IsPaused, true);
     }
 }
Example #5
0
 // On Enter, cache a reference to the state machine casted as an Arcade.
 // We do this so that we have access to the state machine when getting the
 // screen's title, description, or options in case we want to use parameters
 // in them. For example: "{LivesRemaining}/3 Lives"
 protected override void OnEnter(StateMachine <StateId, ParamId, string> stateMachine) =>
 arcade = stateMachine as Arcade;
Example #6
0
 // Every screen must have a means of handling the player input
 public abstract void HandleInput(Arcade arcadeMachine, string input);