public static GameController getInstance() { if (null == instance) { instance = new GameController(); } return instance; }
private void checkInput(GameController control) { if (state != BoyState.Die) { if ((control.keyState.IsKeyDown(Keys.Space) || control.padState.IsButtonDown(Buttons.A))) { if ((((state == BoyState.Walk || state == BoyState.Idle) && control.keyState.IsKeyUp(Keys.Right) && control.keyState.IsKeyUp(Keys.Left) && control.padState.IsButtonUp(Buttons.LeftThumbstickRight) && control.padState.IsButtonUp(Buttons.LeftThumbstickLeft)) || state == BoyState.PushWalk) && null != interactor) { interactor.Interact(); } } else if ((state == BoyState.PushingStill ||state == BoyState.PushWalk) && interactor != null) { state = BoyState.Idle; } if (control.keyState.IsKeyDown(Keys.LeftControl) || control.padState.IsButtonDown(Buttons.RightTrigger)) { if (nearestChair != null) { state = BoyState.ControllingChair; nearestChair.state = Chairs.ChairsState.Moving; } } else { if (nearestChair != null && nearestChair.state == Chairs.ChairsState.Moving) { nearestChair.state = Chairs.ChairsState.Falling; state = BoyState.Idle; } } if (control.keyState.IsKeyUp(Keys.Left) && control.keyState.IsKeyUp(Keys.Right) && control.padState.IsButtonUp(Buttons.LeftThumbstickLeft) && control.padState.IsButtonUp(Buttons.LeftThumbstickRight) && state != BoyState.Teleport && state != BoyState.TimeTravel) { if (state != BoyState.ControllingChair) { if (direction == Direction.Right) { if (state != BoyState.StairsRight && state != BoyState.StairsLeft) { if ((state == BoyState.PushWalk || state == BoyState.PushingStill) && interactor != null) state = BoyState.PushingStill; else state = BoyState.Idle; } } else { if (state != BoyState.StairsRight && state != BoyState.StairsLeft) { if ((state == BoyState.PushWalk || state == BoyState.PushingStill) && interactor != null) state = BoyState.PushingStill; else state = BoyState.Idle; } } } } else { if (state != BoyState.ControllingChair) { if (control.keyState.IsKeyDown(Keys.Right) || control.padState.IsButtonDown(Buttons.LeftThumbstickRight)) { if ((state != BoyState.PushWalk && state != BoyState.PushingStill) || (interactor != null && ((Wardrobe)interactor).X > X)) direction = Direction.Right; if (state == BoyState.Idle) state = BoyState.Walk; if (state == BoyState.PushingStill && direction == Direction.Right && interactor != null) state = BoyState.PushWalk; } else if (control.keyState.IsKeyDown(Keys.Left) || control.padState.IsButtonDown(Buttons.LeftThumbstickLeft)) { if ((state != BoyState.PushWalk && state != BoyState.PushingStill) || (interactor != null && ((Wardrobe)interactor).X < X)) direction = Direction.Left; if (state == BoyState.Idle) state = BoyState.Walk; if (state == BoyState.PushingStill && direction == Direction.Left && interactor != null) state = BoyState.PushWalk; } } } if (state == BoyState.ControllingChair) { if (nearestChair != null && nearestChair.state == Chairs.ChairsState.Moving) { if (control.keyState.IsKeyDown(Keys.Right) || control.padState.IsButtonDown(Buttons.LeftThumbstickRight)) { nearestChair.move(Direction.Right); } else if (control.keyState.IsKeyDown(Keys.Left) || control.padState.IsButtonDown(Buttons.LeftThumbstickLeft)) { nearestChair.move(Direction.Left); } if (control.keyState.IsKeyDown(Keys.Up) || control.padState.IsButtonDown(Buttons.LeftThumbstickUp)) { nearestChair.move(Direction.Up); } else if (control.keyState.IsKeyDown(Keys.Down) || control.padState.IsButtonDown(Buttons.LeftThumbstickDown)) { nearestChair.move(Direction.Down); } } else { state = BoyState.Idle; } } } }