Example #1
0
 public void SetActiveKeyboardLayout(KeyboardConfiguration layout)
 {
     foreach (var option in _keyboardLayoutOptions)
     {
         option.active = option.layout == layout;
     }
 }
Example #2
0
        private void UpdateDebugInput()
        {
            KeyboardState         keyboardState = Keyboard.GetState();
            KeyboardConfiguration kb            = new KeyboardConfiguration(keyboardState);

            if (kb.IsKeyPressed(ActionKey.ToggleDiagnosticMode, oldState))
            {
                Config.Diagnostic = !Config.Diagnostic;
            }

            if (Config.Diagnostic)             // debug mode only available in diagnostic configuration.
            {
                if (kb.IsKeyPressed(ActionKey.ToggleDebugMode, oldState))
                {
                    debugMode = !debugMode;
                }

                if (kb.IsKeyPressed(ActionKey.UpdateInNextFrame, oldState))
                {
                    debugMode         = true;
                    updateInNextFrame = true;
                }
            }
            oldState = keyboardState;
        }
Example #3
0
        private void UpdateMovementAirborne(KeyboardConfiguration kb, GameTime gameTime)
        {
            if (kb.IsKeyDown(ActionKey.Jump))
            {
                if (!lastJumpStarted.HasValue)                 // sanity.
                {
                    return;
                }
                if (gameTime.TotalGameTime - lastJumpStarted.Value < MagicNumbers.JumpWindow)
                {
                    Speed.Y = MagicNumbers.JumpSpeed / 2;
                }
            }

            if (kb.IsKeyDown(ActionKey.Right))
            {
                Direction = Direction.Right;
            }
            else if (kb.IsKeyDown(ActionKey.Left))
            {
                Direction = Direction.Left;
            }
            else
            {
                Direction = Direction.None;
            }
        }
Example #4
0
 public void Monitor(
     JoystickConfiguration joystickConfiguration,
     KeyboardConfiguration keyboardConfiguration
     )
 {
     MonitorJoystickInput(joystickConfiguration);
     MonitorKeyboardInput(keyboardConfiguration);
 }
Example #5
0
        public void UpdateInput(GameTime gameTime)
        {
            KeyboardState         keyboardState = Keyboard.GetState();
            KeyboardConfiguration kb            = new KeyboardConfiguration(keyboardState);

            if (kb.IsKeyPressed(ActionKey.ToggleMusic, oldState))
            {
                if (MediaPlayer.State == MediaState.Stopped)
                {
                    PlayRandomSong();
                }
                else
                {
                    stopping = true;
                    MediaPlayer.Stop();
                }
            }

            oldState = keyboardState;
        }
Example #6
0
    public void ChangeMode(Mode mode)
    {
        this.mode = mode;
        switch (mode)
        {
        case Mode.Battle:
            audioManager.PlayBGM("battleTheme");
            modeLabel.text = "Battle Mode";
            if (level == 1)
            {
                audioManager.Play("*you-are-in-a-battle");
            }
            else
            {
                audioManager.Play("_you-are-in-a-battle");
            }
            break;

        case Mode.Menu:
            audioManager.PlayBGM("exploringTheme");
            modeLabel.text = "Menu Mode";
            audioManager.Play("*you-are-in-the-menu");
            break;

        case Mode.Path:
            audioManager.PlayBGM("gameOverTheme");
            modeLabel.text = "Path Selection Mode";
            if (level == 13)
            {
                audioManager.Play("end-demo", "", true);
            }
            else
            {
                audioManager.Play("*you-are-in-the-level " + level);
            }
            break;
        }
        validSequences = KeyboardConfiguration.GetValidSequences(mode);
        keyTypes       = KeyboardConfiguration.GetKeyTypes(mode);
        gamesActions   = KeyboardConfiguration.GetActions(mode);
    }
Example #7
0
        private void UpdateMovement(GameTime gameTime)
        {
            var kb = new KeyboardConfiguration(keyboardState);

            if (Config.Diagnostic)
            {
                if (kb.IsKeyPressed(ActionKey.Suicide, oldState))
                {
                    Die();
                }
                oldState = keyboardState;
            }

            if (State == HitBoxState.Surfaced)
            {
                UpdateMovementSurfaced(kb, gameTime);
            }
            else if (State == HitBoxState.Airborne)
            {
                UpdateMovementAirborne(kb, gameTime);
            }
        }
Example #8
0
 private void UpdateMovementSurfaced(KeyboardConfiguration kb, GameTime gameTime)
 {
     if (kb.IsKeyDown(ActionKey.Jump))
     {
         JumpEffects();
         Speed.Y           = MagicNumbers.JumpSpeed;
         lastJumpStarted   = gameTime.TotalGameTime;
         jumpStartPosition = Position + MagicNumbers.FallEffect;
     }
     else if (kb.IsKeyDown(ActionKey.Right))
     {
         Direction = Direction.Right;
     }
     else if (kb.IsKeyDown(ActionKey.Left))
     {
         Direction = Direction.Left;
     }
     else
     {
         Direction = Direction.None;
     }
 }
Example #9
0
 void Reset()
 {
     keyboardConfig = this.GetComponent<KeyboardConfiguration>();
 }
Example #10
0
 private void SetKeyboardLayout(KeyboardConfiguration config)
 {
     App.keyboardConfiguration = config;
     _uiController.SetActiveKeyboardLayout(config);
 }
Example #11
0
    public void Awake()
    {
        Instance = this;
        Logger.Log(Logger.Initialisation, $"Our game mode is {GameRules.GameMode}");
        Guard.CheckIsNull(GridGO, "GridGO", gameObject);

        Guard.CheckIsNull(_mazeLevelManagerPrefab, "MazeLevelManagerPrefab", gameObject);
        Guard.CheckIsNull(_mazeCharacterManagerPrefab, "_mazeCharacterManagerPrefab", gameObject);
        Guard.CheckIsNull(_overworldCharacterManagerPrefab, "_overworldCharacterManagerPrefab", gameObject);
        Guard.CheckIsNull(_mazeLevelSpriteManagerPrefab, "_mazeLevelSpriteManagerPrefab", gameObject);
        Guard.CheckIsNull(_overworldSpriteManagerPrefab, "_overworldSpriteManagerPrefab", gameObject);
        Guard.CheckIsNull(_overworldManagerPrefab, "_overworldManagerPrefab", gameObject);
        Guard.CheckIsNull(_cameraContainerPrefab, "_cameraContainerPrefab", gameObject);

        InitialiseLoggers();
        if (PhotonNetwork.PlayerList.Length == 0)
        {
            if (GameRules.GamePlayerType != GamePlayerType.SplitScreenMultiplayer)
            {
                GameRules.SetGamePlayerType(GamePlayerType.SinglePlayer);
            }
        }
        else
        {
            GameRules.SetGamePlayerType(GamePlayerType.NetworkMultiplayer);
        }

        PersistentGameManager.CurrentSceneType = _thisSceneType;
        Logger.Warning($"We set the game type to {GameRules.GamePlayerType} in a {PersistentGameManager.CurrentSceneType} scene. The scene loading origin is {PersistentGameManager.SceneLoadOrigin}");

        if (Application.isMobilePlatform)
        {
            PersistentGameManager.CurrentPlatform = Platform.Android;
            Configuration = new AndroidConfiguration();
        }
        else
        {
            PersistentGameManager.CurrentPlatform = Platform.PC;
            Configuration = new PCConfiguration();
        }

        KeyboardConfiguration = new KeyboardConfiguration();

        switch (PersistentGameManager.CurrentSceneType)
        {
        case SceneType.Overworld:
            Instantiate(_overworldSpriteManagerPrefab, transform);
            Instantiate(_overworldCharacterManagerPrefab, transform);
            Instantiate(_overworldManagerPrefab, transform);
            break;

        case SceneType.Maze:
            Instantiate(_mazeLevelSpriteManagerPrefab, transform);
            Instantiate(_mazeCharacterManagerPrefab, transform);
            Instantiate(_mazeLevelManagerPrefab, transform);
            break;

        default:
            Logger.Error($"Scenetype {PersistentGameManager.CurrentSceneType} is not implemented yet");
            break;
        }

        Instantiate(_cameraContainerPrefab);
    }
Example #12
0
    public void MonitorKeyboardInput(KeyboardConfiguration keyboardConfiguration)
    {
        if (Input.GetKey(keyboardConfiguration.RightKeyCode))
        {
            if (IsMonitoringJoystick())
            {
                CurrentControlScheme = ControlScheme.KEYBOARD;
            }

            if (IsMovingLeft())
            {
                CurrentMovementState &= ~MovementState.LEFT;
            }

            CurrentMovementState |= MovementState.RIGHT;
        }
        else if (Input.GetKey(keyboardConfiguration.LeftKeyCode))
        {
            if (IsMonitoringJoystick())
            {
                CurrentControlScheme = ControlScheme.KEYBOARD;
            }

            if (IsMovingRight())
            {
                CurrentMovementState &= ~MovementState.RIGHT;
            }

            CurrentMovementState |= MovementState.LEFT;
        }
        else if (!IsMonitoringJoystick())
        {
            CurrentMovementState &= ~(MovementState.LEFT | MovementState.RIGHT);
        }

        if (Input.GetKey(keyboardConfiguration.UpKeyCode))
        {
            if (IsMonitoringJoystick())
            {
                CurrentControlScheme = ControlScheme.KEYBOARD;
            }

            if (IsMovingDown())
            {
                CurrentMovementState &= ~MovementState.DOWN;
            }

            CurrentMovementState |= MovementState.UP;
        }
        else if (Input.GetKey(keyboardConfiguration.DownKeyCode))
        {
            if (IsMonitoringJoystick())
            {
                CurrentControlScheme = ControlScheme.KEYBOARD;
            }

            if (IsMovingUp())
            {
                CurrentMovementState &= ~MovementState.UP;
            }

            CurrentMovementState |= MovementState.DOWN;
        }
        else if (!IsMonitoringJoystick())
        {
            CurrentMovementState &= ~(MovementState.UP | MovementState.DOWN);
        }
    }