Пример #1
0
        public Vector3[] GenerateWaypoints(ITerrain terrain, Vector3 centrePos, float radius, int count)
        {
            Vector3[] vector3Array = new Vector3[count];
            for (int index = 0; index < count; ++index)
            {
                float   num1     = Utility.RandomFloat() * 6.283185f;
                float   num2     = (float)Math.Sqrt(Utility.Random(0.0f, radius));
                Vector3 worldPos = new Vector3();
                worldPos.X          = centrePos.X + radius * num2 * (float)Math.Cos(num1);
                worldPos.Y          = centrePos.Y + radius * num2 * (float)Math.Sin(num1);
                worldPos.Z          = centrePos.Z;
                worldPos.Z          = terrain.GetGroundHeightUnderneath(worldPos);
                vector3Array[index] = worldPos;
            }

            return(vector3Array);
        }
Пример #2
0
 public Vector3[] GenerateWaypoints(ITerrain terrain, Vector3 centrePos, float radius, int count)
 {
     var wps = new Vector3[count];
     for (var i = 0; i < count; i++)
     {
         var angle = Utility.RandomFloat() * MathUtil.TwoPI;
         var dist = (float)Math.Sqrt(Utility.Random(0, radius));
         var newPos = new Vector3();
         newPos.X = centrePos.X + ((radius * dist) * (float)Math.Cos(angle));
         newPos.Y = centrePos.Y + ((radius * dist) * (float)Math.Sin(angle));
         newPos.Z = centrePos.Z;
         //consider flying units
         newPos.Z = terrain.GetGroundHeightUnderneath(newPos);
         wps[i] = newPos;
     }
     return wps;
 }
Пример #3
0
        public Vector3[] GenerateWaypoints(ITerrain terrain, Vector3 centrePos, float radius, int count)
        {
            var wps = new Vector3[count];

            for (var i = 0; i < count; i++)
            {
                var angle  = Utility.RandomFloat() * MathUtil.TwoPI;
                var dist   = (float)Math.Sqrt(Utility.Random(0, radius));
                var newPos = new Vector3();
                newPos.X = centrePos.X + ((radius * dist) * (float)Math.Cos(angle));
                newPos.Y = centrePos.Y + ((radius * dist) * (float)Math.Sin(angle));
                newPos.Z = centrePos.Z;
                //consider flying units
                newPos.Z = terrain.GetGroundHeightUnderneath(newPos);
                wps[i]   = newPos;
            }
            return(wps);
        }
Пример #4
0
		public Vector3[] GenerateWaypoints(ITerrain terrain, Vector3 lastPos, int min, int max, float minDist, float maxDist)
		{
			if (min < 1 || max < min || maxDist < minDist)
			{
				throw new ArgumentException("Invalid arguments");
			}

			var count = Utility.Random(min, max);
			var wps = new Vector3[count];
			for (var i = 0; i < count; i++)
			{
				var direction = Utility.Random(0, MathUtil.TwoPI);
				var dist = Utility.Random(minDist, maxDist);
				lastPos.GetPointYX(direction, dist, out lastPos);
				lastPos.Z = terrain.GetGroundHeightUnderneath(lastPos);
				wps[i] = lastPos;
			}
			return wps;
		}
Пример #5
0
        public static Vector3[] GenerateWaypoints(ITerrain terrain, Vector3 lastPos, float minDist, float maxDist, int count)
        {
            if (maxDist < minDist)
            {
                throw new ArgumentException(@"The maximum waypoint distance must be greater than the minimum", "maxDist");
            }

            var wps = new Vector3[count];
            for (var i = 0; i < count; i++)
            {
                var direction = Utility.Random(0, MathUtil.TwoPI);
                var dist = Utility.Random(minDist, maxDist);
                var z = lastPos.Z;
                lastPos.GetPointYX(direction, dist, out lastPos);
                lastPos.Z = z;
                //consider flying units
                lastPos.Z = terrain.GetGroundHeightUnderneath(lastPos);
                wps[i] = lastPos;
            }
            return wps;
        }
Пример #6
0
        public static Vector3[] GenerateWaypoints(ITerrain terrain, Vector3 lastPos, float minDist, float maxDist,
                                                  int count)
        {
            if (maxDist < (double)minDist)
            {
                throw new ArgumentException("The maximum waypoint distance must be greater than the minimum",
                                            nameof(maxDist));
            }
            Vector3[] vector3Array = new Vector3[count];
            for (int index = 0; index < count; ++index)
            {
                float angle = Utility.Random(0.0f, 6.283185f);
                float dist  = Utility.Random(minDist, maxDist);
                float z     = lastPos.Z;
                lastPos.GetPointYX(angle, dist, out lastPos);
                lastPos.Z           = z;
                lastPos.Z           = terrain.GetGroundHeightUnderneath(lastPos);
                vector3Array[index] = lastPos;
            }

            return(vector3Array);
        }
Пример #7
0
        public static Vector3[] GenerateWaypoints(ITerrain terrain, Vector3 lastPos, float minDist, float maxDist, int count)
        {
            if (maxDist < minDist)
            {
                throw new ArgumentException(@"The maximum waypoint distance must be greater than the minimum", "maxDist");
            }

            var wps = new Vector3[count];

            for (var i = 0; i < count; i++)
            {
                var direction = Utility.Random(0, MathUtil.TwoPI);
                var dist      = Utility.Random(minDist, maxDist);
                var z         = lastPos.Z;
                lastPos.GetPointYX(direction, dist, out lastPos);
                lastPos.Z = z;
                //consider flying units
                lastPos.Z = terrain.GetGroundHeightUnderneath(lastPos);
                wps[i]    = lastPos;
            }
            return(wps);
        }