示例#1
0
 public void ContinueGame()
 {
     ButtonRepeat.Stop();
     ButtonDelay.Stop();
     state = GameState.SimulationState;
     RaiseMessageEvent(new LogicMessage(LogicMessage.MessageType.GameMessage));
 }
示例#2
0
 /// <summary>
 /// Checks the input mode.
 /// TODO: refactor the Menu logic to a menuLogic class or use a partial class definition as this file seems to become messy
 /// </summary>
 void CheckInputMode(InputTranslator translator)
 {
     if (rawInput)
     {
         translator.Mode = InputTranslator.InputMode.RAW;
         ButtonRepeat.Stop();
         ButtonDelay.Stop();
     }
 }
示例#3
0
        public void StartGame(MatchSettings settings, bool isMultiplayer = false, int localPlayerId = -1)
        {
            ButtonRepeat.Stop();
            ButtonDelay.Stop();
            // Go back to main menu so it will show when the user enters the menu later
            MenuGoBack();
            // Select the "Continue" entry
            activeMenu.Peek().SelectIndex(0);

            state = GameState.SimulationState;
            Ballz.The().LockMouse = true;
            if (Game.Match != null)
            {
                Game.Match.Dispose();
            }

            Game.Match = settings.GameMode.StartSession(Game, settings, isMultiplayer, localPlayerId);
            Game.Match.Start();
            RaiseMessageEvent(new LogicMessage(LogicMessage.MessageType.GameMessage));
        }
示例#4
0
        private void MenuLogic(InputMessage msg)
        {
            MenuPanel top = activeMenu.Peek();

            //KeyPress Events
            if (msg.Kind == InputMessage.MessageType.RawInput || msg.Kind == InputMessage.MessageType.RawBack || msg.Pressed)
            {
                ButtonDelay.Stop();
                ButtonDelay.Start();
                ButtonRepeat.Elapsed -= repeatHandler;
                repeatHandler         = (s, e) => this.MenuLogic(msg);
                ButtonRepeat.Elapsed += repeatHandler;

                switch (msg.Kind)
                {
                case InputMessage.MessageType.ControlsAction:
                    //(top.SelectedItem as MenuButton)?.DoClick();
                    //Ballz.The().Services.GetService<SoundControl>().PlaySound(SoundControl.AcceptSound);
                    break;

                case InputMessage.MessageType.ControlsBack:
                    Ballz.The().Services.GetService <SoundControl>().PlaySound(SoundControl.DeclineSound);
                    if (activeMenu.Count == 1)     // exit if we are in main menuToPrepare
                    {
                        Ballz.The().Exit();        //TODO: this is rather ugly find a nice way to terminate the programm like sending a termination message
                    }
                    else
                    {
                        if (rawInput)
                        {
                            rawInput = false;
                        }
                        else
                        {
                            MenuGoBack();
                        }
                    }

                    RaiseMessageEvent(new MenuMessage(activeMenu.Peek()));
                    break;

                case InputMessage.MessageType.ControlsUp:
                    if (top.SelectedItem != null)
                    {
                        Ballz.The().Services.GetService <SoundControl>().PlaySound(SoundControl.SelectSound);
                        top.SelectPrevious();
                        RaiseMessageEvent(new MenuMessage(top));
                    }

                    break;

                case InputMessage.MessageType.ControlsDown:
                    if (top.SelectedItem != null)
                    {
                        Ballz.The().Services.GetService <SoundControl>().PlaySound(SoundControl.SelectSound);
                        top.SelectNext();
                        RaiseMessageEvent(new MenuMessage(top));
                    }

                    break;

                case InputMessage.MessageType.ControlsLeft:
                    (top.SelectedItem as IChooseable)?.SelectPrevious();
                    break;

                case InputMessage.MessageType.ControlsRight:
                    (top.SelectedItem as IChooseable)?.SelectNext();
                    break;

                case InputMessage.MessageType.RawInput:
                    (top.SelectedItem as IRawInputConsumer)?.HandleRawKey(msg.Key);
                    break;

                case InputMessage.MessageType.RawBack:
                    (top.SelectedItem as IRawInputConsumer)?.HandleBackspace();
                    break;

                default:
                    //throw new ArgumentOutOfRangeException();
                    break;
                }
            }
            else
            {
                //Key release events
                if (!msg.Pressed)
                {
                    ButtonRepeat.Stop();
                    ButtonDelay.Stop();
                    switch (msg.Kind)
                    {
                    case InputMessage.MessageType.ControlsLeft:
                        break;

                    case InputMessage.MessageType.ControlsRight:
                        break;
                    }
                }
            }
        }