コード例 #1
0
    void FixedUpdate()
    {
        speedStretch = m_Rigidbody.velocity.y * Time.fixedDeltaTime;
        if (speedStretch > -0.05f)
        {
            speedStretch = -0.05f;
        }
        collisionDownEnter = collisionDown;
        collisionDown      = CollisionUtilities.GetCollision(this.gameObject,
                                                             //Vector3.down * (m_boxCollider.size.y / 2f), new Vector2(0.55f, -speedStretch * 2), layer, true);
                                                             Vector3.down * (m_boxCollider.size.y / 2f), new Vector2(0.55f, 0.1f), layer, true);
        collisionDownEnter = collisionDown != collisionDownEnter && collisionDown;

        if (collisionDown)
        {
            collisionDownTimer = coyoteTime;
        }
        collisionDownTimer -= Time.fixedDeltaTime;

        //speedStretch = m_Rigidbody.velocity.y * Time.fixedDeltaTime;
        //if (speedStretch < 0.05f) speedStretch = 0.05f;
        collisionUpEnter = collisionUp;
        collisionUp      = CollisionUtilities.GetCollision(this.gameObject,
                                                           //Vector3.up * (m_boxCollider.size.y / 2f), new Vector2(0.5f, speedStretch * 2), collisionUpLayer, true);
                                                           Vector3.up * (m_boxCollider.size.y / 2f), new Vector2(0.5f, 0.1f), collisionUpLayer, true);
        collisionUpEnter = collisionUp != collisionUpEnter;

        collisionUpLeft = CollisionUtilities.GetCollision(this.gameObject,
                                                          Vector3.up * (m_boxCollider.size.y / 2f + 0.1f) + Vector3.left * 0.24f, new Vector2(0.1f, 0.3f), collisionUpLayer);
        collisionUpRight = CollisionUtilities.GetCollision(this.gameObject,
                                                           Vector3.up * (m_boxCollider.size.y / 2f + 0.1f) + Vector3.right * 0.24f, new Vector2(0.1f, 0.3f), collisionUpLayer);
        collisionUpMiddle = CollisionUtilities.GetCollision(this.gameObject,
                                                            Vector3.up * (m_boxCollider.size.y / 2f + 0.1f), new Vector2(0.4f, 0.3f), collisionUpLayer);

        collisionDanger = CollisionUtilities.GetCollision(this.gameObject,
                                                          Vector3.zero, new Vector2(0.6f, 1.2f), dangerLayer);

        collisionLeftStep = CollisionUtilities.GetCollisionDistance(this.gameObject,
                                                                    Vector2.left * (m_boxCollider.size.x / 2f + (0.1f * detectDistance)), Vector2.down, m_boxCollider.size.y / 2f, layer);
        collisionRightStep = CollisionUtilities.GetCollisionDistance(this.gameObject,
                                                                     Vector2.right * (m_boxCollider.size.x / 2f + (0.1f * detectDistance)), Vector2.down, m_boxCollider.size.y / 2f, layer);
    }
コード例 #2
0
    void FixedUpdate()
    {
        if (isCarried)
        {
            collisionDownLayer = collisionUpLayer;
            gameObject.layer   = LayerUtilities.LayerNumber(carriedIdolLayer);
        }
        else
        {
            collisionDownLayer = layer;
            gameObject.layer   = LayerUtilities.LayerNumber(idolLayer);
        }

        speedStretchX = m_Rigidbody.velocity.x * Time.fixedDeltaTime;
        speedStretchY = m_Rigidbody.velocity.y * Time.fixedDeltaTime;
        if (speedStretchY > -0.05f)
        {
            speedStretchY = -0.05f;
        }
        collisionDownEnter = collisionDown;
        collisionDown      = CollisionUtilities.GetCollision(this.gameObject,
                                                             Vector3.down * -speedStretchY + Vector3.right * speedStretchX,
                                                             new Vector2(0.25f, 0.6f), collisionDownLayer, true) ||
                             (m_Velocity.y > yVelocityBuffer && yVelocityBuffer <= 0f && !isCarried);
        collisionDownEnter = collisionDown != collisionDownEnter;

        speedStretchY = m_Rigidbody.velocity.y * Time.fixedDeltaTime;
        if (speedStretchY < 0.05f)
        {
            speedStretchY = 0.05f;
        }
        collisionUpEnter = collisionUp;
        collisionUp      = CollisionUtilities.GetCollision(this.gameObject,
                                                           Vector3.up * (m_boxCollider.size.y / 2f + 0.05f), new Vector2(0.25f, (speedStretchY + 0.05f) * 2f), collisionUpLayer, true);
        collisionUpEnter = collisionUp != collisionUpEnter;

        collisionLeft = CollisionUtilities.GetCollision(this.gameObject,
                                                        Vector3.left * (m_boxCollider.size.x / 2f) + Vector3.down * 0.05f, new Vector2(0.1f, 0.5f), collisionUpLayer);

        collisionRight = CollisionUtilities.GetCollision(this.gameObject,
                                                         Vector3.right * (m_boxCollider.size.x / 2f) + Vector3.down * 0.05f, new Vector2(0.1f, 0.5f), collisionUpLayer);

        collisionDanger = CollisionUtilities.GetCollision(this.gameObject,
                                                          Vector3.zero, new Vector2(0.3f, 0.6f), dangerLayer);

        collisionCarryPlayer = CollisionUtilities.GetCollisionDistance(player.gameObject,
                                                                       Vector2.zero, Vector2.up, carryHeight + 0.6f, player.GetCollisionUpLayer());

        collisionCarry = CollisionUtilities.GetCollisionDistance(player.gameObject,
                                                                 new Vector2(m_Rigidbody.position.x - playerRigidbody.position.x, 0f),
                                                                 Vector2.up, carryHeight + 0.6f, collisionUpLayer);

        collisionTeleport = CollisionUtilities.GetCollision(this.gameObject,
                                                            Vector3.up * 0.35f + Vector3.left * 0.225f, new Vector2(0.15f, 1.1f), collisionUpLayer) &&
                            CollisionUtilities.GetCollision(this.gameObject,
                                                            Vector3.up * 0.35f + Vector3.right * 0.225f, new Vector2(0.15f, 1.1f), collisionUpLayer);

        float n; if (teleportRechargeTimer < 0)

        {
            n = 0;
        }
        else
        {
            n = teleportRechargeTimer;                                                 /////
        }
        CollisionUtilities.GetCollision(this.gameObject,
                                        Vector3.right * 0.5f, new Vector2(0.1f, n * 3f), layer, true);

        teleportTimer         -= Time.fixedDeltaTime;
        teleportRechargeTimer -= Time.fixedDeltaTime;
        rechargeIndicator.SetFill(teleportRechargeTimer / teleportRechargeDuration);
        yVelocityBuffer = m_Velocity.y;
    }