示例#1
0
    private void giveSound()
    {
        walking = true;
        bool inRange = false;

        foreach (GuardDetection g in guards)
        {
            Vector3 position = g.gameObject.transform.position;
            float   distance = (position - theTransform.position).magnitude;
            float   range    = g.hearingRange;
            switch (running)
            {
            case RunningState.running:
                range *= 2;
                break;

            case RunningState.silent:
                range /= 2;
                break;

            default:
                break;
            }
            inRange = distance <= range? true: inRange;
        }
        if (inRange)
        {
            Node closestNode = info.nearestNode(theTransform.position);
            manager.distributeOnSound(closestNode);
        }
    }