Exemple #1
0
 public Choice(Game1.action act, Vector2 pos, string k, Game1.screen destination = Game1.screen.NULL)
 {
     action   = act;
     position = pos;
     key      = k;
 }
Exemple #2
0
        public Game1.action Update(Game1.screen scr)
        {
            Game1.action action       = Game1.action.NULL;
            bool         preventInput = false;

            if (curScreen != scr)
            {
                preventInput = true;
                iconPosition = 0;
                curScreen    = scr;
                switch (scr)
                {
                case Game1.screen.MAIN:
                    title          = "LUNAR LANDER";
                    currentChoices = mainChoices;
                    break;

                case Game1.screen.HIGH_SCORES:
                    title          = "HIGH SCORES";
                    currentChoices = subscreenChoices;
                    break;

                case Game1.screen.CONTROLS:
                    title          = "CONTROL CONFIGURATION";
                    currentChoices = controlChoices;
                    break;

                case Game1.screen.CREDITS:
                    title          = "CREDITS";
                    currentChoices = subscreenChoices;
                    break;

                case Game1.screen.LEVEL1:
                    title          = "";
                    currentChoices = new Choice[0];
                    break;

                case Game1.screen.LEVEL2:
                    title          = "";
                    currentChoices = new Choice[0];
                    break;

                case Game1.screen.QUIT:
                    title          = "ARE YOU SURE YOU WANT TO QUIT?";
                    currentChoices = quitChoices;
                    break;

                case Game1.screen.LOSE:
                    title          = "MISSION FAILED";
                    currentChoices = lossChoices;
                    break;

                case Game1.screen.WIN1:
                    title          = "LEVEL 2";
                    currentChoices = new Choice[0];
                    break;

                case Game1.screen.WIN2:
                    title          = "MISSION COMPLETE";
                    currentChoices = winChoices;
                    break;
                }
            }
            else
            {
                preventInput = false;
            }

            if (!preventInput && !stopFunction)
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                {
                    action = Game1.action.QUIT;
                }
                else if (Keyboard.GetState().IsKeyDown(Keys.Enter))
                {
                    action       = currentChoices[iconPosition].action;
                    stopFunction = true;
                }
                else if (Keyboard.GetState().IsKeyDown(Keys.Down))
                {
                    iconPosition += (iconPosition + 1) > currentChoices.Length - 1 ? 0 : 1;
                    stopFunction  = true;
                }
                else if (Keyboard.GetState().IsKeyDown(Keys.Up))
                {
                    iconPosition -= (iconPosition - 1) < 0 ? 0 : 1;
                    stopFunction  = true;
                }
            }
            if (Keyboard.GetState().GetPressedKeyCount() == 0)
            {
                stopFunction = false;
            }

            return(action);
        }