コード例 #1
0
    public virtual void Deactivate()
    {
        sm_editController.Execute(Command.MENU_HIDE);

        GlobalInputController.ResetKey(ControlAction.CONFIRM);
        GlobalInputController.ResetKey(ControlAction.BACK);
    }
コード例 #2
0
    public override void ExecuteMenuCommand()
    {
        GlobalInputController.LockInput();
        switch (MenuAction)
        {
        case MenuCommand.EXIT_GAME:
            Application.Quit();
            break;

        case MenuCommand.RESUME:
            MessageServer.SendMessage(MessageID.PAUSE, new Message(0));
            break;

        case MenuCommand.CONFIRM:
            break;

        case MenuCommand.UPDATE_GAME_DATA:
            GlobalGameData.playerOneCharacter = currentCharacter;
            MessageServer.SendMessage(MessageID.CHARACTER_SELECTED, new Message((uint)PlayerID.PLAYER1));
            break;

        case MenuCommand.MENU_BACK:
            MessageServer.SendMessage(MessageID.MENU_BACK, new Message());
            break;
        }
    }
コード例 #3
0
    private void OnGUI()
    {
        var e = Event.current;

        if (e.type != EventType.KeyDown)
        {
            return;
        }

        var key = e.keyCode;

        if (!Input.GetKeyDown(key))
        {
            return;
        }
        var pressedType = GlobalInputController.FindInputType(key);

        if (GlobalInputController.Instance.CheckKeyAssigned(KeyType.Cancel))
        {
            return;
        }
        if (pressedType != InputType.None)
        {
            return;                                //누른키가 none(이동키가 아니어야만)
        }
        GlobalInputController.Instance.AssignKey(KeyType.Cancel, key);
    }
コード例 #4
0
    public override void ExecuteMenuCommand()
    {
        GlobalInputController.LockInput();
        switch (MenuAction)
        {
        case MenuCommand.EXIT_GAME:
            Application.Quit();
            break;

        case MenuCommand.RESTART:
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex, LoadSceneMode.Single);
            break;

        case MenuCommand.CHANGE_SCENE:
            if (c_itemActiveData.i_nextScene > -1 && c_itemActiveData.i_nextScene < SceneManager.sceneCountInBuildSettings)
            {
                MessageServer.OnSceneChange();
                SceneManager.LoadScene(c_itemActiveData.i_nextScene, LoadSceneMode.Single);
            }
            break;

        case MenuCommand.RESUME:
            MessageServer.SendMessage(MessageID.PAUSE, new Message(0));
            break;

        case MenuCommand.CONFIRM:
            break;
        }
    }
コード例 #5
0
 private void InitializeSpriteDisplay()
 {
     InputSpriteController.getInputSprite(out Sprite spriteOut,
                                          GlobalInputController.GetInputKey(InputAction, GlobalInputController.GetActiveControllerType()),
                                          GlobalInputController.GetActiveControllerType());
     SpriteDisplay.sprite = spriteOut;
 }
コード例 #6
0
    /// <summary>
    /// Pulls information from the engine into the controller/data structure
    /// </summary>
    public void EnginePull()
    {
        c_inputData.f_inputAxisLHoriz = GlobalInputController.GetAnalogInputAction(ControlAction.SPIN_AXIS);
        c_inputData.f_inputAxisLVert  = GlobalInputController.GetAnalogInputAction(ControlAction.FLIP_AXIS);

        CheckForZone();
    }
コード例 #7
0
    public override void ExecuteMenuCommand()
    {
        GlobalInputController.LockInput();
        switch (MenuAction)
        {
        case MenuCommand.EXIT_GAME:
            Application.Quit();
            break;

        case MenuCommand.RESTART:
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex, LoadSceneMode.Single);
            break;

        case MenuCommand.CHANGE_SCENE:
            if (c_itemActiveData.i_nextScene > -1)
            {
                MessageServer.OnSceneChange();
                SceneManager.LoadScene(c_itemActiveData.i_nextScene, LoadSceneMode.Single);
            }
            break;

        case MenuCommand.RESUME:
            MessageServer.SendMessage(MessageID.PAUSE, new Message(0));
            break;

        case MenuCommand.MENU_BACK:
            MessageServer.SendMessage(MessageID.MENU_BACK, new Message());
            break;

        case MenuCommand.MENU_FORWARD:
            if (ChildMenuController == null)
            {
                return;
            }
            MessageServer.SendMessage(MessageID.MENU_FORWARD, new Message(ChildMenuController.GetSuperMenuIndex()));
            break;

        case MenuCommand.CONFIRM:
            break;

        case MenuCommand.EDIT_DATA:
            if (DataItem == DataTarget.ERROR_TARGET)
            {
                return;
            }
            if (ChildEditController == null)
            {
                return;
            }
            // open data editor, wait for return
            ChildEditController.Activate(DataItem);
            MessageServer.SendMessage(MessageID.EDIT_START, new Message());
            break;

        case MenuCommand.RESET_CONTROLS:
            GlobalGameData.SetControlsToDefault(DataItem == DataTarget.CONTROLLER_CONTROLS ? InputType.CONTROLLER_GENERIC : InputType.KEYBOARD_GENERIC);
            break;
        }
    }
コード例 #8
0
    // Update is called once per frame
    public override void UpdateEditor()
    {
        if (!c_controllerData.b_editorActive)
        {
            return;
        }

        float inputAxisValue = GlobalInputController.GetAnalogInputAction(ControlAction.SPIN_AXIS);

        if (inputAxisValue < -0.5f)
        {
            c_controllerData.i_increasing = -1;
            sm_editController.Execute(Command.MENU_TICK_INPUT);
        }
        else if (inputAxisValue > 0.5f)
        {
            c_controllerData.i_increasing = 1;
            sm_editController.Execute(Command.MENU_TICK_INPUT);
        }
        else
        {
            // no input, unready
            c_controllerData.i_increasing = 0;
        }

        if (float.Equals(c_controllerData.f_currentTickTime, c_controllerData.f_maxTickTime))
        {
            sm_editController.Execute(Command.MENU_READY);
        }
        else
        {
            sm_editController.Execute(Command.MENU_IDLE);
        }

        if (c_controllerData.i_increasing == 0)
        {
            sm_editController.Execute(Command.MENU_READY);
        }

        if (!CheckForConfirmation())
        {
            return;
        }

        if (GlobalInputController.GetInputAction(ControlAction.CONFIRM, KeyValue.PRESSED))
        {
            ConfirmDataEdit(CurrentTarget);
            Deactivate();
        }

        else if (GlobalInputController.GetInputAction(ControlAction.BACK, KeyValue.PRESSED))
        {
            CancelDataEdit();
            Deactivate();
        }

        sm_editController.Act();
        EnginePush();
    }
コード例 #9
0
    public override void Deactivate()
    {
        sm_editController.Execute(Command.MENU_HIDE);

        // hack fix: reset the menu action keys as the Video Quality Edit Controller seems to keep the button held on confirmation
        GlobalInputController.ResetKey(ControlAction.CONFIRM);
        GlobalInputController.ResetKey(ControlAction.BACK);
    }
コード例 #10
0
 public override void ConfirmDataEdit(DataTarget targetIn)
 {
     MessageServer.SendMessage(MessageID.EDIT_END, new Message());
     GlobalInputController.UpdateAction(InputAction, c_controllerData.k, this.InputType);
     GlobalGameData.SetActionSetting(InputAction, c_controllerData.k, this.InputType);
     MessageServer.SendMessage(MessageID.EDIT_DISPLAY_UPDATE, new Message((int)c_controllerData.k, (uint)InputAction).withInputType(this.InputType));
     Deactivate();
 }
コード例 #11
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (GlobalInputController.GetInputAction(ControlAction.PAUSE, KeyValue.PRESSED))
     {
         Message pauseMessage = new Message((c_data.b_isPaused ? 0 : 1)); // if we want to pause, send 1, otherwise 0
         //isPaused = !isPaused;
         MessageServer.SendMessage(MessageID.PAUSE, pauseMessage);
     }
 }
コード例 #12
0
    private void Awake()
    {
        GlobalGameData.CheckAndSetDefaults();

        GlobalInputController.InitializeInput();
        if (GlobalInputController.InputIsLocked())
        {
            StartCoroutine(GlobalInputController.StartLockTimer());
        }
    }
コード例 #13
0
    public void InputUnbind()
    {
        c_controllerData.k = KeyCode.None;

        GlobalInputController.UpdateAction(InputAction, c_controllerData.k, this.InputType);
        GlobalGameData.SetActionSetting(InputAction, c_controllerData.k, this.InputType);

        if (InputSpriteController.getInputSprite(out spriteOut, c_controllerData.k, this.InputType))
        {
            SpriteDisplay.sprite = spriteOut;
        }
    }
コード例 #14
0
 private void FixedUpdate()
 {
     if (GlobalInputController.InputIsLocked())
     {
         return;
     }
     if (GlobalInputController.WatchForAnyInput())
     {
         GlobalInputController.CheckAndSetValueArbitrary();
     }
     GlobalInputController.UpdateInput();
 }
コード例 #15
0
    public void UpdateMenu()
    {
        if (c_activeMenuData.b_editorActive)
        {
            c_activeMenuItem.UpdateEditor();
            return;
        }

        if (c_activeMenuData.b_menuActive == false)
        {
            return;
        }

        c_activeMenuData.i_menuMousePositionItemIndex = -1;
        CheckMouseInput();

        float inputAxisValue = GlobalInputController.GetAnalogInputAction(ControlAction.FLIP_AXIS);

        if (inputAxisValue > 0.5f)
        {
            c_activeMenuData.i_menuDir = -1; // menus are often organized top to bottom
        }
        else if (inputAxisValue < -0.5f)
        {
            c_activeMenuData.i_menuDir = 1;
        }
        else
        {
            c_activeMenuData.i_menuDir = 0;
        }

        if (!CheckForConfirmation())
        {
            return;
        }

        if (GlobalInputController.GetInputAction(ControlAction.BACK, KeyValue.PRESSED))
        {
            // return to previous menu
            c_activeMenuItem.MenuCommandBack();
        }

        if (GlobalInputController.GetInputAction(ControlAction.CONFIRM, KeyValue.PRESSED) ||
            c_activeMenuData.b_menuItemClicked)
        {
            c_activeMenuItem.ExecuteMenuCommand();
        }

        UpdateStateMachine();

        SetActiveMenuItemIndex();
    }
コード例 #16
0
    // TODO: swapping a key with pause will not also update the "other mutex" buttons, allowing for a multiple mapping edge case
    public void InputSwap(KeyCode keyIn)
    {
        c_controllerData.k = keyIn;

        GlobalInputController.UpdateAction(InputAction, c_controllerData.k, this.InputType);
        GlobalGameData.SetActionSetting(InputAction, c_controllerData.k, this.InputType);

        if (InputSpriteController.getInputSprite(out spriteOut, c_controllerData.k, this.InputType))
        {
            SpriteDisplay.sprite = spriteOut;
        }
        MessageServer.SendMessage(MessageID.EDIT_DISPLAY_UPDATE, new Message((int)c_controllerData.k, (uint)InputAction).withInputType(this.InputType));
    }
コード例 #17
0
    /* Checks if the key is in the mutex or not, as certain inputs cannot be overlapped
     *
     */
    private void VerifyAndUpdateMutex(KeyCode keyIn)
    {
        // if the current keycode is bound to an existing action
        List <ControlAction> foundActions = GlobalInputController.GetActionForKey(keyIn);

        foreach (ControlAction controlAction in foundActions)
        {
            if (this.InputMutex.MutuallyExclusiveActions.Contains(controlAction) &&
                controlAction != InputAction)    // verify that we are not infinitely swapping the current action
            {
                MessageServer.SendMessage(MessageID.EDIT_SWAP, new Message((int)c_controllerData.k, (uint)controlAction));
            }
        }
    }
コード例 #18
0
 // Update is called once per frame
 void FixedUpdate()
 {
     // call update function for active Menu Controller
     if (!m_bMenuInputActive)
     {
         if (GlobalInputController.GetInputAction(ControlAction.CONFIRM, KeyValue.IDLE) &&
             GlobalInputController.GetInputAction(ControlAction.BACK, KeyValue.IDLE))
         {
             m_bMenuInputActive = true;
         }
         else
         {
             return;
         }
     }
     m_activeMenuController.UpdateMenu();
 }
コード例 #19
0
 public virtual bool CheckForConfirmation()
 {
     if (!c_controllerData.b_editConfirmationActive)
     {
         if (GlobalInputController.GetInputAction(ControlAction.CONFIRM, KeyValue.IDLE) &&
             GlobalInputController.GetInputAction(ControlAction.BACK, KeyValue.IDLE))
         {
             c_controllerData.b_editConfirmationActive = true;
             return(true);
         }
         else
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #20
0
    public virtual void UpdateEditor()
    {
        if (!CheckForConfirmation())
        {
            return;
        }

        if (GlobalInputController.GetInputAction(ControlAction.CONFIRM, KeyValue.PRESSED))
        {
            ConfirmDataEdit(CurrentTarget);
            Deactivate();
        }

        else if (GlobalInputController.GetInputAction(ControlAction.BACK, KeyValue.PRESSED))
        {
            CancelDataEdit();
            Deactivate();
        }
    }
コード例 #21
0
    private void UpdateTrickStateMachine()
    {
        bool TrickHit = false;

        if (!TrickHit && GlobalInputController.GetInputAction(ControlAction.LEFT_GRAB, KeyValue.PRESSED))
        {
            TrickHit = true;
            trickData.k_activeTrickAction = ControlAction.LEFT_GRAB;
            trickData.t_activeTrickName   = trickData.trick_left;
        }
        if (!TrickHit && GlobalInputController.GetInputAction(ControlAction.UP_GRAB, KeyValue.PRESSED))
        {
            TrickHit = true;
            trickData.k_activeTrickAction = ControlAction.UP_GRAB;
            trickData.t_activeTrickName   = trickData.trick_up;
        }

        if (!TrickHit && GlobalInputController.GetInputAction(ControlAction.RIGHT_GRAB, KeyValue.PRESSED))
        {
            TrickHit = true;
            trickData.k_activeTrickAction = ControlAction.RIGHT_GRAB;
            trickData.t_activeTrickName   = trickData.trick_right;
        }

        if (!TrickHit && GlobalInputController.GetInputAction(ControlAction.DOWN_GRAB, KeyValue.PRESSED))
        {
            TrickHit = true;
            trickData.k_activeTrickAction = ControlAction.DOWN_GRAB;
            trickData.t_activeTrickName   = trickData.trick_down;
        }

        if (TrickHit)
        {
            sm_tricking.Execute(Command.START_TRICK);
            sm_tricking.Execute(Command.SCORE_TRICK);
        }
        else if (GlobalInputController.GetInputAction(trickData.k_activeTrickAction, KeyValue.UP))
        {
            sm_tricking.Execute(Command.END_TRICK);
        }
    }
コード例 #22
0
    private void UpdateStateMachine()
    {
        if (GlobalInputController.GetInputAction(ControlAction.CONFIRM, KeyValue.PRESSED) &&
            !CountdownDisplayImage.enabled)
        {
            InGameInterface.SetActive(true);
            PreviewInterface.SetActive(false);
            CountdownDisplayImage.enabled = true;

            MessageServer.SendMessage(MessageID.COUNTDOWN_START, new Message());
            sm_countdown.Execute(Command.START_COUNTDOWN);
        }
        // we want to continuously countdown, tick, then countdown again
        if (c_countdownData.f_currentCountdownTime < c_countdownData.i_countdownTime)
        {
            sm_countdown.Execute(Command.TICK_TIMER);
            sm_countdown.Execute(Command.START_TIMER_DOWN);

            CountdownDisplayImage.sprite = CountdownSprites[c_countdownData.i_countdownTime];
        }
    }
コード例 #23
0
    // Update is called once per frame
    public override void UpdateEditor()
    {
        if (c_controllerData.b_editorActive == false)
        {
            return;
        }

        if (GlobalInputController.GetInputAction(ControlAction.CONFIRM, KeyValue.IDLE))
        {
            GlobalInputController.StartWatchForAnyInput();
            SpriteDisplay.sprite = InputSpriteController.EmptySprite();
        }

        KeyCode keyIn = GlobalInputController.GetAnyKey();

        if (keyIn == KeyCode.Escape)
        {
            GlobalInputController.StopWatchForAnyInput();
            CancelDataEdit();
            if (InputSpriteController.getInputSprite(out spriteOut, c_controllerData.k, this.InputType))
            {
                SpriteDisplay.sprite = spriteOut;
            }
        }

        else if (keyIn != KeyCode.None)
        {
            GlobalInputController.StopWatchForAnyInput();
            VerifyAndUpdateMutex(keyIn);
            if (InputSpriteController.getInputSprite(out spriteOut, keyIn, this.InputType))
            {
                SpriteDisplay.sprite = spriteOut;
            }
            c_controllerData.k = keyIn;
            ConfirmDataEdit(CurrentTarget);
        }

        // no state machine needed, handled by isActive
        EnginePush();
    }
コード例 #24
0
    void FixedUpdate()
    {
        c_activeMenuData.v_lastFramePosition = c_activeMenuData.v_currentPosition;
        if (c_activeMenuData.b_showMenu == true)
        {
            float inputAxisValue = GlobalInputController.GetAnalogInputAction(ControlAction.FLIP_AXIS);
            if (inputAxisValue > 0.5f)
            {
                c_activeMenuData.i_menuDir = -1; // menus are often organized top to bottom
            }
            else if (inputAxisValue < -0.5f)
            {
                c_activeMenuData.i_menuDir = 1;
            }
            else
            {
                c_activeMenuData.i_menuDir = 0;
            }

            if (GlobalInputController.GetInputAction(ControlAction.CONFIRM, KeyValue.PRESSED))
            {
                c_activeMenuItem.ExecuteMenuCommand();
            }
        }

        UpdateStateMachine();

        sm_menuInput.Act();
        sm_pauseMenu.Act();

        if (i_activeMenuItemIndex != c_activeMenuData.i_activeMenuItemIndex)
        {
            c_activeMenuItem.ExecuteStateMachineCommand(Command.UNSELECT);
            i_activeMenuItemIndex = c_activeMenuData.i_activeMenuItemIndex;
            c_activeMenuItem      = MenuItems[i_activeMenuItemIndex];
            c_activeMenuItem.ExecuteStateMachineCommand(Command.SELECT);
        }
    }
コード例 #25
0
    //처음으로 누른 이동키/사용키를 설정

    private void OnGUI()
    {
        var e = Event.current;

        if (e.type != EventType.KeyDown)
        {
            return;
        }

        var key = e.keyCode;

        if (!Input.GetKeyDown(key))
        {
            return;
        }
        var pressedType = GlobalInputController.FindInputType(key);

        if (GlobalInputController.Instance.InputType == InputType.None) //이동 키가 설정이 안되었다면
        {
            if (pressedType != InputType.None)
            {
                GlobalInputController.Instance.InputType = pressedType;
                Debug.Log("최초 입력 방식 설정됨: " + pressedType);
                return;
            }
        }

        if (GlobalInputController.Instance.CheckKeyAssigned(KeyType.Use))
        {
            return;
        }
        if (pressedType != InputType.None)
        {
            return;                                //누른키가 none(이동키가 아니어야만)
        }
        GlobalInputController.Instance.AssignKey(KeyType.Use, key);
    }
コード例 #26
0
    /// <summary>
    /// Updates the state machine based on whatever input sources are required
    /// </summary>
    public void UpdateStateMachine()
    {
        if (c_stateData.b_preStarted == false)
        {
            c_accelMachine.Execute(Command.COUNTDOWN_OVER);
            c_turnMachine.Execute(Command.COUNTDOWN_OVER);
            c_airMachine.Execute(Command.COUNTDOWN_OVER);
            sm_tricking.Execute(Command.COUNTDOWN_OVER);
            sm_trickPhys.Execute(Command.COUNTDOWN_OVER);
            sm_switch.Execute(Command.COUNTDOWN_OVER);
            c_stateData.b_preStarted = true; // we want to execute this only once
        }

        if (c_stateData.b_courseFinished == true)
        {
            c_accelMachine.Execute(Command.SLOW);
            c_turnMachine.Execute(Command.RIDE);
            if (c_playerData.f_currentSpeed < 0.0f)
            {
                c_accelMachine.Execute(Command.STOP);
                // we should completely stop do something now that we're done
            }
            return;
        }
        if (Mathf.Abs(c_inputData.f_inputAxisLHoriz) > 0.0f)
        {
            // catch changing direction between two FixedUpdates
            if (Mathf.Sign(c_turnData.f_currentTurnSpeed) != Mathf.Sign(c_inputData.f_inputAxisLHoriz))
            {
                c_turnMachine.Execute(Command.RIDE);
            }
            c_turnMachine.Execute(Command.TURN);
        }

        else
        {
            c_turnMachine.Execute(Command.RIDE);
        }

        if (Mathf.Abs(c_inputData.f_inputAxisLHoriz) <= 0.0f &&
            Mathf.Abs(c_inputData.f_inputAxisLVert) <= 0.0f)
        {
            sm_trickPhys.Execute(Command.SPIN_STOP);
        }

        if (c_inputData.f_inputAxisLVert < 0.0f)
        {
            c_accelMachine.Execute(Command.SLOW);
        }
        else
        {
            c_accelMachine.Execute(Command.RIDE);
        }
        if (c_inputData.f_inputAxisLVert > 0.0f)
        {
            c_accelMachine.Execute(Command.STARTMOVE);
        }

        if (c_playerData.f_currentSpeed <= 0.02f)
        {
            c_accelMachine.Execute(Command.STOP);
        }

        if (GlobalInputController.GetInputAction(ControlAction.CROUCH, KeyValue.PRESSED))
        {
            c_airMachine.Execute(Command.START_BOOST);
            c_accelMachine.Execute(Command.START_BOOST);
            c_turnMachine.Execute(Command.START_BOOST);
            sm_trickPhys.Execute(Command.START_BOOST);
        }
        else if (GlobalInputController.GetInputAction(ControlAction.CROUCH, KeyValue.UP))
        {
            c_airMachine.Execute(Command.STOP_BOOST);
        }

        // TODO: split out the sm_trickPhysics machine to ensure that after correcting we can charge the spin again
        if (GlobalInputController.GetInputAction(ControlAction.JUMP, KeyValue.PRESSED))
        {
            c_accelMachine.Execute(Command.CHARGE);
            c_airMachine.Execute(Command.CHARGE);
            c_turnMachine.Execute(Command.CHARGE);
            sm_trickPhys.Execute(Command.CHARGE);
        }
        else if (GlobalInputController.GetInputAction(ControlAction.JUMP, KeyValue.UP))
        {
            c_turnMachine.Execute(Command.JUMP);
            c_airMachine.Execute(Command.JUMP);
            sm_trickPhys.Execute(Command.JUMP);
        }

        UpdateTrickStateMachine();

        if (c_playerData.f_currentCrashTimer > c_playerData.f_crashRecoveryTime)
        {
            c_accelMachine.Execute(Command.READY);
            c_turnMachine.Execute(Command.READY);
            c_airMachine.Execute(Command.READY);
        }
        else if (c_playerData.v_currentObstacleNormal.magnitude > Constants.ZERO_F) // nonzero obstacle normal implies collision
        {
            //c_accelMachine.Execute(Command.CRASH);
            //c_turnMachine.Execute(Command.CRASH);
            //c_airMachine.Execute(Command.CRASH);
            //sm_trickPhys.Execute(Command.CRASH);
        }

        if (c_trickPhysicsData.f_groundResetTarget.Equals(Constants.ZERO_F))
        {
            sm_trickPhys.Execute(Command.SPIN_CORRECT_END);
        }

        UpdateSwitchStateMachine();
    }
コード例 #27
0
 public override void CancelDataEdit()
 {
     MessageServer.SendMessage(MessageID.EDIT_END, new Message());
     c_controllerData.k = GlobalInputController.GetInputKey(InputAction, this.InputType);
     Deactivate();
 }