コード例 #1
0
    public override void OnFixedUpdate()
    {
        // Detect Ground
        data.groundDetectionData.DetectGround(!jumpData.isJumping, data.RB2D, transform);
        data.groundDetectionData.ExecuteOnGroundMethod(this);

        // Fall Through
        fallThroughKeyPressed = PlayerInputManager.Inst.Input_FallThrough;
        data.groundDetectionData.FallThrough(ref fallThroughKeyPressed, data.RB2D, transform, oneWayCollider);

        // Walk
        PlayerStats.Inst.walkData.Walk(PlayerInputManager.Inst.Input_WalkDir, data.RB2D, jumpData.isJumping);

        // Follow Moving Platform
        data.groundDetectionData.FollowMovingPlatform(data.RB2D);

        // Jump
        if (jumpData.Jump(ref PlayerInputManager.Inst.Input_Jump, data.RB2D, transform))
        {
            PlayerActionEventManager.Trigger(PlayerActions.Jump);
        }

        // Gravity
        Gravity_Logic.ApplyGravity(data.RB2D,
                                   data.groundDetectionData.isGrounded || jumpData.isJumping
            ? GravityData.Zero
            : data.gravityData);

        // Update Animation
        UpdateAnimation();
    }
コード例 #2
0
    public override void OnFixedUpdate()
    {
        // Gravity
        Gravity_Logic.ApplyGravity(data.RB2D, data.gravityData);

        // Slowdown X Velocity
        data.RB2D.velocity = data.RB2D.velocity.Change(x: data.RB2D.velocity.x * 0.6f);
    }
コード例 #3
0
    public override void OnFixedUpdate()
    {
        // Stunned
        if (!PlayerStatus.IsKnockbacked)
        {
            // 0 X Velocity
            data.RB2D.velocity = data.RB2D.velocity.Change(x: 0);

            // Reset knockback time
            curKnockbackTime = 0;

            // Gravity
            Gravity_Logic.ApplyGravity(data.RB2D,
                                       data.groundDetectionData.isGrounded ? GravityData.Zero :
                                       data.gravityData);
        }
        // Knockbacked
        else
        {
            if (data.KnockbackStarted)
            {
                data.KnockbackStarted = false;

                // Reset knockback time
                curKnockbackTime = 0;

                // Set Current Gravity
                curKnockbackGravity = PlayerStatus.ResetGravityOnKnockback ? 0 : data.RB2D.velocity.y;

                // Start New Knockback Animation
                playKnockbackAnim = true;
            }

            // Gravity
            Gravity_Logic.ApplyGravity(ref curKnockbackGravity,
                                       data.groundDetectionData.isGrounded ? GravityData.Zero :
                                       data.gravityData);

            // Calc Knockback Velocity
            Vector2 knockbackVel = PlayerStatus.KnockbackDir.normalized * PlayerStatus.KnockbackCurve.Evaluate(curKnockbackTime);
            curKnockbackTime += Time.fixedDeltaTime;

            // Apply Velocity
            data.RB2D.velocity = knockbackVel + new Vector2(0, curKnockbackGravity);
        }

        // Detect Ground
        data.groundDetectionData.DetectGround(!PlayerStatus.IsKnockbacked || data.RB2D.velocity.y <= 0, data.RB2D, transform);
    }
コード例 #4
0
    public override void OnFixedUpdate()
    {
        // Detect Ground
        data.groundDetectionData.DetectGround(true, data.RB2D, transform);

        // Walk
        PlayerStats.Inst.walkData.Walk(PlayerInputManager.Inst.Input_WalkDir, data.RB2D, false);

        // Follow Moving Platform
        data.groundDetectionData.FollowMovingPlatform(data.RB2D);

        // Gravity
        Gravity_Logic.ApplyGravity(data.RB2D,
                                   data.groundDetectionData.isGrounded ? GravityData.Zero :
                                   data.gravityData);
    }
コード例 #5
0
    private void FixedUpdate()
    {
        m_groundDetectionData.DetectGround(!m_jumpData.isJumping, m_rb, transform);
        m_groundDetectionData.ExecuteOnGroundMethod(this);
        var OverlapSlowSpeed = (CheckOverlapSlow(MobSize, new Vector2(m_MoveData.Dir, 0)) ? OverlapSlow : 1f);

        m_rb.velocity = new Vector2(m_bFollowJump && m_jumpData.isJumping ? VelX : VelX * m_SEObj.SpeedMult * OverlapSlowSpeed, VelY);
        if (m_SEObj.UseSEVel)
        {
            m_rb.velocity = m_SEObj.EffectDir2d * m_SEObj.SpeedMult;
        }
        if (!m_SEObj.UseSEVelCurve)
        {
            CurveTime = 0f;
        }
        if (m_SEObj.UseSEVelCurve)
        {
            m_rb.velocity = m_SEObj.EffectDir2d * m_SEObj.VelCurve.Evaluate(CurveTime);
            CurveTime    += Time.fixedDeltaTime;
        }
        m_groundDetectionData.FallThrough(ref m_bFallStart, m_rb, transform, m_OneWayCollider);


        m_jumpData.Jump(ref m_bJumpStart, m_rb, transform);


        Gravity_Logic.ApplyGravity(m_rb, m_groundDetectionData.isGrounded ? new GravityData(false, 0, 0) :
                                   m_bFollowJump ? m_gravityData :
                                   !m_jumpData.isJumping ? m_gravityData : new GravityData(true, m_jumpData.jumpGravity, 0));


        Animation();
        m_ani.SetDuration(m_Ani[m_CurAniST].Item2);
        if (m_bAniStart)
        {
            m_ani.Play(m_Ani[m_CurAniST].Item1, 0, 0); m_bAniStart = false;
        }
        else
        {
            m_ani.Play(m_Ani[m_CurAniST].Item1);
        }
    }