コード例 #1
0
    void UpdateUse(float dT)
    {
        bool checkUse = controls.IsUse();

        if (checkUse)
        {
            if (liftTarget)
            {
                Tool tool = liftTarget.GetComponent <Tool>() as Tool;
                if (tool)
                {
                    tool.user = this;
                    tool.Use();
                    return;
                }
            }

            if (useTarget != null)
            {
                if (
                    DistanceSquaredTo(useTarget.transform.position) < useDistanceSquared &&
                    IsFacing(useTarget.transform.position, useAngle)
                    )
                {
                    useTarget.Use(dT);
                    UpdateLookAtPosition(useTarget.transform.position, dT, turnSpeed);
                }
                else
                {
                    useTarget = null;
                }
            }

            if (useTarget == null)
            {
                Usable curTarget = GetClosestUsable(useDistanceSquared);
                if (curTarget)
                {
                    useTarget = curTarget;
                }
            }
        }
        else
        {
            useTarget = null;
        }
    }