Example #1
0
        private GameState SetRoundStart()
        {
            GameManager.Instance.SoundManager.RestoreVolume();
            CurrentSplashState.CurrentState    = SplashState.State.RoundStart_3;
            CurrentSplashState.FramesRemaining = GameplayConstants.FRAMES_COUNTDOWN;

            GameState state = new GameState(m_setData.InitData, 0);

            state.P1_Gauge = m_previousState.P1_Gauge;
            state.P1_Hitboxes.Add(CreateCharacterStartingHitbox());
            state.P1_Position    = GameplayConstants.STARTING_POSITION * -1;
            state.P1_State       = GameplayEnums.CharacterState.Idle;
            state.P1_StateFrames = 0;

            state.P2_Gauge = m_previousState.P2_Gauge;
            state.P2_Hitboxes.Add(CreateCharacterStartingHitbox());
            state.P2_Position    = GameplayConstants.STARTING_POSITION;
            state.P2_State       = GameplayEnums.CharacterState.Idle;
            state.P2_StateFrames = 0;

            state.RemainingHitstop = 0;
            state.RemainingTime    = GameplayConstants.FRAMES_PER_ROUND;


            m_p1LastInputs = new SinglePlayerInputs();
            m_p2LastInputs = new SinglePlayerInputs();


            ResetCamera();

            return(state);
        }
    //public int playerId = 0; // The Rewired player id of this character
    //
    //public float moveSpeed = 3.0f;
    //public float bulletSpeed = 15.0f;
    //public GameObject bulletPrefab;
    //
    //private Player player; // The Rewired Player
    //private CharacterController cc;
    //private Vector3 moveVector;
    //private bool fire;
    //
    //void Awake()
    //{
    //    // Get the Rewired Player object for this player and keep it for the duration of the character's lifetime
    //    player = ReInput.players.GetPlayer(playerId);
    //
    //    // Get the character controller
    //    cc = GetComponent<CharacterController>();
    //}
    //
    //void Update()
    //{
    //    GetInput();
    //    ProcessInput();
    //}
    //
    //private void GetInput()
    //{
    //    // Get the input from the Rewired Player. All controllers that the Player owns will contribute, so it doesn't matter
    //    // whether the input is coming from a joystick, the keyboard, mouse, or a custom controller.
    //
    //    moveVector.x = player.GetAxis("Move Horizontal"); // get input by name or action id
    //    moveVector.y = player.GetAxis("Move Vertical");
    //    fire = player.GetButtonDown("Fire");
    //}
    //
    //private void ProcessInput()
    //{
    //    // Process movement
    //    if (moveVector.x != 0.0f || moveVector.y != 0.0f)
    //    {
    //        cc.Move(moveVector * moveSpeed * Time.deltaTime);
    //    }
    //
    //    // Process fire
    //    if (fire)
    //    {
    //        GameObject bullet = (GameObject)Instantiate(bulletPrefab, transform.position + transform.right, transform.rotation);
    //        bullet.rigidbody.AddForce(transform.right * bulletSpeed, ForceMode.VelocityChange);
    //    }
    //}


    static public SinglePlayerInputs GetInputs(bool _p1)
    {
        Log();
        SinglePlayerInputs inputs = new SinglePlayerInputs();
        var playerId = RewiredJoystickAssigner.GetPlayerId(_p1);

        if (playerId < 0)
        {
            return(inputs);
        }
        Player player = ReInput.players.GetPlayer(playerId);

        float h;
        float v;

        float diag_TL_BR = player.GetAxisRaw("Move_Diagonal_TL_BR");
        float diag_TR_BL = player.GetAxisRaw("Move_Diagonal_TR_BL");

        //adjusting because d-pads are sometimes considered as HAT inputs, where the diagonals require their own axis....... I hate this
        if (Mathf.Abs(diag_TL_BR) > 0.1)
        {
            if (diag_TL_BR < 0)
            {
                h = -1f;
                v = 1f;
            }
            else
            {
                h = 1f;
                v = -1f;
            }
        }
        else if (Mathf.Abs(diag_TR_BL) > 0.1)
        {
            if (diag_TR_BL < 0)
            {
                h = 1f;
                v = 1f;
            }
            else
            {
                h = -1f;
                v = -1f;
            }
        }
        else
        {
            h = player.GetAxisRaw("Move_Horizontal");
            v = player.GetAxisRaw("Move_Vertical");
        }
        inputs.JoystickDirection = GetNumpadDirection(h, v, _p1);


        inputs.A = player.GetButton("Button_A");
        inputs.B = player.GetButton("Button_B");
        inputs.C = player.GetButton("Button_C");

        return(inputs);
    }
 public bool Equals(SinglePlayerInputs other)
 {
     return(JoystickDirection == other.JoystickDirection &&
            A == other.A &&
            B == other.B &&
            C == other.C &&
            Start == other.Start);
 }
Example #4
0
 public SingleFrameInputValidation()
 {
     P1_Inputs     = new SinglePlayerInputs();
     P2_Inputs     = new SinglePlayerInputs();
     SyncConfirmed = false;
     FrameNumber   = -1;
     P1_Source     = true;
 }
 public SinglePlayerInputs(SinglePlayerInputs other)
 {
     JoystickDirection = other.JoystickDirection;
     A     = other.A;
     B     = other.B;
     C     = other.C;
     Start = other.Start;
 }
Example #6
0
        void GameplayStateUpdate(SinglePlayerInputs _p1Inputs, SinglePlayerInputs _p2Inputs, bool skipRender = false)
        {
            //1.1 Check for pause? todo
            if (CurrentSplashState.CurrentState == SplashState.State.GameOver)
            {
                //check if any button is pressed to start a new game
                if (_p1Inputs.A || _p1Inputs.B || _p1Inputs.C || _p1Inputs.Start ||
                    _p2Inputs.A || _p2Inputs.B || _p2Inputs.C || _p2Inputs.Start)
                {
                    ApplicationStateManager.GetInstance().SetCharacterSelectScreen(m_setData);
                }
            }
            else if (UpdateSplashScreen())
            {
            }
            else if (m_previousState.RemainingHitstop > 0)
            {
                m_previousState.RemainingHitstop--;
            }
            else
            {
                //2. Sees if the inputs can be applied to current action
                GameState currentState = UpdateGameStateWithInputs(_p1Inputs, _p2Inputs, m_previousState);
                m_p1LastInputs = _p1Inputs;
                m_p2LastInputs = _p2Inputs;

                //3. Resolves actions
                MatchOutcome outcome = ResolveActions(_p1Inputs, _p2Inputs, currentState);



                //4. Checks if the match is over
                if (outcome.IsEnd())
                {
                    //Extra render on game end?
                    GameplayRendererObject.RenderScene(m_previousState, Match, CurrentSplashState);
                    HandleOutcome(outcome);
                    CurrentSplashState.CurrentState    = SplashState.State.RoundOver_ShowResult;
                    CurrentSplashState.FramesRemaining = GameplayConstants.FRAMES_END_ROUND_SPLASH;


                    //camera tests
                    //isPanning = true;
                    isRotating = true;
                }
                --currentState.RemainingTime;
                m_previousStates.Add(currentState);
            }
            if (!skipRender)
            {
                //5. Render Scene
                GameplayRendererObject.RenderScene(m_previousState, Match, CurrentSplashState);

                //6. Camera Tests
                CameraMoveTest(Match);
            }
        }
Example #7
0
        protected virtual SinglePlayerInputs GetInputs(CharacterSelectScreen gameState)
        {
            SinglePlayerInputs inputs = new SinglePlayerInputs();

            timeSinceLastPress += Time.deltaTime;
            if (timeSinceLastPress > timeBetweenPresses)
            {
                timeSinceLastPress = 0;
                inputs.A           = true;
            }
            return(inputs);
        }
Example #8
0
        //todo : place these in a strategy pattern
        protected virtual SinglePlayerInputs GetInputs(GameplayState gameState)
        {
            //1. tries to maintain a distance of attack range +50%
            //2. if opponent whiffs an attack. hit him
            //3. if opponent is in throw range. throw

            var inputs    = new SinglePlayerInputs();
            var pastState = gameState.GetPastState(0);
            var distanceBetweenCharacters = Math.Abs(pastState.P1_Position - pastState.P2_Position);
            var attackRangeAndAHalf       = GameplayConstants.HITBOX_ACTIVE_LATE * 3 / 2;

            GameplayEnums.CharacterState opponentState;
            if (p1)
            {
                opponentState = pastState.P2_CState.State;
            }
            else
            {
                opponentState = pastState.P1_CState.State;
            }

            if (distanceBetweenCharacters > attackRangeAndAHalf)
            {
                //move forward
                inputs.JoystickDirection = 6;
            }
            else
            {
                if (opponentState == GameplayEnums.CharacterState.AttackRecovery)
                {
                    inputs.A = true;
                }
                inputs.JoystickDirection = 4;
            }
            if (distanceBetweenCharacters < GameplayConstants.THROW_ACTIVE_RANGE + GameplayConstants.CHARACTER_HURTBOX_WIDTH)
            {
                inputs.B = true;
            }
            return(inputs);
        }
Example #9
0
        private SinglePlayerInputs GetInputs(bool _p1)
        {
            short direction           = 5;
            SinglePlayerInputs inputs = new SinglePlayerInputs();
            float h;
            float v;

            if (_p1)
            {
                //if(P1_Joystick)
                {
                    h = Input.GetAxisRaw("Horizontal_PsStick1") + Input.GetAxisRaw("Horizontal_KB1");;
                    v = Input.GetAxisRaw("Vertical_PsStick1") + Input.GetAxisRaw("Vertical_KB1");
                }
                //else
                //{
                //    h = Input.GetAxis("Horizontal_KB1");
                //    v = Input.GetAxis("Vertical_KB1");
                //}
                inputs.A     = Input.GetButton("A_P1");
                inputs.B     = Input.GetButton("B_P1");
                inputs.C     = Input.GetButton("C_P1");
                inputs.Start = Input.GetButtonDown("Start_P1");
            }
            else
            {
                //if (P2_Joystick)
                {
                    h = Input.GetAxisRaw("Horizontal_PsStick2") + Input.GetAxisRaw("Horizontal_KB2");
                    v = Input.GetAxisRaw("Vertical_PsStick2") + Input.GetAxisRaw("Vertical_KB2");
                }
                //else
                //{
                //    h = Input.GetAxis("Horizontal_KB2");
                //    v = Input.GetAxis("Vertical_KB2");
                //}
                inputs.A     = Input.GetButton("A_P2");
                inputs.B     = Input.GetButton("B_P2");
                inputs.C     = Input.GetButton("C_P2");
                inputs.Start = Input.GetButtonDown("Start_P2");
            }
            if (h > 0.1)
            {
                if (v > 0.1)
                {
                    if (_p1)
                    {
                        direction = 9;
                    }
                    else
                    {
                        direction = 7;
                    }
                }
                else if (v < -0.1)
                {
                    if (_p1)
                    {
                        direction = 3;
                    }
                    else
                    {
                        direction = 1;
                    }
                }
                else
                {
                    if (_p1)
                    {
                        direction = 6;
                    }
                    else
                    {
                        direction = 4;
                    }
                }
            }
            else if (h < -0.1)
            {
                if (v > 0.1)
                {
                    if (_p1)
                    {
                        direction = 7;
                    }
                    else
                    {
                        direction = 9;
                    }
                }
                else if (v < -0.1)
                {
                    if (_p1)
                    {
                        direction = 1;
                    }
                    else
                    {
                        direction = 3;
                    }
                }
                else
                {
                    if (_p1)
                    {
                        direction = 4;
                    }
                    else
                    {
                        direction = 6;
                    }
                }
            }
            else
            {
                if (v > 0.1)
                {
                    if (_p1)
                    {
                        direction = 8;
                    }
                    else
                    {
                        direction = 8;
                    }
                }
                else if (v < -0.1)
                {
                    if (_p1)
                    {
                        direction = 2;
                    }
                    else
                    {
                        direction = 2;
                    }
                }
                else
                {
                    direction = 5;
                }
            }
            inputs.JoystickDirection = direction;
            return(inputs);
        }
Example #10
0
 public virtual void HandleInputs(CharacterState _cstate, SinglePlayerInputs _currentInputs, SinglePlayerInputs _previousInputs)
 {
 }
Example #11
0
 public Inputs(SinglePlayerInputs _p1Inputs, SinglePlayerInputs _p2Inputs, CommonInputs _commonInputs)
 {
     P1_Inputs     = _p1Inputs;
     P2_Inputs     = _p2Inputs;
     Common_Inputs = _commonInputs;
 }
Example #12
0
        public SinglePlayerInputs GetInputs()
        {
#if REWIRED
            return(InputReaderRewired.GetInputs(_p1));
#endif
            short direction           = 5;
            SinglePlayerInputs inputs = new SinglePlayerInputs();
            float h;
            float v;

            if (_p1)
            {
                //if(P1_Joystick)
                {
                    h = UnityEngine.Input.GetAxisRaw("Horizontal_PsStick1") + UnityEngine.Input.GetAxisRaw("Horizontal_KB1");;
                    v = UnityEngine.Input.GetAxisRaw("Vertical_PsStick1") + UnityEngine.Input.GetAxisRaw("Vertical_KB1");
                }
                //else
                //{
                //    h = UnityEngine.Input.GetAxis("Horizontal_KB1");
                //    v = UnityEngine.Input.GetAxis("Vertical_KB1");
                //}
                inputs.A     = UnityEngine.Input.GetButton("A_P1");
                inputs.B     = UnityEngine.Input.GetButton("B_P1");
                inputs.C     = UnityEngine.Input.GetButton("C_P1");
                inputs.Start = UnityEngine.Input.GetButtonDown("Start_P1");
            }
            else
            {
                //if (P2_Joystick)
                {
                    h = UnityEngine.Input.GetAxisRaw("Horizontal_PsStick2") + UnityEngine.Input.GetAxisRaw("Horizontal_KB2");
                    v = UnityEngine.Input.GetAxisRaw("Vertical_PsStick2") + UnityEngine.Input.GetAxisRaw("Vertical_KB2");
                }
                //else
                //{
                //    h = UnityEngine.Input.GetAxis("Horizontal_KB2");
                //    v = UnityEngine.Input.GetAxis("Vertical_KB2");
                //}
                inputs.A     = UnityEngine.Input.GetButton("A_P2");
                inputs.B     = UnityEngine.Input.GetButton("B_P2");
                inputs.C     = UnityEngine.Input.GetButton("C_P2");
                inputs.Start = UnityEngine.Input.GetButtonDown("Start_P2");
            }
            if (h > 0.1)
            {
                if (v > 0.1)
                {
                    if (_p1)
                    {
                        direction = 9;
                    }
                    else
                    {
                        direction = 7;
                    }
                }
                else if (v < -0.1)
                {
                    if (_p1)
                    {
                        direction = 3;
                    }
                    else
                    {
                        direction = 1;
                    }
                }
                else
                {
                    if (_p1)
                    {
                        direction = 6;
                    }
                    else
                    {
                        direction = 4;
                    }
                }
            }
            else if (h < -0.1)
            {
                if (v > 0.1)
                {
                    if (_p1)
                    {
                        direction = 7;
                    }
                    else
                    {
                        direction = 9;
                    }
                }
                else if (v < -0.1)
                {
                    if (_p1)
                    {
                        direction = 1;
                    }
                    else
                    {
                        direction = 3;
                    }
                }
                else
                {
                    if (_p1)
                    {
                        direction = 4;
                    }
                    else
                    {
                        direction = 6;
                    }
                }
            }
            else
            {
                if (v > 0.1)
                {
                    if (_p1)
                    {
                        direction = 8;
                    }
                    else
                    {
                        direction = 8;
                    }
                }
                else if (v < -0.1)
                {
                    if (_p1)
                    {
                        direction = 2;
                    }
                    else
                    {
                        direction = 2;
                    }
                }
                else
                {
                    direction = 5;
                }
            }
            inputs.JoystickDirection = direction;
            return(inputs);
        }
Example #13
0
        protected override SinglePlayerInputs GetInputs(GameplayState gameState)
        {
            timeSinceLastStanceChange += Time.deltaTime;
            if (timeSinceLastStanceChange > timeBetweenStanceChange)
            {
                aggroMode = !aggroMode;
                timeSinceLastStanceChange = 0f;
            }
            //1. tries to maintain a distance of attack range +50%
            //2. if opponent whiffs an attack. hit him
            //3. if opponent is in throw range. throw

            var inputs    = new SinglePlayerInputs();
            var pastState = gameState.GetPastState(framesDelay);
            var distanceBetweenCharacters = Math.Abs(pastState.P1_Position - pastState.P2_Position);
            var actualAttackRange         = GameplayConstants.HITBOX_ACTIVE_LATE + GameplayConstants.CHARACTER_HURTBOX_WIDTH;

            GameplayEnums.CharacterState opponentState;
            if (p1)
            {
                opponentState = pastState.P2_CState.State;
            }
            else
            {
                opponentState = pastState.P1_CState.State;
            }

            if (aggroMode)
            {
                //move forward
                if (!p1)
                {
                    inputs.JoystickDirection = 6;
                }
                else
                {
                    inputs.JoystickDirection = 4;
                }

                int timeBeforeAttackFullyExtends_DelayConsidered   = framesDelay + GameplayConstants.ATTACK_STARTUP + GameplayConstants.ATTACK_FULL_EXTEND;
                int distanceOpponentCanCoverBeforeAttackReachesHim = -(timeBeforeAttackFullyExtends_DelayConsidered * GameplayConstants.WALK_B_SPEED);

                if (distanceOpponentCanCoverBeforeAttackReachesHim + distanceBetweenCharacters < actualAttackRange)
                {
                    inputs.A = true;
                }
            }
            else
            {
                if (distanceBetweenCharacters > actualAttackRange)
                {
                    //move forward
                    if (!p1)
                    {
                        inputs.JoystickDirection = 6;
                    }
                    else
                    {
                        inputs.JoystickDirection = 4;
                    }
                }
                else
                {
                    if (opponentState == GameplayEnums.CharacterState.AttackRecovery)
                    {
                        inputs.A = true;
                    }
                    if (p1)
                    {
                        inputs.JoystickDirection = 6;
                    }
                    else
                    {
                        inputs.JoystickDirection = 4;
                    }
                }
            }
            if (distanceBetweenCharacters < GameplayConstants.THROW_ACTIVE_RANGE + GameplayConstants.CHARACTER_HURTBOX_WIDTH)
            {
                inputs.B = true;
            }
            return(inputs);
        }