Exemple #1
0
 private void DoInput(PlayerInputs.InputActionValue input)
 {
     if (!playerInputData.IsLocked())
     {
         playerInputData.AddToComboBuffer(input);
         playerInputData.AddToInputArray(input);
         playerInputData.AddToTokenArray(input);
     }
 }
Exemple #2
0
    // Cleans the output such that if left and right are being held the most recent input is taken.
    // Treats multiple buttons as if you let go of the old button and pressed only the new button even if
    // physically both buttons are being held. It then treats letting go of one of 2 held buttons as if you
    // let go of the currently active button and pressed the inactive button.
    private void EvaluatePerformAction(PlayerInputs.InputActionValue rawInput, int[] socd = null)
    {
        if (socd == null)
        {
            DoInput(rawInput);
        }
        else
        {
            // NOTE: Comments written for the specific case of right and left cleaning
            int firstInput  = socd[0];                                      // right
            int secondInput = socd[1];                                      // left

            if ((int)rawInput == firstInput)                                // If right is being pressed
            {
                socd[2] = 1;                                                //set right to pressed
                if (socd[3] == 1)                                           // If left is pressed
                {
                    DoInput((PlayerInputs.InputActionValue)(-secondInput)); // if left is being held then unpress left
                    socd[3] = -1;                                           //change status to physically held but unpressed
                }
                DoInput(rawInput);                                          // press right
            }
            else if ((int)rawInput == -firstInput)                          // If right is being unpressed
            {
                socd[2] = 0;                                                //set right to unpressed
                if (socd[3] == -1)                                          // if direction was right
                {
                    DoInput(rawInput);                                      //release right
                    socd[3] = 1;                                            // Set left to pressed
                    DoInput((PlayerInputs.InputActionValue)secondInput);    // press left
                }
                else if (socd[3] == 0)                                      // if left was not pressed at all
                {
                    DoInput(rawInput);                                      // simply release right (stop moving)
                }
                //if (socd[3] == 1) { } // if direction was left, do nothing as it has already been released
            }
            else if ((int)rawInput == secondInput)                         // If left is being pressed
            {
                socd[3] = 1;                                               // Set left to pressed
                if (socd[2] == 1)                                          // If right is pressed
                {
                    DoInput((PlayerInputs.InputActionValue)(-firstInput)); // Unpress right
                    socd[2] = -1;                                          // set right to held but unpressed
                }
                DoInput(rawInput);                                         // press left
            }
            else if ((int)rawInput == -secondInput)                        // If left is being unpressed
            {
                socd[3] = 0;                                               // Set left to unpressed
                if (socd[2] == -1)                                         // If right is held but not pressed
                {
                    DoInput(rawInput);                                     // Release left
                    socd[2] = 1;                                           // Set right to pressed
                    DoInput((PlayerInputs.InputActionValue)firstInput);    // Press right
                }
                else if (socd[2] == 0)                                     //If right is unpressed
                {
                    DoInput(rawInput);                                     // Unpress Left
                }
                //if (socd[2] == 1) { }
            }
        }
    }