예제 #1
0
        public static float GetViewDistance(Vector3 position, float viewDistance, bool isAlerted)
        {
            var count = Physics.OverlapSphereNonAlloc(position, 1, _colliders, 0x1 << 8, QueryTriggerInteraction.Collide);

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

            for (int i = 0; i < count; i++)
            {
                {
                    var zone = DarkZones.Get(_colliders[i].gameObject);
                    if (zone != null)
                    {
                        _dark.Add(zone);
                    }
                }
                {
                    var zone = LightZones.Get(_colliders[i].gameObject);
                    if (zone != null)
                    {
                        _light.Add(zone);
                    }
                }
                {
                    var zone = GrassZones.Get(_colliders[i].gameObject);
                    if (zone != null)
                    {
                        _grass.Add(zone);
                    }
                }
            }

            return(GetViewDistance(viewDistance, _dark, _light, _grass, isAlerted));
        }
예제 #2
0
 private void OnDestroy()
 {
     GrassZones.Unregister(this);
 }
예제 #3
0
 private void OnDisable()
 {
     GrassZones.Unregister(this);
 }
예제 #4
0
 private void OnEnable()
 {
     GrassZones.Register(this);
 }