private void FixedUpdate()
        {
            var _velocity_Y = characterRigidBody.velocity.y;

            if (_velocity_Y < 0)
            {
                characterAnimator.SetInteger(INT_STATE, (int)CharacterState.Fall);
            }

            if (IsGrounded)
            {
                AudioManager.Instance.PlaySound(characterSounds.GroundedSound);

                if (Mathf.Abs(HorizontalAxes) > Mathf.Epsilon)
                {
                    NextStateAction.Invoke(CharacterState.Move);
                }
                else
                {
                    NextStateAction.Invoke(CharacterState.Idle);
                }
            }

            if (Mathf.Abs(HorizontalAxes) > 0)
            {
                characterRigidBody.velocity = new Vector2(HorizontalAxes * GameInfo.Instance.CharData.Speed, characterRigidBody.velocity.y);
            }

            SpriteFlipper.FlipSprite(characterRigidBody, characterSpriteRenderer);
        }
Beispiel #2
0
    private void FixedUpdate()
    {
        var _velocity = rBody2D.velocity;

        _velocity.x = Vector2.right.x * speed * HorizontalValue;

        if (_velocity.x > 0)
        {
            playerSprite.flipX = false;
        }
        else if (_velocity.x < 0)
        {
            playerSprite.flipX = true;
        }

        if (IsGrounded)
        {
            if (_velocity.x == 0)
            {
                NextStateAction.Invoke(PlayerState.Idle);
            }
            else
            {
                NextStateAction.Invoke(PlayerState.Run);
            }
        }
        else if (_velocity.y < lowYVelosity)
        {
            NextStateAction.Invoke(PlayerState.Fall);
        }

        rBody2D.velocity = _velocity;
    }
        public void FixedUpdate()
        {
            if (characterRigidBody.velocity.y < 0)
            {
                characterRigidBody.velocity += Vector2.up * Physics2D.gravity * gravityMultiplyer * Time.deltaTime;
            }

            if (JumpAxes > Mathf.Epsilon)
            {
                NextStateAction.Invoke(CharacterState.Jump);
            }

            if (IsGrounded)
            {
                AudioManager.Instance.PlaySound(characterSounds.GroundedSound);

                if (Mathf.Abs(HorizontalAxes) > Mathf.Epsilon)
                {
                    NextStateAction.Invoke(CharacterState.Move);
                }
                else
                {
                    NextStateAction.Invoke(CharacterState.Idle);
                }
            }

            if (Mathf.Abs(HorizontalAxes) > 0)
            {
                characterRigidBody.velocity = new Vector2(HorizontalAxes * GameInfo.Instance.CharData.Speed, characterRigidBody.velocity.y);
            }

            SpriteFlipper.FlipSprite(characterRigidBody, characterSpriteRenderer);
        }
Beispiel #4
0
 public virtual void OnCollision(Collision2D collision)
 {
     if (collision.transform.tag == "Poison" || collision.transform.tag == "Enemy")
     {
         NextStateAction.Invoke(PlayerState.Die);
     }
 }
Beispiel #5
0
    private void FixedUpdate()
    {
        var _velocity = rBody2D.velocity;

        if (JumpValue > 0)
        {
            if (IsNearLeftWall)
            {
                _velocity          = Vector2.one * jumpForce;
                playerSprite.flipX = false;
            }
            else if (IsNearRightWall)
            {
                _velocity.x        = Vector2.one.x * jumpForce * -1;
                _velocity.y        = Vector2.one.y * jumpForce;
                playerSprite.flipX = true;
            }
        }

        rBody2D.velocity = _velocity;

        if (_velocity.y < 0)
        {
            NextStateAction.Invoke(PlayerState.Fall);
        }
        else if (IsGrounded)
        {
            NextStateAction.Invoke(PlayerState.Idle);
        }
    }
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.S))
     {
         if (GameInfo.Instance.CharData.HasFastFall && GameInfo.Instance.CharData.HasReloadedFastFall)
         {
             NextStateAction.Invoke(CharacterState.FastFall);
         }
     }
 }
Beispiel #7
0
 private void FixedUpdate()
 {
     if (JumpValue > 0 && (IsNearLeftWall || IsNearRightWall))
     {
         NextStateAction.Invoke(PlayerState.AngleJump);
     }
     else if (IsGrounded)
     {
         NextStateAction.Invoke(PlayerState.Idle);
     }
 }
Beispiel #8
0
 public virtual void OnTrigger(Collider2D collision)
 {
     if (collision.tag == "HappyEnd")
     {
         NextStateAction.Invoke(PlayerState.Win);
     }
     else if (collision.tag == "Stair")
     {
         NextStateAction.Invoke(PlayerState.Climb);
     }
 }
Beispiel #9
0
        private void FixedUpdate()
        {
            if (Mathf.Abs(HorizontalAxes) > 0)
            {
                characterRigidBody.velocity = new Vector2(HorizontalAxes * speed, characterRigidBody.velocity.y);

                if (JumpAxes > Mathf.Epsilon)
                {
                    NextStateAction.Invoke(CharacterState.Jump);
                }
            }
        }
        private void FixedUpdate()
        {
            if (IsGrounded)
            {
                AudioManager.Instance.PlaySound(characterSounds.GroundedSound);

                if (Mathf.Abs(HorizontalAxes) > Mathf.Epsilon)
                {
                    NextStateAction.Invoke(CharacterState.Move);
                }
                else
                {
                    NextStateAction.Invoke(CharacterState.Idle);
                }
            }
        }
    private void FixedUpdate()
    {
        var _velocity = rBody2D.velocity;

        _velocity.y      = VerticalValue * speed * Vector2.up.y;
        _velocity.x      = Vector2.right.x * HorizontalValue * speed;
        rBody2D.velocity = _velocity;

        if (IsGrounded)
        {
            NextStateAction.Invoke(PlayerState.Idle);
        }
        else if (!IsGrounded)
        {
            NextStateAction.Invoke(PlayerState.Fall);
        }
    }
Beispiel #12
0
        private void FixedUpdate()
        {
            if (IsGrounded)
            {
                if (Mathf.Abs(HorizontalAxes) > Mathf.Epsilon)
                {
                    NextStateAction.Invoke(CharacterState.Move);
                }

                if (JumpAxes > Mathf.Epsilon)
                {
                    NextStateAction.Invoke(CharacterState.Jump);
                }
            }
            else
            {
                NextStateAction.Invoke(CharacterState.Fall);
            }
        }
 private void FixedUpdate()
 {
     if (HorizontalValue != 0)
     {
         NextStateAction.Invoke(PlayerState.Run);
     }
     else if (JumpValue != 0)
     {
         NextStateAction.Invoke(PlayerState.Jump);
     }
     else if (VerticalValue < 0)
     {
         NextStateAction.Invoke(PlayerState.Duck);
     }
     else
     {
         var _velocity = rBody2D.velocity;
         _velocity.x      = 0;
         rBody2D.velocity = _velocity;
     }
 }
    private void FixedUpdate()
    {
        var _velocity = rBody2D.velocity;

        _velocity.x      = Vector2.right.x * speed * HorizontalValue;
        rBody2D.velocity = _velocity;

        if (_velocity.x > 0)
        {
            playerSprite.flipX = false;
        }
        else if (_velocity.x < 0)
        {
            playerSprite.flipX = true;
        }

        if (VerticalValue >= 0 && !IsCeilingAbove)
        {
            colliderToHide.enabled = true;
            NextStateAction.Invoke(PlayerState.Run);
        }
    }
        private void Update()
        {
            timer -= Time.deltaTime;

            if (Input.GetKeyDown(KeyCode.S))
            {
                if (GameInfo.Instance.CharData.HasFastFall && GameInfo.Instance.CharData.HasReloadedFastFall)
                {
                    NextStateAction.Invoke(CharacterState.FastFall);
                }
            }

            if (IsSecondJumpAvaliable)
            {
                if (Input.GetKeyDown(KeyCode.Space))
                {
                    if (GameInfo.Instance.CharData.HasDoubleJump && GameInfo.Instance.CharData.HasReloadedDoubleJump)
                    {
                        NextStateAction.Invoke(CharacterState.DoubleJump);
                    }
                }
            }
        }
        private void FixedUpdate()
        {
            if (IsGrounded)
            {
                if (Mathf.Abs(HorizontalAxes) > 0)
                {
                    characterRigidBody.velocity = new Vector2(HorizontalAxes * GameInfo.Instance.CharData.Speed, characterRigidBody.velocity.y);

                    if (DashAxes > Mathf.Epsilon)
                    {
                        if (GameInfo.Instance.CharData.HasDash)
                        {
                            if (GameInfo.Instance.CharData.HasReloadedDash)
                            {
                                NextStateAction(CharacterState.Dash);
                                PlayerUsedDash.Invoke();
                            }
                        }
                    }

                    if (JumpAxes > Mathf.Epsilon)
                    {
                        NextStateAction.Invoke(CharacterState.Jump);
                    }
                }
                else
                {
                    NextStateAction.Invoke(CharacterState.Idle);
                }

                SpriteFlipper.FlipSprite(characterRigidBody, characterSpriteRenderer);
            }
            else
            {
                NextStateAction.Invoke(CharacterState.Fall);
            }
        }