示例#1
0
        public static float GetViewDistance(Vector3 position, float viewDistance, bool isAlerted)
        {
            var count = Physics.OverlapSphereNonAlloc(position, 1, Colliders, Layers.Zones, QueryTriggerInteraction.Collide);

            _dark.Clear();
            _light.Clear();
            _grass.Clear();

            for (int i = 0; i < count; i++)
            {
                {
                    var zone = DarkZone.Get(Colliders[i].gameObject);
                    if (zone != null)
                    {
                        _dark.Add(zone);
                    }
                }
                {
                    var zone = LightZone.Get(Colliders[i].gameObject);
                    if (zone != null)
                    {
                        _light.Add(zone);
                    }
                }
                {
                    var zone = GrassZone.Get(Colliders[i].gameObject);
                    if (zone != null)
                    {
                        _grass.Add(zone);
                    }
                }
            }

            return(GetViewDistance(viewDistance, _dark, _light, _grass, isAlerted));
        }
示例#2
0
 /// <summary>
 /// The actor leaves a lighted area.
 /// </summary>
 public void OnLeaveLight(LightZone zone)
 {
     if (_lightZones.Contains(zone))
     {
         _lightZones.Remove(zone);
     }
 }
示例#3
0
 /// <summary>
 /// The actor enters a flashlight or any similar object.
 /// </summary>
 public void OnEnterLight(LightZone zone)
 {
     if (!_lightZones.Contains(zone))
     {
         _lightZones.Add(zone);
     }
 }
示例#4
0
        public static void Register(LightZone zone)
        {
            if (!_list.Contains(zone))
            {
                _list.Add(zone);
            }

            _map[zone.gameObject] = zone;
        }
示例#5
0
        public static void Unregister(LightZone zone)
        {
            if (_list.Contains(zone))
            {
                _list.Remove(zone);
            }

            if (_map.ContainsKey(zone.gameObject))
            {
                _map.Remove(zone.gameObject);
            }
        }