コード例 #1
0
    private void UpdateLastValidMovementQuadrant(Vector2 velocity)
    {
        if (velocity.y == 0)
        {
            if (lastValidMovementQuadrant == Quadrant.NORTHEAST || lastValidMovementQuadrant == Quadrant.NORTHWEST)
            {
                if (velocity.x > 0)
                {
                    lastValidMovementQuadrant = Quadrant.NORTHEAST;
                }
                else
                {
                    lastValidMovementQuadrant = Quadrant.NORTHWEST;
                }
            }
            else
            {
                if (velocity.x > 0)
                {
                    lastValidMovementQuadrant = Quadrant.SOUTHEAST;
                }
                else
                {
                    lastValidMovementQuadrant = Quadrant.SOUTHWEST;
                }
            }
        }
        else if (velocity.x == 0)
        {
            if (lastValidMovementQuadrant == Quadrant.NORTHEAST || lastValidMovementQuadrant == Quadrant.SOUTHEAST)
            {
                if (velocity.y > 0)
                {
                    lastValidMovementQuadrant = Quadrant.NORTHEAST;
                }
                else
                {
                    lastValidMovementQuadrant = Quadrant.SOUTHEAST;
                }
            }
            else
            {
                if (velocity.y > 0)
                {
                    lastValidMovementQuadrant = Quadrant.NORTHWEST;
                }
                else
                {
                    lastValidMovementQuadrant = Quadrant.SOUTHWEST;
                }
            }
        }
        else if (velocity.x > 0 && velocity.y > 0)
        {
            // 1st quad
            lastValidMovementQuadrant = Quadrant.NORTHEAST;
        }
        else if (velocity.x > 0)
        {
            // 2nd quad
            lastValidMovementQuadrant = Quadrant.SOUTHEAST;
        }
        else if (velocity.y < 0)
        {
            // 3rd quad
            lastValidMovementQuadrant = Quadrant.SOUTHWEST;
        }
        else
        {
            // 4th quad
            lastValidMovementQuadrant = Quadrant.NORTHWEST;
        }

        interactionTrigger.UpdateTriggerPosition(lastValidMovementQuadrant);
    }