Exemple #1
0
 private void SubmitButton_Click(object sender, EventArgs e)
 {
     if (!LevelManager.IsPassword(this.Password))
     {
         PasswordStatusLabel.Text = "Invalid password";
         return;
     }
     menuChoice = MenuChoices.Submit;
     this.Close();
 }
        public MultiplayerScreen()
            : base()
        {
            this.RequireDrawFocus = true;

            CursorMapMin       = 0;
            ActiveUnitMinIndex = 0;
            IsFrozen           = false;

            Messenger          = new List <string>();
            Message            = "";
            MessageDraw        = "";
            MessageStartIndex  = 0;
            MessageCursorIndex = 0;
            lastPressedKeys    = new Keys[0];
            Stage            = MenuChoices.None;
            CurrentSelection = MenuChoices.PlayerList;
            ListPlayerType   = new string[5] {
                "Closed", "Open", "Human", "CPU", "Online"
            };
        }
Exemple #3
0
        public void Update(GameTime gametime, ref GameStates states, Level mainMenuLevel)
        {
            var env = mainMenuLevel.Environment;
            if (_mControls.IsBackPressed(false))
                states = GameStates.Exit;
            if (_mControls.IsAPressed(false) || _mControls.IsStartPressed(false))
            {
                if (_mCurrentChoice == MenuChoices.StartGame)
                {
                    states = GameStates.LevelSelection;
                    mainMenuLevel.Reload();
                }
                if (_mCurrentChoice == MenuChoices.Exit)
                    states = GameStates.Exit;
                if (_mCurrentChoice == MenuChoices.Options)
                    states = GameStates.Options;
                if (_mCurrentChoice == MenuChoices.Credits)
                {
                    states = GameStates.Credits;
                    mainMenuLevel.Reload();
                }
                env.GravityDirection = GravityDirections.Down;
            }

            if (env.GravityDirection == GravityDirections.Down)
                _mCurrentChoice = MenuChoices.StartGame;
            if (env.GravityDirection == GravityDirections.Left)
                _mCurrentChoice = MenuChoices.Credits;
            if (env.GravityDirection == GravityDirections.Right)
                _mCurrentChoice = MenuChoices.Options;
            if (env.GravityDirection == GravityDirections.Up)
                _mCurrentChoice = MenuChoices.Exit;
        }
Exemple #4
0
        public Rectangle GetRegion(MenuChoices choice, Texture2D texture)
        {
            Viewport viewport = _mGraphics.GraphicsDevice.Viewport;

            var mSize = new float[2] { viewport.TitleSafeArea.Width / (float)_mGraphics.GraphicsDevice.Viewport.Width, viewport.TitleSafeArea.Height / (float)_mGraphics.GraphicsDevice.Viewport.Height };

            if (choice == MenuChoices.StartGame)
                return new Rectangle(viewport.TitleSafeArea.Center.X - ((int)(texture.Width * mSize[0]) / 2),
                    viewport.TitleSafeArea.Bottom - (int)(texture.Height * mSize[1]), (int)(texture.Width * mSize[0]), (int)(texture.Height * mSize[1]));
            if (choice == MenuChoices.Exit)
                return new Rectangle(viewport.TitleSafeArea.Center.X - ((int)(texture.Width * mSize[0]) / 2),
                    viewport.TitleSafeArea.Top + (int)(_mTitle.Height * mSize[1]), (int)(texture.Width * mSize[0]), (int)(texture.Height * mSize[1]));
            if (choice == MenuChoices.Options)
                return new Rectangle(viewport.TitleSafeArea.Right - ((int)(texture.Width * mSize[0])) - (int)(_mTitle.Height * mSize[1]),
                    viewport.TitleSafeArea.Center.Y + (int)(_mTitle.Height * mSize[1]) / 2 - ((int)(texture.Height * mSize[1]) / 2), (int)(texture.Width * mSize[0]), (int)(texture.Height * mSize[1]));
            if (choice == MenuChoices.Credits)
                return new Rectangle(viewport.TitleSafeArea.Left + (int)(_mTitle.Height * mSize[1]),
                    viewport.TitleSafeArea.Center.Y + (int)(_mTitle.Height * mSize[1]) / 2 - ((int)(texture.Height * mSize[1]) / 2), (int)(texture.Width * mSize[0]), (int)(texture.Height * mSize[1]));
            return new Rectangle();
        }
Exemple #5
0
        static void Main(string[] args)
        {
            MenuChoices nextCommand = MenuChoices.NONE;

            Employee[] employees         = new Employee[50];
            int        numberOfEmployees = 0;
            int        employeeIndex     = 0;

            // Use sentinel loop to begin menu prompts.
            while (nextCommand != MenuChoices.EXIT_PROGRAM)
            {
                string userSelection = "";
                userSelection = getMenuChoice();

                // Prompt the user for a command.
                nextCommand = getSelectionFromMenuChoice(userSelection);

                // Add employee if user selects option 1.
                if (nextCommand == MenuChoices.ADD_EMPLOYEE)
                {
                    Employee newEmployee = getEmployeeInformation();

                    Console.WriteLine();

                    // Add the new employee to the employees array.
                    employees[employeeIndex] = newEmployee;
                    employeeIndex++;
                    numberOfEmployees++;

                    Console.WriteLine();
                }

                // Update employee information if user selects option 2.
                if (nextCommand == MenuChoices.UPDATE_EMPLOYEE)
                {
                    string userInput       = "";
                    int    indexOfEmployee = 0;

                    // Ask user which employee they wish to update.
                    Console.Write("There are currently {0} employess. \n" +
                                  "Which employee do you want to update (0-{0})? ", (numberOfEmployees - 1));
                    userInput       = Console.ReadLine();
                    indexOfEmployee = int.Parse(userInput);

                    // Replace old information with new information.
                    employees[indexOfEmployee] = getEmployeeInformation();
                }

                // Show payroll if user selects option 3.
                if (nextCommand == MenuChoices.PAY_EMPLOYEES)
                {
                    Console.WriteLine("Payroll: ");

                    for (int index = 0; index < numberOfEmployees; index++)
                    {
                        float pay   = 0.0f;
                        float wage  = employees[index].Wage;
                        float hours = employees[index].HoursWorked;

                        // Check that the employee is actually on the payroll.
                        if (employees[index].OnThePayroll == true)
                        {
                            pay = (wage * hours);
                            Console.Write("{0}: ${1}", employees[index].FirstName, pay);

                            Console.WriteLine();
                        }
                    }
                }
            }
        }
Exemple #6
0
        public override void Update(GameTime gameTime)
        {
            keyboard = Keyboard.GetState();

            if (CheckKeystroke(Keys.Enter))
            {
                Sounds.SoundBank.PlayCue("MenuHit");
                switch (menuChoices)
                {
                    case MenuChoices.StartGame:
                        ChangeScreen(menuChoices);
                        break;
                    case MenuChoices.Highscores:
                        ChangeScreen(menuChoices);
                        break;
                    case MenuChoices.Unlockables:
                        ChangeScreen(menuChoices);
                        break;
                    case MenuChoices.Options:
                        ChangeScreen(menuChoices);
                        break;
                    case MenuChoices.Exit:
                        Thread.Sleep(400);
                        game.Exit();
                        break;
                    default:
                        break;
                }
            }

            //User pressed the up key.
            if (CheckKeystroke(Keys.Up) && (int)menuChoices < 4)
            {
                Sounds.SoundBank.PlayCue("MenuChoiceChange");
                SetAllRed();
                menuChoices += 1;
            }
            //User pressed the down key.
            else if (CheckKeystroke(Keys.Down) == true && (int)menuChoices > 0)
            {
                Sounds.SoundBank.PlayCue("MenuChoiceChange");
                SetAllRed();
                menuChoices -= 1;
            }

            switch (menuChoices)
            {
                case MenuChoices.StartGame:
                    startGameChoice = Color.White;
                    break;
                case MenuChoices.Highscores:
                    highscoreChoice = Color.White;
                    break;
                case MenuChoices.Unlockables:
                    unlockablesChoice = Color.White;
                    break;
                case MenuChoices.Options:
                    optionsChoice = Color.White;
                    break;
                case MenuChoices.Exit:
                    exitChoice = Color.White;
                    break;
                default:
                    break;
            }

            prevKeyboard = keyboard;
            base.Update(gameTime);
        }
Exemple #7
0
        public override void Update(GameTime gameTime)
        {
            if (OnlinePlayers.IsHost)
            {
                OnlinePlayers.CheckForNewClient();
            }

            OnlinePlayers.Update();

            if (IsFrozen)
            {
                return;
            }

            switch (Stage)
            {
                #region None

            case MenuChoices.None:
                if (InputHelper.InputConfirmPressed())
                {
                    if (CurrentSelection == MenuChoices.StartGame && OnlinePlayers.IsHost)
                    {
                        PushScreen(NewMap);
                        NewMap.TogglePreview(false);
                        RemoveScreen(this);
                    }
                    else if (CurrentSelection == MenuChoices.JoinGame)
                    {
                        IPInputBox.Open();
                        Stage = CurrentSelection;
                    }
                    else
                    {
                        Stage = CurrentSelection;
                    }
                }
                else if (InputHelper.InputLeftPressed())
                {
                    if (CurrentSelection == MenuChoices.PlayerList)
                    {
                        CurrentSelection = MenuChoices.JoinGame;
                    }
                    else if (CurrentSelection == MenuChoices.Messenger)
                    {
                        CurrentSelection = MenuChoices.StartGame;
                    }
                    else if (CurrentSelection == MenuChoices.StartGame)
                    {
                        CurrentSelection = MenuChoices.Messenger;
                    }
                    else if (CurrentSelection == MenuChoices.ChangeMap || CurrentSelection == MenuChoices.JoinGame)
                    {
                        CurrentSelection = MenuChoices.PlayerList;
                    }
                }
                else if (InputHelper.InputRightPressed())
                {
                    if (CurrentSelection == MenuChoices.PlayerList)
                    {
                        CurrentSelection = MenuChoices.JoinGame;
                    }
                    else if (CurrentSelection == MenuChoices.Messenger)
                    {
                        CurrentSelection = MenuChoices.StartGame;
                    }
                    else if (CurrentSelection == MenuChoices.StartGame)
                    {
                        CurrentSelection = MenuChoices.Messenger;
                    }
                    else if (CurrentSelection == MenuChoices.ChangeMap || CurrentSelection == MenuChoices.JoinGame)
                    {
                        CurrentSelection = MenuChoices.PlayerList;
                    }
                }
                else if (InputHelper.InputUpPressed())
                {
                    if (CurrentSelection == MenuChoices.PlayerList)
                    {
                        CurrentSelection = MenuChoices.Messenger;
                    }
                    else if (CurrentSelection == MenuChoices.Messenger)
                    {
                        CurrentSelection = MenuChoices.PlayerList;
                    }
                    else if (CurrentSelection == MenuChoices.JoinGame)
                    {
                        CurrentSelection = MenuChoices.StartGame;
                    }
                    else if (CurrentSelection == MenuChoices.ChangeMap)
                    {
                        CurrentSelection = MenuChoices.JoinGame;
                    }
                    else if (CurrentSelection == MenuChoices.StartGame)
                    {
                        CurrentSelection = MenuChoices.ChangeMap;
                    }
                }
                else if (InputHelper.InputDownPressed())
                {
                    if (CurrentSelection == MenuChoices.PlayerList)
                    {
                        CurrentSelection = MenuChoices.Messenger;
                    }
                    else if (CurrentSelection == MenuChoices.Messenger)
                    {
                        CurrentSelection = MenuChoices.PlayerList;
                    }
                    else if (CurrentSelection == MenuChoices.JoinGame)
                    {
                        CurrentSelection = MenuChoices.ChangeMap;
                    }
                    else if (CurrentSelection == MenuChoices.ChangeMap)
                    {
                        CurrentSelection = MenuChoices.StartGame;
                    }
                    else if (CurrentSelection == MenuChoices.StartGame)
                    {
                        CurrentSelection = MenuChoices.JoinGame;
                    }
                }
                break;

                #endregion

                #region Messenger

            case MenuChoices.Messenger:
                Keys[] pressedKeys = KeyboardHelper.PlayerState.GetPressedKeys();
                //check if any of the previous update's keys are no longer pressed
                foreach (Keys key in lastPressedKeys)
                {
                    if (!pressedKeys.Contains(key))
                    {
                        switch (key)
                        {
                        case Keys.Enter:
                            OnlinePlayers­.ExecuteAndSend(new DeathmatchLobyScriptHolder.LobyMessageScript(this, Message));
                            Message     = "";
                            MessageDraw = Message;
                            UpdateMessengerCursor();
                            break;

                        case Keys.Escape:
                            Stage = MenuChoices.None;
                            break;

                        case Keys.Right:
                            if (MessageCursorIndex < Message.Length)
                            {
                                MessageCursorIndex++;
                            }
                            UpdateMessengerCursor();
                            break;

                        case Keys.Left:
                            if (MessageCursorIndex > 0)
                            {
                                MessageCursorIndex--;
                            }
                            UpdateMessengerCursor();
                            break;

                        case Keys.Space:
                            Message += " ";
                            break;

                        case Keys.Back:
                            if (MessageCursorIndex > 0)
                            {
                                Message = Message.Remove(--MessageCursorIndex, 1);
                            }
                            break;

                        case Keys.Delete:
                            if (MessageCursorIndex < Message.Length)
                            {
                                Message = Message.Remove(MessageCursorIndex, 1);
                            }
                            break;

                        default:
                            Message    += key;
                            MessageDraw = Message;
                            break;
                        }
                    }
                }
                lastPressedKeys = pressedKeys;
                break;

                #endregion

                #region Join Game

            case MenuChoices.JoinGame:
                if (IPInputBox.IsOpen)
                {
                    IPInputBox.Update(gameTime);
                }
                else
                {
                    if (OnlinePlayers.JoinHost(IPAddress.Loopback))
                    {
                        Messenger.Add("Connection Confirmed");
                    }

                    Stage = MenuChoices.None;
                }
                break;

                #endregion

                #region Change Map

            case MenuChoices.ChangeMap:
                if (InputHelper.InputConfirmPressed())
                {
                    NewMap.BattleMapPath = ListMap[CursorMap].Name;
                    MaxNumberOfPlayers   = ListMap[CursorMap].MaxNumberOfPlayers;
                    MapSizeX             = ListMap[CursorMap].MapSize.X;
                    MapSizeY             = ListMap[CursorMap].MapSize.Y;

                    if (NewMap.ListPlayer.Count > MaxNumberOfPlayers)
                    {
                        NewMap.ListPlayer.RemoveRange(MaxNumberOfPlayers, NewMap.ListPlayer.Count - MaxNumberOfPlayers);
                    }
                    else
                    {
                        while (NewMap.ListPlayer.Count < MaxNumberOfPlayers)
                        {
                            Player NewPlayer = new Player("Player " + (NewMap.ListPlayer.Count + 1), "Open", false, true, NewMap.ListPlayer.Count, Color.Blue);
                            NewPlayer.IsAlive = false;
                            NewMap.ListPlayer.Add(NewPlayer);
                        }
                    }

                    for (int P = 0; P < NewMap.ListPlayer.Count; P++)
                    {
                        NewMap.ListPlayer[P].ListSpawnPoint.Clear();
                        for (int S = 0; S < ListMap[CursorMap].ListSpawns.Count; S++)
                        {
                            if (Convert.ToInt32(ListMap[CursorMap].ListSpawns[S].Tag) == P + 1)
                            {
                                NewMap.ListPlayer[P].ListSpawnPoint.Add(ListMap[CursorMap].ListSpawns[S]);
                            }
                        }
                    }

                    Stage = MenuChoices.None;
                }
                else if (InputHelper.InputCancelPressed())
                {
                    Stage = MenuChoices.None;
                }
                else if (InputHelper.InputUpPressed())
                {
                    CursorMap--;
                    if (CursorMap < 0)
                    {
                        CursorMap = ListMap.Count - 1;
                    }
                }
                else if (InputHelper.InputDownPressed())
                {
                    CursorMap++;
                    if (CursorMap >= ListMap.Count)
                    {
                        CursorMap = 0;
                    }
                }
                break;

                #endregion

                #region Player List

            case MenuChoices.PlayerList:
                if (InputHelper.InputConfirmPressed())
                {
                    if ((OnlinePlayers.IsHost && NewMap.ListPlayer[ActivePlayerIndex].OnlinePlayerType != "Online") ||
                        (NewMap.ListPlayer[ActivePlayerIndex].IsOnline && NewMap.ListPlayer[ActivePlayerIndex].OnlinePlayerType == "Open"))
                    {
                        Stage            = MenuChoices.PlayerEdit;
                        CurrentSelection = MenuChoices.PlayerType;
                    }
                }
                else if (InputHelper.InputCancelPressed())
                {
                    Stage            = MenuChoices.None;
                    CurrentSelection = MenuChoices.PlayerList;
                }
                else if (InputHelper.InputUpPressed())
                {
                    ActivePlayerIndex--;
                    if (ActivePlayerIndex < 0)
                    {
                        ActivePlayerIndex = NewMap.ListPlayer.Count - 1;
                    }
                }
                else if (InputHelper.InputDownPressed())
                {
                    ActivePlayerIndex++;
                    if (ActivePlayerIndex >= NewMap.ListPlayer.Count)
                    {
                        ActivePlayerIndex = 0;
                    }
                }
                break;

                #endregion

                #region Player Edit

            case MenuChoices.PlayerEdit:
                if (InputHelper.InputConfirmPressed())
                {
                    Stage = CurrentSelection;
                    PlayerChoiceSubMenuIndex = 0;
                }
                else if (InputHelper.InputCancelPressed())
                {
                    Stage = MenuChoices.PlayerList;
                }
                else if (InputHelper.InputLeftPressed())
                {
                    if (CurrentSelection == MenuChoices.PlayerType)
                    {
                        CurrentSelection = MenuChoices.SquadSelection;
                    }
                    else
                    {
                        CurrentSelection--;
                    }
                }
                else if (InputHelper.InputRightPressed())
                {
                    if (CurrentSelection == MenuChoices.SquadSelection)
                    {
                        CurrentSelection = MenuChoices.PlayerType;
                    }
                    else
                    {
                        CurrentSelection++;
                    }
                }
                break;

                #endregion

                #region Player Type

            case MenuChoices.PlayerType:
                if (InputHelper.InputConfirmPressed())
                {
                    if (NewMap.ListPlayer[ActivePlayerIndex].OnlinePlayerType != ListPlayerType[PlayerChoiceSubMenuIndex])
                    {
                        NewMap.ListPlayer[ActivePlayerIndex].OnlinePlayerType = ListPlayerType[PlayerChoiceSubMenuIndex];
                        if (NewMap.ListPlayer[ActivePlayerIndex].OnlinePlayerType == "Human")
                        {
                            NewMap.ListPlayer[ActivePlayerIndex].IsPlayerControlled = true;
                        }

                        if (NewMap.ListPlayer[ActivePlayerIndex].OnlinePlayerType == "Online")
                        {
                            NewMap.ListPlayer[ActivePlayerIndex].IsOnline = true;
                        }
                        else
                        {
                            NewMap.ListPlayer[ActivePlayerIndex].IsOnline = false;
                        }

                        Stage = MenuChoices.PlayerEdit;
                    }
                }
                else if (InputHelper.InputCancelPressed())
                {
                    Stage = MenuChoices.PlayerEdit;
                }
                else if (InputHelper.InputUpPressed())
                {
                    PlayerChoiceSubMenuIndex--;
                    if (PlayerChoiceSubMenuIndex < 0)
                    {
                        PlayerChoiceSubMenuIndex = 3;
                    }
                }
                else if (InputHelper.InputDownPressed())
                {
                    PlayerChoiceSubMenuIndex++;
                    if (PlayerChoiceSubMenuIndex > 3)
                    {
                        PlayerChoiceSubMenuIndex = 0;
                    }
                }
                break;

                #endregion

                #region Squad Selection

            case MenuChoices.SquadSelection:
                if (InputHelper.InputConfirmPressed())
                {
                    Stage              = MenuChoices.UnitSelection;
                    ActiveUnitIndex    = 0;
                    ActiveUnitMinIndex = 0;
                }
                else if (InputHelper.InputCancelPressed())
                {
                    Stage = MenuChoices.PlayerEdit;
                }
                else if (InputHelper.InputUpPressed())
                {
                    ActiveSquadIndex--;
                    if (ActiveSquadIndex < 0)
                    {
                        ActiveSquadIndex = NewMap.ListPlayer[ActivePlayerIndex].ListSpawnPoint.Count - 1;
                    }
                }
                else if (InputHelper.InputDownPressed())
                {
                    ActiveSquadIndex++;
                    if (ActiveSquadIndex >= NewMap.ListPlayer[ActivePlayerIndex].ListSpawnPoint.Count)
                    {
                        ActiveSquadIndex = 0;
                    }
                }
                else if (InputHelper.InputLeftPressed())
                {
                    PlayerChoiceSubMenuIndex--;
                    if (PlayerChoiceSubMenuIndex < 0)
                    {
                        PlayerChoiceSubMenuIndex = 2;
                    }
                }
                else if (InputHelper.InputRightPressed())
                {
                    PlayerChoiceSubMenuIndex++;
                    if (PlayerChoiceSubMenuIndex > 2)
                    {
                        PlayerChoiceSubMenuIndex = 0;
                    }
                }
                break;

                #endregion

                #region Unit Selection

            case MenuChoices.UnitSelection:
                if (InputHelper.InputConfirmPressed())
                {
                    Stage               = MenuChoices.PilotSelection;
                    ActivePilotIndex    = 0;
                    ActivePilotMinIndex = 0;
                }
                else if (InputHelper.InputCancelPressed())
                {
                    Stage = MenuChoices.SquadSelection;
                }
                else if (InputHelper.InputUpPressed())
                {
                    ActiveUnitIndex--;
                    if (ActiveUnitIndex < 0)
                    {
                        ActiveUnitIndex    = ArrayUnit.Length - 1;
                        ActiveUnitMinIndex = Math.Max(0, ArrayUnit.Length - MaxItemToDraw);
                    }
                    else if (ActiveUnitIndex < ActiveUnitMinIndex)
                    {
                        ActiveUnitMinIndex = ActiveUnitIndex;
                    }
                }
                else if (InputHelper.InputDownPressed())
                {
                    ActiveUnitIndex++;
                    if (ActiveUnitIndex >= ArrayUnit.Length)
                    {
                        ActiveUnitIndex    = 0;
                        ActiveUnitMinIndex = 0;
                    }
                    else if (ActiveUnitIndex >= MaxItemToDraw + ActiveUnitMinIndex)
                    {
                        ActiveUnitMinIndex = ActiveUnitIndex - MaxItemToDraw + 1;
                    }
                }
                break;

                #endregion

                #region Pilot Selection

            case MenuChoices.PilotSelection:

                if (InputHelper.InputConfirmPressed())
                {
                    Stage = MenuChoices.SquadSelection;
                    if (PlayerChoiceSubMenuIndex == 0)
                    {
                        NewMap.ListPlayer[ActivePlayerIndex].ListSpawnPoint[ActiveSquadIndex].LeaderPilot    = ListPilot[ActivePilotIndex];
                        NewMap.ListPlayer[ActivePlayerIndex].ListSpawnPoint[ActiveSquadIndex].LeaderTypeName = ArrayUnit[ActiveUnitIndex].Item1;
                        NewMap.ListPlayer[ActivePlayerIndex].ListSpawnPoint[ActiveSquadIndex].LeaderName     = ArrayUnit[ActiveUnitIndex].Item2;
                    }
                    else if (PlayerChoiceSubMenuIndex == 1)
                    {
                        NewMap.ListPlayer[ActivePlayerIndex].ListSpawnPoint[ActiveSquadIndex].WingmanAPilot    = ListPilot[ActivePilotIndex];
                        NewMap.ListPlayer[ActivePlayerIndex].ListSpawnPoint[ActiveSquadIndex].WingmanATypeName = ArrayUnit[ActiveUnitIndex].Item1;
                        NewMap.ListPlayer[ActivePlayerIndex].ListSpawnPoint[ActiveSquadIndex].WingmanAName     = ArrayUnit[ActiveUnitIndex].Item2;
                    }
                    else if (PlayerChoiceSubMenuIndex == 2)
                    {
                        NewMap.ListPlayer[ActivePlayerIndex].ListSpawnPoint[ActiveSquadIndex].WingmanBPilot    = ListPilot[ActivePilotIndex];
                        NewMap.ListPlayer[ActivePlayerIndex].ListSpawnPoint[ActiveSquadIndex].WingmanBTypeName = ArrayUnit[ActiveUnitIndex].Item1;
                        NewMap.ListPlayer[ActivePlayerIndex].ListSpawnPoint[ActiveSquadIndex].WingmanBName     = ArrayUnit[ActiveUnitIndex].Item2;
                    }
                }
                else if (InputHelper.InputCancelPressed())
                {
                    Stage = MenuChoices.UnitSelection;
                }
                else if (InputHelper.InputUpPressed())
                {
                    ActivePilotIndex--;
                    if (ActivePilotIndex < 0)
                    {
                        ActivePilotIndex    = ListPilot.Count - 1;
                        ActivePilotMinIndex = Math.Max(0, ActivePilotIndex - ListPilot.Count);
                    }
                    else if (ActivePilotIndex < ActivePilotMinIndex)
                    {
                        ActivePilotMinIndex = ActivePilotIndex;
                    }
                }
                else if (InputHelper.InputDownPressed())
                {
                    ActivePilotIndex++;
                    if (ActivePilotIndex >= ListPilot.Count)
                    {
                        ActivePilotIndex    = 0;
                        ActivePilotMinIndex = 0;
                    }
                    else if (ActivePilotIndex >= MaxItemToDraw + ActivePilotMinIndex)
                    {
                        ActivePilotMinIndex = ActivePilotIndex - MaxItemToDraw + 1;
                    }
                }
                break;

                #endregion
            }

            if (KeyboardHelper.KeyPressed(Keys.Escape))
            {
                if (Stage == MenuChoices.None)
                {
                    RemoveScreen(this);
                }
                else
                {
                    Stage = MenuChoices.None;
                }
            }
        }
Exemple #8
0
        public Rectangle GetRegion(MenuChoices choice, Texture2D texture)
        {
            Viewport viewport = _mGraphics.GraphicsDevice.Viewport;

            var mSize = new float[2] { viewport.TitleSafeArea.Width / (float)_mGraphics.GraphicsDevice.Viewport.Width, viewport.TitleSafeArea.Height / (float)_mGraphics.GraphicsDevice.Viewport.Height };

            if (choice == MenuChoices.Mute)
                return new Rectangle(viewport.TitleSafeArea.Center.X - ((int)(texture.Width * mSize[0]) / 2) - ((int)(_mMute.Width * mSize[0]) / 2),
                    viewport.TitleSafeArea.Center.Y - (int)(texture.Height * mSize[1]), (int)(texture.Width * mSize[0]), (int)(texture.Height * mSize[1]));
            if (choice == MenuChoices.Back)
                return new Rectangle(viewport.TitleSafeArea.Center.X - ((int)(texture.Width * mSize[0]) / 2),
                    viewport.TitleSafeArea.Center.Y + (int)(texture.Height * mSize[1]), (int)(texture.Width * mSize[0]), (int)(texture.Height * mSize[1]));
            return new Rectangle();
        }
        /// <summary>
        /// Update process of this screen.  Responds to player input to go back to the options screen.
        /// </summary>
        /// <param name="gametime">Current gameTime</param>
        /// <param name="states">Current state of the game</param>
        public void Update(GameTime gametime, ref GameStates states)
        {
            if (mControls.isBackPressed(false))
                states = GameStates.Options;
            if (mControls.isAPressed(false) || mControls.isStartPressed(false))
            {
                if (mCurrentChoice == MenuChoices.Back)
                {
                    states = GameStates.Options;
                }
                if (mCurrentChoice == MenuChoices.Mute)
                {
                    mMuted = !mMuted;
                }
            }
            if (mControls.isBPressed(false) || mControls.isBackPressed(false))
                states = GameStates.Options;

            if (mMuted)
            {
                GameSound.volume = GameSound.menuMusic_title.Volume = 0.0f;
            }
            else
            {
                GameSound.volume = GameSound.menuMusic_title.Volume = 1.0f;
            }

            if (mControls.isUpPressed(false))
            {
                if (mCurrentChoice != MenuChoices.Mute)
                {
                    GameSound.menuSound_rollover.Play(GameSound.volume, 0.0f, 0.0f);
                    mCurrentChoice = MenuChoices.Mute;
                }

            }

            if (mControls.isDownPressed(false))
            {
                if (mCurrentChoice != MenuChoices.Back)
                {
                    GameSound.menuSound_rollover.Play(GameSound.volume, 0.0f, 0.0f);
                    mCurrentChoice = MenuChoices.Back;
                }

            }
        }
Exemple #10
0
        public override void Update(GameTime gameTime)
        {
            switch (Stage)
            {
                #region None

            case MenuChoices.None:
                if (InputHelper.InputUpPressed())
                {
                    if (ActiveSquadIndex > 0)
                    {
                        ActiveSquadIndex--;
                    }
                }
                else if (InputHelper.InputDownPressed())
                {
                    if (ActiveSquadIndex < ItemPerPage && ActiveSquadIndex + 1 + (PageCurrent - 1) * ItemPerPage < ListPresentSquad.Count + 1)
                    {
                        ActiveSquadIndex++;
                    }
                }
                else if (InputHelper.InputLeftPressed())
                {
                    if (PageCurrent > 1)
                    {
                        PageCurrent--;
                    }
                }
                else if (InputHelper.InputRightPressed())
                {
                    if (PageCurrent * 8 < ListPresentSquad.Count)
                    {
                        PageCurrent++;
                    }
                }
                else if (InputHelper.InputConfirmPressed())
                {
                    if (ActiveSquadIndex + (PageCurrent - 1) * ItemPerPage == ListPresentSquad.Count)
                    {
                        Squad NewSquad = new Squad("New Squad");
                        NewSquad.TeamTags.AddTag("Present");
                        NewSquad.IsPlayerControlled = true;
                        PlayerRoster.TeamSquads.Add(NewSquad);
                        ListPresentSquad = PlayerRoster.TeamSquads.GetPresent();
                        PageMax          = (int)Math.Ceiling((ListPresentSquad.Count + 1) / (float)ItemPerPage);
                    }
                    else
                    {
                        ActiveSquad = ListPresentSquad[ActiveSquadIndex + (PageCurrent - 1) * ItemPerPage];
                        Stage       = MenuChoices.SquadSelected;
                        MenuChoice  = MenuChoices.LeaderStats;

                        ActiveUnitMinIndex = 0;
                        ActiveUnitIndex    = 0;
                    }
                }
                else if (InputHelper.InputCancelPressed())
                {
                    RemoveScreen(this);
                }
                break;

                #endregion

                #region Squad Selected

            case MenuChoices.SquadSelected:

                if (InputHelper.InputUpPressed())
                {
                    if (MenuChoice > MenuChoices.LeaderStats)
                    {
                        MenuChoice--;
                    }
                }
                else if (InputHelper.InputDownPressed())
                {
                    if (MenuChoice < MenuChoices.DisbandSquad)
                    {
                        MenuChoice++;
                    }
                }
                else if (InputHelper.InputConfirmPressed())
                {
                    Stage = MenuChoice;
                    switch (MenuChoice)
                    {
                    case MenuChoices.LeaderStats:

                        break;

                    case MenuChoices.WingmanAStats:

                        break;

                    case MenuChoices.WingmanBStats:

                        break;

                    case MenuChoices.RenameSquad:

                        break;

                    case MenuChoices.SetLeader:

                        break;

                    case MenuChoices.SetWingmanA:

                        break;

                    case MenuChoices.SetWingmanB:

                        break;

                    case MenuChoices.DisbandSquad:

                        break;
                    }
                }
                else if (InputHelper.InputCancelPressed())
                {
                    Stage = MenuChoices.None;
                }
                break;

                #endregion

                #region Set Leader

            case MenuChoices.SetLeader:
                if (InputHelper.InputConfirmPressed())
                {
                    Stage = MenuChoices.SquadSelected;

                    Unit OldLeader = ActiveSquad.CurrentLeader;
                    if (OldLeader != null)
                    {
                        PlayerRoster.TeamUnits.Add(OldLeader);
                        ListPresentUnit = PlayerRoster.TeamUnits.GetPresent();
                    }

                    Unit NewLeader = ListPresentUnit[ActiveUnitIndex];
                    PlayerRoster.TeamUnits.Remove(NewLeader);
                    ListPresentUnit = PlayerRoster.TeamUnits.GetPresent();

                    ActiveSquad.SetNewLeader(NewLeader);
                }
                else
                {
                    UpdateUnitSelection();
                }
                break;

            case MenuChoices.SetWingmanA:
                if (InputHelper.InputConfirmPressed())
                {
                    Stage = MenuChoices.SquadSelected;

                    Unit OldWingmanA = ActiveSquad.CurrentWingmanA;
                    if (OldWingmanA != null)
                    {
                        PlayerRoster.TeamUnits.Add(OldWingmanA);
                        ListPresentUnit = PlayerRoster.TeamUnits.GetPresent();
                    }

                    Unit NewWingmanA = ListPresentUnit[ActiveUnitIndex];
                    PlayerRoster.TeamUnits.Remove(NewWingmanA);
                    ListPresentUnit = PlayerRoster.TeamUnits.GetPresent();

                    ActiveSquad.SetNewWingmanA(NewWingmanA);
                }
                else
                {
                    UpdateUnitSelection();
                }
                break;

            case MenuChoices.SetWingmanB:
                if (InputHelper.InputConfirmPressed())
                {
                    Stage = MenuChoices.SquadSelected;

                    Unit OldWingmanB = ActiveSquad.CurrentWingmanB;
                    if (OldWingmanB != null)
                    {
                        PlayerRoster.TeamUnits.Add(OldWingmanB);
                        ListPresentUnit = PlayerRoster.TeamUnits.GetPresent();
                    }

                    Unit NewWingmanB = ListPresentUnit[ActiveUnitIndex];
                    PlayerRoster.TeamUnits.Remove(NewWingmanB);
                    ListPresentUnit = PlayerRoster.TeamUnits.GetPresent();

                    ActiveSquad.SetNewWingmanB(NewWingmanB);
                }
                else
                {
                    UpdateUnitSelection();
                }
                break;

                #endregion

            default:
                if (InputHelper.InputCancelPressed())
                {
                    Stage = MenuChoices.None;
                }
                break;
            }
        }
Exemple #11
0
        public void Update(GameTime gametime, ref GameStates states, Level mainMenuLevel)
        {
            var env = mainMenuLevel.Environment;
            if (_mControls.IsBackPressed(false) || _mControls.IsBPressed(false))
                states = GameStates.MainMenu;

            if (_mControls.IsAPressed(false) || _mControls.IsStartPressed(false))
            {
                if (_mCurrentChoice == MenuChoices.Volume)
                {
                    states = GameStates.SoundOptions;
                    mainMenuLevel.Reload();
                }
                if (_mCurrentChoice == MenuChoices.Controls)
                {
                    states = GameStates.Controls;
                    mainMenuLevel.Reload();
                }
                if (_mCurrentChoice == MenuChoices.Reset)
                {
                    states = GameStates.ResetConfirm;
                    mainMenuLevel.Reload();
                }
                if (_mCurrentChoice == MenuChoices.Back)
                    states = GameStates.MainMenu;

                env.GravityDirection = GravityDirections.Down;
            }

            if (env.GravityDirection == GravityDirections.Down)
                _mCurrentChoice = MenuChoices.Controls;
            if (env.GravityDirection == GravityDirections.Left)
                _mCurrentChoice = MenuChoices.Reset;
            if (env.GravityDirection == GravityDirections.Right)
                _mCurrentChoice = MenuChoices.Volume;
            if (env.GravityDirection == GravityDirections.Up)
                _mCurrentChoice = MenuChoices.Back;
        }
Exemple #12
0
 private void RestartButton_Click(object sender, EventArgs e)
 {
     menuChoice = MenuChoices.Restart;
     this.Close();
 }
Exemple #13
0
 private void Button_Cancel_Click(object sender, EventArgs e)
 {
     menuChoice = MenuChoices.Cancel;
     this.Close();
 }
Exemple #14
0
        public Rectangle GetRegion(MenuChoices choice, Texture2D texture)
        {
            Viewport viewport = mGraphics.GraphicsDevice.Viewport;

            float[] mSize = new float[2] { (float)mGraphics.GraphicsDevice.Viewport.TitleSafeArea.Width / (float)mGraphics.GraphicsDevice.Viewport.Width, (float)mGraphics.GraphicsDevice.Viewport.TitleSafeArea.Height / (float)mGraphics.GraphicsDevice.Viewport.Height };

            if (choice == MenuChoices.Controls)
                return new Rectangle(viewport.TitleSafeArea.Center.X - ((int)(texture.Width * mSize[0]) / 2),
                    viewport.TitleSafeArea.Bottom - (int)(texture.Height * mSize[1]), (int)(texture.Width * mSize[0]), (int)(texture.Height * mSize[1]));
            if (choice == MenuChoices.Back)
                return new Rectangle(viewport.TitleSafeArea.Center.X - ((int)(texture.Width * mSize[0]) / 2),
                    viewport.TitleSafeArea.Top + (int)(mTitle.Height * mSize[1]), (int)(texture.Width * mSize[0]), (int)(texture.Height * mSize[1]));
            if (choice == MenuChoices.Volume)
                return new Rectangle(viewport.TitleSafeArea.Right - ((int)(texture.Width * mSize[0])) - (int)(mTitle.Height * mSize[1]),
                    viewport.TitleSafeArea.Center.Y + (int)(mTitle.Height * mSize[1]) / 2 - ((int)(texture.Height * mSize[1]) / 2), (int)(texture.Width * mSize[0]), (int)(texture.Height * mSize[1]));
            if (choice == MenuChoices.Reset)
                return new Rectangle(viewport.TitleSafeArea.Left + (int)(mTitle.Height * mSize[1]),
                    viewport.TitleSafeArea.Center.Y + (int)(mTitle.Height * mSize[1]) / 2 - ((int)(texture.Height * mSize[1]) / 2), (int)(texture.Width * mSize[0]), (int)(texture.Height * mSize[1]));
            return new Rectangle();
        }
Exemple #15
0
        public void ShowMenu()
        {
            int amountOfWithdrawnsLeft = 5;

            while (true)
            {
                Console.Clear();
                int index = 0;
                Console.WriteLine("E-ATM\n");

                foreach (string str in Enum.GetNames(typeof(MenuChoices)))
                {
                    index++;

                    Console.WriteLine(index + ": " + str);
                }

                Console.WriteLine("\nAnge ditt val : 1-3 :\n");
                string choice = Console.ReadLine();

/*                int intChoice;
 *                  if (!int.TryParse(choice, out intChoice))
 *              {
 *
 *                  Console.WriteLine("Valet ska anges i siffervärde, möjliga val 1-2-3.");
 *                  Console.WriteLine("Tryck valfritt knapp får att gå vidare...");
 *                  Console.ReadKey();
 *              }
 *              else
 *              { */// testar validering, komentera bort hit om det inte funkar
                MenuChoices MenuChoice = (MenuChoices)Enum.Parse(typeof(MenuChoices), choice);

                switch (MenuChoice)
                {
                case MenuChoices.UTTAG:
                    Console.WriteLine("UTTAG");

                    Console.WriteLine("Ange det beloppet du vill ta ut!");
                    double money    = Convert.ToDouble(Console.ReadLine());
                    bool   withdraw = bankClass.Withdrawn(money);
                    if (withdraw && amountOfWithdrawnsLeft > 0)
                    {
                        amountOfWithdrawnsLeft--;
                        Console.WriteLine($"Du tog ut {money} kr! Ditt nya belopp är {bankClass.amountOfExistingMoney}\nDu har {amountOfWithdrawnsLeft} uttag kvar");
                    }
                    else if (amountOfWithdrawnsLeft == 0)
                    {
                        Console.WriteLine("Du har överskridit antalet uttag!");
                    }
                    else
                    {
                        Console.WriteLine("Du har skrivit in ett ogiltigt belopp!");
                    }

                    Console.ReadKey();

                    break;

                case MenuChoices.TRANSAKTIONSHISTORIK:
                    Console.WriteLine("TRANSAKTIONSHISTORIK");
                    Console.WriteLine("Tryck valfritt knapp får att gå vidare...");
                    Console.ReadKey();
                    break;

                case MenuChoices.INSÄTTNING:
                    Console.WriteLine("Var god och ange insättningsbeloppet:");
                    double amountOfMoney2 = double.Parse(Console.ReadLine());
                    double newBalance     = bankClass.Deposit(amountOfMoney2);
                    Console.WriteLine($"Ditt nya belopp: {newBalance}");
                    Console.ReadKey();
                    break;

                case MenuChoices.AVSLUTA:
                    Console.WriteLine("LOGGA UT");
                    Environment.Exit(0);
                    break;

                default:
                    Console.WriteLine("Felaktig val, försök igen.");
                    Console.WriteLine("Tryck valfritt knapp får att gå vidare...");
                    Console.ReadKey();
                    break;
                }
                // }
            }
        }
 public OptionMenu()
     : base()
 {
     MenuChoice = 0;
 }
Exemple #17
0
        private void TitleScreenEvent(object obj, EventArgs e)
        {
            // Depending on the choice in TitleScreen, change screen.
            if (menuChoice == MenuChoices.StartGame)
                mCurrentScreen = mInGameScreen;

            else if (menuChoice == MenuChoices.Highscores)
                mCurrentScreen = new HighscoreScreen(this.Content, new EventHandler(HighscoreScreenEvent), this);

            else if (menuChoice == MenuChoices.Unlockables)
                mCurrentScreen = new UnlockablesScreen(this.Content, new EventHandler(UnlockablesScreenEvent), this);

            else if (menuChoice == MenuChoices.Options)
                mCurrentScreen = mOptionsScreen;

            menuChoice = MenuChoices.Empty;
        }
Exemple #18
0
        static void Main(string[] args)
        {
            MenuChoices nextCommand    = MenuChoices.NONE;
            BankAccount theBankAccount = new BankAccount();

            while (theBankAccount.Balance < 0)
            {
                try
                {
                    theBankAccount.theBalance = setInitialBalance();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine();
                }
            }

            Console.WriteLine("NEW BALANCE: " + theBankAccount.Balance + "\n");

            while (theBankAccount.InterestRate < 0)
            {
                try
                {
                    theBankAccount.InterestRate = setInitialInterestRate();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine();
                }
            }

            Console.WriteLine();

            while (nextCommand != MenuChoices.EXIT_PROGRAM)
            {
                // I chose string as the data type because it works best with prompting user input
                string userSelection = "";
                userSelection = getMenuChoice();

                // Prompt the use for a command
                nextCommand = getSelectionFromMenuChoice(userSelection);

                // Add deposit amount to the balance if user selects choice 1
                if (nextCommand == MenuChoices.DEPOSIT)
                {
                    theBankAccount.theBalance += Deposit();

                    Console.WriteLine();

                    // Display the new balance
                    Console.WriteLine("NEW BALANCE: " + theBankAccount.Balance + "\n");
                }
                // Subtract withdrawal amount from the balance if user selects choice 2
                if (nextCommand == MenuChoices.WITHDRAW)
                {
                    theBankAccount.theBalance = Withdrawal(theBankAccount.Balance);

                    Console.WriteLine();

                    // Display the new balance
                    Console.WriteLine("NEW BALANCE: " + theBankAccount.Balance + "\n");
                }

                if (nextCommand == MenuChoices.APPLY_INTEREST)
                {
                    theBankAccount.theBalance = ApplyInterest(theBankAccount.Balance, theBankAccount.InterestRate);

                    // Display the new balance
                    Console.WriteLine("NEW BALANCE: " + theBankAccount.Balance + "\n");
                }
            }
        }
Exemple #19
0
 public void SetTitleChoice(MenuChoices choice)
 {
     menuChoice = choice;
 }
Exemple #20
0
        /// <summary>
        /// Update process of this screen.  Responds to player input to go back to the options screen.
        /// </summary>
        /// <param name="gametime">Current gameTime</param>
        /// <param name="states">Current state of the game</param>
        public void Update(GameTime gametime, ref GameStates states)
        {
            if (_mControls.IsBackPressed(false))
                states = GameStates.Options;
            if (_mControls.IsAPressed(false) || _mControls.IsStartPressed(false))
            {
                if (_mCurrentChoice == MenuChoices.Back)
                {
                    states = GameStates.Options;
                }
                if (_mCurrentChoice == MenuChoices.Mute)
                {
                    _mMuted = !_mMuted;
                }
            }
            if (_mControls.IsBPressed(false) || _mControls.IsBackPressed(false))
                states = GameStates.Options;

            if (_mMuted)
            {
                GameSound.Volume = GameSound.MenuMusicTitle.Volume = 0.0f;
            }
            else
            {
                GameSound.Volume = GameSound.MenuMusicTitle.Volume = 1.0f;
            }

            if (_mControls.IsUpPressed(false))
            {
                if (_mCurrentChoice != MenuChoices.Mute)
                {
                    GameSound.MenuSoundRollover.Play(GameSound.Volume, 0.0f, 0.0f);
                    _mCurrentChoice = MenuChoices.Mute;
                }

            }

            if (_mControls.IsDownPressed(false))
            {
                if (_mCurrentChoice != MenuChoices.Back)
                {
                    GameSound.MenuSoundRollover.Play(GameSound.Volume, 0.0f, 0.0f);
                    _mCurrentChoice = MenuChoices.Back;
                }

            }
        }
Exemple #21
0
 private void ChangeScreen(MenuChoices menu)
 {
     game.SetTitleChoice(menu);
     screenEvent.Invoke(this, new EventArgs());
     Thread.Sleep(150);
 }