Ejemplo n.º 1
0
    public override void Step(CharControlMotor player, float deltaTime)
    {
        player.UpdateDirection(player.input.horizontal);
        player.HandleSlopeFactor(deltaTime);
        player.HandleAcceleration(deltaTime);
        player.HandleFriction(deltaTime);
        player.HandleGravity(deltaTime);
        player.HandleFall();
        if (!player.HandleLedgeCheck().Item2)
        {
            player.state.ChangeState <WalkPlayerState>();
        }

        if (player.input.actionDown)
        {
            player.HandleJump();
        }

        if (player.HandleLedgeCheck().Item1)
        {
            player.state.ChangeState <LedgeGrabStateFront>();
        }

        if (player.input.horizontal != 0 || player.velocity.x != 0)
        {
            player.state.ChangeState <WalkPlayerState>();
        }
    }
 public override void Enter(CharControlMotor player)
 {
     player.attacking = false;
     player.ChangeBounds(0);
     player.PlayAudio(player.audios.brake);
     player.UpdateDirection(player.velocity.x);
     //player.skin.SetEulerY(90 - player.direction * 90);
     player.particles.brakeSmoke.Play();
 }
    public override void Step(CharControlMotor player, float deltaTime)
    {
        player.UpdateDirection(player.input.horizontal);
        player.HandleAcceleration(deltaTime);
        player.HandleGravity(deltaTime);

        if (!player.grounded && player.attacking)
        {
            if (player.input.actionUp && player.velocity.y > player.stats.minJumpHeight)
            {
                player.velocity.y = player.stats.minJumpHeight;
            }
        }
        else
        {
            player.state.ChangeState <WalkPlayerState>();
        }
    }
Ejemplo n.º 4
0
    public override void Step(CharControlMotor player, float deltaTime)
    {
        player.UpdateDirection(player.input.horizontal);
        player.HandleAcceleration(deltaTime);
        player.HandleGravity(deltaTime);


        if (!player.grounded && player.attacking)
        {
            if (player.input.actionUp && player.velocity.y > player.stats.minJumpHeight)
            {
                player.velocity.y = player.stats.minJumpHeight;
            }

            if (dashTimer > maxDashAmount)
            {
                dashTimer = maxDashAmount;
            }

            if (active)
            {
                if (Input.GetKeyDown(DifferentKeysForJump[0]) || Input.GetKeyDown(DifferentKeysForJump[1])) //Add more if needed
                {
                    player.PlayAudio(player.audios.spindash_charge, 0.5f);

                    charging = true;
                }


                if (charging)
                {
                    dashTimer  += Time.deltaTime * chargeSpeed;
                    dashSpeed.x = dashTimer;

                    if (Input.GetKey(DifferentKeysForJump[0]) || Input.GetKey(DifferentKeysForJump[1]))
                    {
                        codedDashSpeed = dashSpeed;
                        player.PlayAudio(player.audios.peel_launch, 0.5f);

                        if (player.input.left)
                        {
                            codedDashSpeed -= codedDashSpeed * 2;
                        }
                        else if (player.input.right)
                        {
                            codedDashSpeed = dashSpeed;
                        }
                        else
                        {
                            if (player.velocity.x < 0)
                            {
                                codedDashSpeed = codedDashSpeed - codedDashSpeed * 2;
                            }
                            else if (player.velocity.x > 0)
                            {
                                codedDashSpeed = dashSpeed;
                            }
                        }
                        active          = false;
                        player.velocity = dashTarget.position - transform.position + codedDashSpeed;
                    }
                }
            }
            else if ((Input.GetKeyUp(DifferentKeysForJump[0]) || Input.GetKeyUp(DifferentKeysForJump[1])) && !charging)
            {
                active = true;
            }
        }
        else
        {
            player.state.ChangeState <WalkPlayerState>();
            player.skin.animator.SetInteger("Charge", 0);
        }
    }
Ejemplo n.º 5
0
    public override void Step(CharControlMotor player, float deltaTime)
    {
        player.UpdateDirection(player.input.horizontal);
        player.HandleSlopeFactor(deltaTime);
        player.HandleAcceleration(deltaTime);
        player.HandleFriction(deltaTime);
        player.HandleGravity(deltaTime);
        player.HandleFall();

        if (player.grounded)
        {
            if (player.input.actionDown)
            {
                player.HandleJump();
            }
            else if (player.input.down)
            {
                if (Mathf.Abs(player.velocity.x) > player.stats.minSpeedToRoll)
                {
                    player.sonicState = CharControlMotor.SonicState.Rolling;
                    player.state.ChangeState <RollPlayerState>();
                    //player.PlayAudio(player.audios.spin, 0.5f);
                }
                else if (player.angle < player.stats.minAngleToSlide)
                {
                    player.state.ChangeState <CrouchPlayerState>();
                }
            }
            else if (player.input.up)
            {
                // Changing this condition because it causes animation bugs - Arcy
                //if (Mathf.Abs(player.velocity.x) < player.stats.minSpeedToRoll)
                if (player.velocity.x == 0)
                {
                    player.state.ChangeState <LookUpPlayerState>();
                }
            }
            else if (Mathf.Sign(player.velocity.x) != Mathf.Sign(player.input.horizontal) && player.input.horizontal != 0)
            {
                if (Mathf.Abs(player.velocity.x) >= player.stats.minSpeedToBrake)
                {
                    player.state.ChangeState <BrakePlayerState>();
                }
                else
                {
                    if (player.velocity.x > 0)
                    {
                        player.velocity.x = -player.stats.turnSpeed;
                    }
                    else
                    {
                        player.velocity.x = player.stats.turnSpeed;
                    }
                }
            }
            else if (player.HandleLedgeCheck().Item1)
            {
                player.state.ChangeState <LedgeGrabStateFront>();
            }
            else if (player.HandleLedgeCheck().Item2)
            {
                player.state.ChangeState <LedgeGrabStateBack>();
            }
            else if (player.HandlePushCheck().Item1&& Mathf.Abs(player.input.horizontal) > 0)
            {
                player.state.ChangeState <PushPlayerState>();
            }
        }
    }
Ejemplo n.º 6
0
 public override void Enter(CharControlMotor player)
 {
     player.attacking = false;
     player.ChangeBounds(0);
     player.UpdateDirection(player.velocity.x);
 }