예제 #1
0
        public StateSystem(IInputEventer input, Controller baseController)
            : base()
        {
            Input = input;
            States = new LinkedList<Controller>();
            States.AddLast(baseController);

            Input.KeyPressed += new KeyboardKeyStateChanged(KeyPressed);
            Input.KeyReleased += new KeyboardKeyStateChanged(KeyReleased);
            Input.MouseMoved += new MouseMoved(MouseMoved);
            Input.MouseScrollWheelMoved += new MouseScrollWheelChanged(MouseScrollWheelMoved);
            Input.MouseButtonPressed += new MouseButtonStateChanged(MouseButtonPressed);
            Input.MouseButtonReleased += new MouseButtonStateChanged(MouseButtonReleased);
            Input.ControllerConnected += new GamePadConnectionChanged(ControllerConnected);
            Input.ControllerDisconnected += new GamePadConnectionChanged(ControllerDisconnected);
            Input.ControllerLeftThumbstickMoved += new GamePadThumbStickMoved(ControllerLeftThumbstickMoved);
            Input.ControllerRightThumbstickMoved += new GamePadThumbStickMoved(ControllerRightThumbstickMoved);
            Input.ControllerLeftTriggerMoved += new GamePadTriggerMoved(ControllerLeftTriggerMoved);
            Input.ControllerRightTriggerMoved += new GamePadTriggerMoved(ControllerRightTriggerMoved);
            Input.ControllerButtonPressed += new GamePadButtonStateChanged(ControllerButtonPressed);
            Input.ControllerButtonReleased += new GamePadButtonStateChanged(ControllerButtonReleased);
        }
예제 #2
0
        public void Push(Controller controller)
        {
            if (controller.IsDisposed)
            {
                throw new InvalidOperationException("You cannot push back onto the stack a previously popped state.");
            }

            controller.LoadContent();

            if (this.OnControllerPush != null)
                this.OnControllerPush(controller, States.Last.Value);

            States.AddLast(controller);
        }
예제 #3
0
 /// <summary>
 /// Pops the previous top of the state stack and replaces it with a new one. Useful for switching maps,
 /// etc. where you'd rather not keep the old one around.
 /// </summary>
 public Controller PopAndPush(Controller controller)
 {
     Controller c = this.Pop();
     this.Push(controller);
     return c;
 }