예제 #1
0
        public float DistanceInsideUpperBorder(SpecialZone type, Vector3 position)
        {
            float ret = float.NaN;

            var zones = _zones[type];

            foreach (var zone in zones)
            {
                if (InZone(zone, position))
                {
                    ret = zone.Center.y + zone.HalfSize.y;
                    break;
                }
            }

            return(ret);
        }
예제 #2
0
        private void AddZone(SpecialZone type, Vector3 max, Vector3 min, Vector3 rotation)
        {
            if (!_zones.ContainsKey(type))
            {
                _zones.Add(type, new List <Zone>());
            }
            var newZone = new Zone
            {
                Center          = (max + min) * 0.5f,
                HalfSize        = (max - min) * 0.5f,
                InverseRotation = Quaternion.Euler(rotation),
            };

            newZone.Radius            = newZone.HalfSize.sqrMagnitude;
            newZone.InverseRotation.w = -newZone.InverseRotation.w;
            _zones[type].Add(newZone);
        }
예제 #3
0
        public float DistanceInsideUpperBorder(SpecialZone type, Vector3 position)
        {
            float       ret = float.NaN;
            List <Zone> zones;

            if (_zones.TryGetValue(type, out zones))
            {
                foreach (var zone in zones)
                {
                    if (InZone(zone, position))
                    {
                        ret = zone.Center.y + zone.HalfSize.y;
                        break;
                    }
                }
            }

            return(ret);
        }
예제 #4
0
        public float GetHeightOfUpperBorder(SpecialZone type, Vector3 position)
        {
            float ret = float.NaN;

            if (_zones.ContainsKey(type))
            {
                var zones = _zones[type];

                foreach (var zone in zones)
                {
                    if (ProjectionInZone(zone, position))
                    {
                        ret = zone.Center.y + zone.HalfSize.y;
                        break;
                    }
                }
            }

            return(ret);
        }
예제 #5
0
        public float DistanceOutsideUpperBorder(SpecialZone type, Vector3 position)
        {
            float ret = 0;

            if (_zones.ContainsKey(type))
            {
                var zones = _zones[type];

                foreach (var zone in zones)
                {
                    if (!InZone(zone, position) && ProjectionInZone(zone, position))
                    {
                        ret = position.y - zone.Center.y - zone.HalfSize.y;
                        break;
                    }
                }
            }

            return(ret);
        }
예제 #6
0
        public bool InZone(SpecialZone type, Vector3 position)
        {
            bool ret = false;

            if (_zones.ContainsKey(type))
            {
                var zones = _zones[type];

                foreach (var zone in zones)
                {
                    if (InZone(zone, position))
                    {
                        ret = true;
                        break;
                    }
                }
            }

            return(ret);
        }
예제 #7
0
        public void CreateZoneTriggers(SpecialZone type, int layer)
        {
            var baseName = String.Format("Zone_{0}_Trigger", type);

            if (_zones.ContainsKey(type))
            {
                var zones = _zones[type];

                int count = zones.Count;
                for (int i = 0; i < count; ++i)
                {
                    var name   = String.Format("{0}_{1}", baseName, i);
                    var zoneGo = DefaultGo.CreateGameObject(name);
                    zoneGo.layer = layer;
                    var box  = zoneGo.AddComponent <BoxCollider>();
                    var zone = zones[i];
                    box.center    = zone.Center;
                    box.size      = zone.HalfSize * 2;
                    box.isTrigger = true;
                }
            }
        }