Example #1
0
 public static void GetAreaRangeWithinViewDistance(Vector3i location, Vector3i viewDistance, ref AreaRange range)
 {
     range.Min.X = location.X - viewDistance.X;
     range.Max.X = location.X + viewDistance.X;
     range.Min.Y = location.Y - viewDistance.Y;
     range.Max.Y = location.Y + viewDistance.Y;
     range.Min.Z = location.Z - viewDistance.Z;
     range.Max.Z = location.Z + viewDistance.Z;
 }
Example #2
0
        public static void GetAreaRangeBoundaries(ref AreaRange result, IEnumerable<Area> areasToIterate)
        {
            // No areas to process
            if (areasToIterate == null)
            {
                result = null;
                return;
            }

            var iterator = areasToIterate.GetEnumerator();

            // No areas to process
            if (!iterator.MoveNext())
            {
                result = null;
                return;
            }

            // Get the first area that we know exists in areasToIterate by now
            var first = iterator.Current;

            // Make sure that the result range is initialized before proceeding
            if (result == null)
            {
                result = new AreaRange();
            }

            // Reset the outer bounds
            result.Min.X = first.Info.Location.X;
            result.Min.Y = first.Info.Location.Y;
            result.Min.Z = first.Info.Location.Z;
            result.Max.X = first.Info.Location.X;
            result.Max.Y = first.Info.Location.Y;
            result.Max.Z = first.Info.Location.Z;

            // Loop through all areas and find the outer bounds
            foreach (var area in areasToIterate)
            {
                if (area.Info.Location.X < result.Min.X) result.Min.X = area.Info.Location.X;
                if (area.Info.Location.Y < result.Min.Y) result.Min.Y = area.Info.Location.Y;
                if (area.Info.Location.Z < result.Min.Z) result.Min.Z = area.Info.Location.Z;
                if (area.Info.Location.X > result.Max.X) result.Max.X = area.Info.Location.X;
                if (area.Info.Location.Y > result.Max.Y) result.Max.Y = area.Info.Location.Y;
                if (area.Info.Location.Z > result.Max.Z) result.Max.Z = area.Info.Location.Z;
            }
        }
Example #3
0
        public static void GetAreasInRange(ref List<Area> result, IEnumerable<Area> areasToIterate, AreaRange range)
        {
            var iterator = areasToIterate.GetEnumerator();

            while (iterator.MoveNext())
            {
                // Within the bounds of the range?
                if (iterator.Current.Info.Location.X >= range.Min.X &&
                    iterator.Current.Info.Location.X <= range.Max.X &&
                    iterator.Current.Info.Location.Y >= range.Min.Y &&
                    iterator.Current.Info.Location.Y <= range.Max.Y &&
                    iterator.Current.Info.Location.Z >= range.Min.Z &&
                    iterator.Current.Info.Location.Z <= range.Max.Z)
                {
                    // Add it to our list and proceed with the next area
                    result.Add(iterator.Current);
                }
            }
        }
Example #4
0
        internal static double[] AreaSpan(List <Triangle> triangulation,
                                          uint MaxLength,
                                          double MinAngle,
                                          AreaRange RelativeArea)
        {
            double[] check_range;

            List <double> areas = new List <double>();


            /* Here we get the areas for the triangles that PASS the angle and
             * length filter. That way, the min area will be a valid triangle.
             * We check those areas against the range later. */
            foreach (Triangle tri in triangulation)
            {
                List <double> TriAngles = MathFilter.AngleDegrees(tri);

                if (LengthFilter(tri, MaxLength) &&
                    TriAngles.TrueForAll(angle => angle >= MinAngle))
                {
                    areas.Add(MathFilter.TriangleArea(tri));
                }
            }

            double area_range = areas.Max() - areas.Min();

            double min_area = areas.Min();
            double max_area = areas.Max();
            double low_mid  = min_area + (area_range / 5);
            double high_mid = min_area + ((area_range / 5) * 3);

            double[] no_range = new double[] { min_area, max_area };

            double[] low_range  = new double[] { min_area, low_mid };
            double[] mid_range  = new double[] { low_mid, high_mid };
            double[] high_range = new double[] { high_mid, max_area };

            switch (RelativeArea)
            {
            case AreaRange.Low:
                check_range = low_range;
                break;

            case AreaRange.Mid:
                check_range = mid_range;
                break;

            case AreaRange.High:
                check_range = high_range;
                break;

            case AreaRange.Surprise:
                check_range = no_range;     // Not implemented yet
                break;

            case AreaRange.None:
            default:
                check_range = no_range;
                break;
            }

            return(check_range);
        }
Example #5
0
 // Use this for initialization
 void Start()
 {
     school       = GetComponentInParent <Turret>().GetComponentInParent <AreaRange>();
     playerNumber = GetComponentInParent <JPNetworkShip>().playerNumber;
 }