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

            if (_darkzoneCount == 1)
            {
                Message("OnNeedLight");
            }
        }
Ejemplo 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");
            }
        }
Ejemplo n.º 6
0
        public static void Register(DarkZone zone)
        {
            if (!_list.Contains(zone))
            {
                _list.Add(zone);
            }

            _map[zone.gameObject] = zone;
        }
Ejemplo 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);
            }
        }
Ejemplo 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);
            }
        }