Exemplo n.º 1
0
    private bool GetActualTarget(ref Vector2 actualTargetPosition, ref float actualTargetOrthoSize)
    {
        bool targetValid = false;

        switch (targetMode)
        {
        case TARGET_MODE_POSITION:
            actualTargetPosition  = new Vector2(targetPositionX, targetPositionY);
            actualTargetOrthoSize = originalOrthographicSize;
            targetValid           = true;
            break;

        case TARGET_MODE_PLAYER:
            if (targetPlayerTransform != null)
            {
                actualTargetPosition  = new Vector2(targetPlayerTransform.position.x, targetPlayerTransform.position.y);
                actualTargetPosition += targetPlayer.GetVelocity() * VELOCITY_TO_OFFSET_FACTOR;
                actualTargetOrthoSize = originalOrthographicSize + targetPlayer.GetVelocity().sqrMagnitude *VELOCITY_TO_ORTHO_FACTOR;
                if (actualTargetOrthoSize > maxOrthographicSize)
                {
                    actualTargetOrthoSize = maxOrthographicSize;
                }
                targetValid = true;
            }
            break;

        case TARGET_MODE_NPC:
            if (targetNPCTransform != null)
            {
                actualTargetPosition  = new Vector2(targetNPCTransform.position.x, targetNPCTransform.position.y);
                actualTargetPosition += targetNPC.GetVelocity() * VELOCITY_TO_OFFSET_FACTOR;
                actualTargetOrthoSize = originalOrthographicSize + targetNPC.GetVelocity().sqrMagnitude *VELOCITY_TO_ORTHO_FACTOR;
                if (actualTargetOrthoSize > maxOrthographicSize)
                {
                    actualTargetOrthoSize = maxOrthographicSize;
                }
                targetValid = true;
            }
            break;

        case TARGET_MODE_MIDWAY:
            if ((targetPlayerTransform != null) && (targetNPCTransform != null))
            {
                actualTargetPosition = new Vector2((targetPlayerTransform.position.x + targetNPCTransform.position.x) / 2f,
                                                   (targetPlayerTransform.position.y + targetNPCTransform.position.y) / 2f);
                actualTargetOrthoSize = originalOrthographicSize;
                targetValid           = true;
            }
            break;

        case TARGET_MODE_EDITOR:
            actualTargetPosition  = new Vector2(transform.position.x, transform.position.y);
            actualTargetOrthoSize = originalOrthographicSize;
            targetValid           = true;
            break;
        }
        if (farCamera)
        {
            actualTargetOrthoSize += farCameraOrthoIncrease;
        }
        return(targetValid);
    }