Exemplo n.º 1
0
        public override void OnUpdate(MainPlayerMovementFSM playerFSM)
        {
            if (Mathf.Abs(playerFSM.horizontalInput) == 0 && Mathf.Abs(playerFSM.verticalInput) == 0)
            {
                playerFSM.EnterState(playerFSM.idleState, true);
                return;
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                playerFSM.EnterState(playerFSM.jumpingState, true);
                return;
            }

            if (Input.GetKey(KeyCode.Mouse0))
            {
                playerFSM.EnterState(playerFSM.attackingReadyState, true);
                return;
            }

            if (Input.GetKeyDown(KeyCode.LeftShift) && playerFSM.IsMoving())
            {
                Debug.Log("Shift pressed!");
                playerFSM.EnterState(playerFSM.rollingState, true);
            }
        }
Exemplo n.º 2
0
        public override void OnUpdate(MainPlayerMovementFSM playerFSM)
        {
            timerTime += Time.deltaTime;

            if (timerTime >= playerFSM.timeBeforeRollCompleted)
            {
                playerFSM.anim.SetTrigger("RollingEnds");
                playerFSM.EnterState(playerFSM.idleState, true);
            }
        }
Exemplo n.º 3
0
        public override void OnUpdate(MainPlayerMovementFSM playerFSM)
        {
            //playerFSM.Move();

            if (Mathf.Abs(playerFSM.horizontalInput) > 0 || Mathf.Abs(playerFSM.verticalInput) > 0)
            {
                playerFSM.EnterState(playerFSM.runningState, true);
                return;
            }

            if (Input.GetKeyDown(KeyCode.Space))
            {
                playerFSM.EnterState(playerFSM.jumpingState, true);
                return;
            }

            if (Input.GetKey(KeyCode.Mouse0))
            {
                playerFSM.EnterState(playerFSM.attackingReadyState, true);
                return;
            }
        }
Exemplo n.º 4
0
        public override void OnFixedUpdate(MainPlayerMovementFSM playerFSM)
        {
            if (playerFSM.AirControl)
            {
                playerFSM.MoveFixed();
            }

            if (timerTime >= timeBeforeJumpCheck)
            {
                isJumping = true;
            }

            if (isJumping)
            {
                Collider[] colliders = Physics.OverlapSphere(playerFSM.GroundCheckPoint.position, playerFSM.GroundCheckRadius, playerFSM.GroundMask);
                if (colliders.Length > 0)
                {
                    isJumping = false;
                    playerFSM.EnterState(playerFSM.idleState, true);
                }
            }
        }