Exemplo n.º 1
0
 public void CheckInGameMenuKeys()
 {
     if (input.GetState(input.escapeKey) == InputState.JustPressed)
     {
         //Return to menu!
         gameMusic.stopSound();
         gameMusic       = null;
         core.menuIndex  = 0;
         core.menuOption = 0;
     }
 }
Exemplo n.º 2
0
        public void MenuLoop()
        {
            if (menuMusic == null)
            {
                menuMusic = core.PlaySound(menuLoopSound, true);
            }
            if (input.GetState(input.enterKey) == InputState.JustPressed)
            {
                if (core.menuIndex == (int)MenuIndex.Main) //Main menu
                {
                    if (core.menuOption == 0)
                    {
                        ResetGameState();
                        core.menuIndex = -1;

                        core.PlaySound(startSound);
                        //Stop the menu music and set it to null so it can play again if the menu loop ever gets called again
                        menuMusic.stopSound();
                        menuMusic = null;
                    }
                    else if (core.menuOption == 1)
                    {
                        core.menuIndex  = (int)MenuIndex.HostGame; //Host game menu
                        core.menuOption = 0;
                        core.Connected  = (coreVer, gameVer) => {
                            if (coreVer != core.CoreVersion || gameVer != core.GameVersion)
                            {
                                //TODO: Tell the user the versions don't match
                                core.Disconnect();
                            }
                            else //When connection succeeds, start the game
                            {
                                core.menuIndex = -1;
                            }
                        };
                        //Start listening for incoming connections
                        core.ListenForIncomingConnection();
                    }
                    else if (core.menuOption == 2)
                    {
                        core.menuIndex  = (int)MenuIndex.JoinGame; //Join game menu
                        core.menuOption = 0;
                        //TODO: allow user to input an IP address
                        core.Connected = (coreVer, gameVer) => {
                            if (coreVer != core.CoreVersion || gameVer != core.GameVersion)
                            {
                                //TODO: Tell the user the versions don't match
                                core.Disconnect();
                            }
                            else //When connection succeeds, start the game
                            {
                                core.menuIndex = -1;
                            }
                        };
                        core.Connect(new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 }));
                    }
                    else if (core.menuOption == 3)
                    {
                        core.menuIndex  = (int)MenuIndex.Options; //Options menu
                        core.menuOption = 0;
                    }
                    else if (core.menuOption == 4)
                    {
                        core.menuIndex         = (int)MenuIndex.Credits; //Credits menu
                        core.menuOption        = 0;
                        renderer.creditsScroll = pictureBox1.Height;
                    }
                    else if (core.menuOption == 5)
                    {
                        core.Exit();
                    }
                }
                else if (core.menuIndex == (int)MenuIndex.HostGame) //Host game menu
                {
                    core.menuIndex  = 0;
                    core.menuOption = 1;
                }
                else if (core.menuIndex == (int)MenuIndex.JoinGame) //Join game menu
                {
                    core.menuIndex  = 0;
                    core.menuOption = 2;
                }
                else if (core.menuIndex == (int)MenuIndex.Options) //Options menu
                {
                    core.menuIndex  = 0;
                    core.menuOption = 3;
                }
                else if (core.menuIndex == (int)MenuIndex.Credits) //Credits menu
                {
                    core.menuIndex  = 0;
                    core.menuOption = 4;
                }
            }

            if (input.GetState(input.downArrowKey) == InputState.JustPressed)
            {
                core.menuOption = (core.menuOption + 1) % menuItems[core.menuIndex];
            }
            if (input.GetState(input.upArrowKey) == InputState.JustPressed)
            {
                core.menuOption = core.menuOption == 0 ? menuItems[core.menuIndex] - 1 : core.menuOption - 1;
            }
        }