Пример #1
0
    void FixedUpdate()
    {
        horz = InputWrapper.GetHorz();
        vert = InputWrapper.GetVert();

        vel         = body.velocity;
        overrideVel = Vector2.positiveInfinity;

        applyGravity  = true;
        trail.enabled = true;

        UpdateContacts();
        pbash.UpdateBashCommon();

        if (!isGrounded)
        {
            groundNormal = 0;
        }
        if (!isWall)
        {
            wallNormal = 0;
        }

        switch (mode)
        {
        case MoveMode.STANDARD:

            var pmoveVel = pmove.Update();
            OverrideNonZero(ref vel, pmoveVel);

            if (isGrounded && horz == 0)
            {
                vel.x = pmoveVel.x;
            }

            vel.x += pjump.Update().x;
            pdash.Update();


            if (!isGrounded && isWall)
            {
                mode = MoveMode.WALL;
            }

            break;

        case MoveMode.WALL:

            trail.enabled = false;

            OverrideNonZero(ref vel, pmove.Update());
            OverrideNonZero(ref vel, pwall.Update());
            OverrideNonZero(ref vel, pwalljump.Update());
            pdash.Update();

            if (isGrounded || !isWall)
            {
                mode = MoveMode.STANDARD;
            }

            break;

        case MoveMode.BASH:
            if (!pbash.bashTarget)
            {
                mode = MoveMode.STANDARD;
                break;
            }
            OverrideNonZero(ref vel, pbash.Update());

            break;

        case MoveMode.STOMP:

            break;

        case MoveMode.PUSH:

            break;

        default:
            mode = MoveMode.STANDARD;
            break;
        }

        body.gravityScale = applyGravity ? initGravityScale : 0;

        OverrideNonInf(ref vel, overrideVel);
        body.velocity = vel;
        //pmove.SetX(vel.x);
    }