Esempio n. 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));
        }
Esempio n. 2
0
 /// <summary>
 /// The actor leaves a dark area.
 /// </summary>
 public void OnLeaveDarkness(DarkZone zone)
 {
     if (_darkZones.Contains(zone))
     {
         _darkZones.Remove(zone);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// The actor enters a dark area.
 /// </summary>
 public void OnEnterDarkness(DarkZone zone)
 {
     if (!_darkZones.Contains(zone))
     {
         _darkZones.Add(zone);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Notified of an entrance to a dark area.
        /// </summary>
        public void OnEnterDarkness(DarkZone zone)
        {
            _darkzoneCount++;

            if (_darkzoneCount == 1)
            {
                Message("OnNeedLight");
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Notified of an exit out of a dark area.
        /// </summary>
        public void OnLeaveDarkness(DarkZone zone)
        {
            _darkzoneCount--;

            if (_darkzoneCount == 0)
            {
                Message("OnDontNeedLight");
            }
        }
Esempio n. 6
0
        public static void Register(DarkZone zone)
        {
            if (!_list.Contains(zone))
            {
                _list.Add(zone);
            }

            _map[zone.gameObject] = zone;
        }
Esempio n. 7
0
        public static void Unregister(DarkZone zone)
        {
            if (_list.Contains(zone))
            {
                _list.Remove(zone);
            }

            if (_map.ContainsKey(zone.gameObject))
            {
                _map.Remove(zone.gameObject);
            }
        }
Esempio n. 8
0
        static void Gizmo(DarkZone zone, GizmoType type)
        {
            var isSelected = (type & GizmoType.Selected) != 0;
            var alpha      = isSelected ? 0.8f : 0.4f;

            var collider = zone.GetComponent <BoxCollider>();

            if (collider != null)
            {
                var bounds = collider.bounds;

                Gizmos.color = new Color(0.5f, 0.5f, 1.0f, alpha);
                Gizmos.DrawCube(bounds.center, bounds.extents * 2);
            }
        }