Beispiel #1
0
    public static List <Pos> GetPosInPathRange(Pos p, RadiusRange radiusRange)
    {
        BreadthFirstSearchRadius bfsr = new BreadthFirstSearchRadius(p, radiusRange);
        List <Pos> posInRadius        = bfsr.GetPosInRadius();

        return(posInRadius);
    }
    public BreadthFirstSearchRadius(Pos start, RadiusRange radius, int maxIter = 100000)
    {
        _start   = start;
        _range   = radius._range;
        _type    = radius._path;
        _maxIter = maxIter;

        _fastestPath       = new Dictionary <Pos, Pos>();
        _distanceFromStart = new Dictionary <Pos, float>();
        _searched          = new List <Pos>();
    }
Beispiel #3
0
 public static List <Pos> GetPosInRadius(List <Pos> allPos, Pos p, RadiusRange radius)
 {
     if (radius._path == ePath.Euclidian)
     {
         return(GetPosInEuclidianRadius(allPos, p, radius._range));
     }
     else if (radius._path == ePath.NodeEuclidian)
     {
         return(GetPosInPathRange(p, radius));
     }
     else
     {
         throw new System.NotImplementedException();
     }
 }
Beispiel #4
0
            public void CreateCloud()
            {
                float   cloudRadius = RadiusRange.Random();
                Vector3 pos         = UnityEngine.Random.insideUnitSphere * BoundsRadius;

                pos.y = Mathf.Abs(pos.y * 0.5f) + BoundsHeightRange.Random();
                //pos.y = BoundsHeightRange.Random();

                // for debugging with particle alpha blend shader
                //vertices[0] = pos - new Vector3(radius, 0.0f, radius);
                //vertices[1] = pos - new Vector3(-radius, 0.0f, radius);
                //vertices[2] = pos - new Vector3(radius, 0.0f, -radius);
                //vertices[3] = pos - new Vector3(-radius, 0.0f, -radius);

                vertices.Add(pos);
                vertices.Add(pos);
                vertices.Add(pos);
                vertices.Add(pos);

                UVEntry uv = uvEntries[UnityEngine.Random.Range(0, uvEntries.Length)];

                uvs.Add(new Vector4(uv.UV1.x, uv.UV1.y, quadUV1.x, quadUV1.y));
                uvs.Add(new Vector4(uv.UV2.x, uv.UV2.y, quadUV2.x, quadUV2.y));
                uvs.Add(new Vector4(uv.UV3.x, uv.UV3.y, quadUV3.x, quadUV3.y));
                uvs.Add(new Vector4(uv.UV4.x, uv.UV4.y, quadUV4.x, quadUV4.y));

                float   fadeTime      = FadeTimeRange.Random();
                float   totalLifeTime = LifeTimeRange.Random();
                Vector4 lifeTime      = new Vector4(Time.timeSinceLevelLoad + fadeTimeDelay, fadeTime, totalLifeTime); // creation time, fade in/out time in seconds, total life time in seconds

                fadeTimeDelay += FadeTimeDelayRange.Random();
                lifeTimes.Add(lifeTime);
                lifeTimes.Add(lifeTime);
                lifeTimes.Add(lifeTime);
                lifeTimes.Add(lifeTime);

                colors.Add(whiteColor);
                colors.Add(whiteColor);
                colors.Add(whiteColor);
                colors.Add(whiteColor);

                float   velocityX = VelocityRangeX.Random();
                float   velocityZ = VelocityRangeZ.Random();
                Vector3 velocity  = new Vector3(velocityX, 0.0f, velocityZ);

                velocities.Add(velocity);
                velocities.Add(velocity);
                velocities.Add(velocity);
                velocities.Add(velocity);

                float startAngle      = UnityEngine.Random.Range(-Mathf.PI, Mathf.PI);
                float angularVelocity = AngularVelocityRange.Random();

                others.Add(new Vector4(startAngle, angularVelocity, -cloudRadius, -cloudRadius));
                others.Add(new Vector4(startAngle, angularVelocity, cloudRadius, -cloudRadius));
                others.Add(new Vector4(startAngle, angularVelocity, -cloudRadius, cloudRadius));
                others.Add(new Vector4(startAngle, angularVelocity, cloudRadius, cloudRadius));

                indices.Add(++indice);
                indices.Add(++indice);
                indices.Add(++indice);
                indices.Add(indice--);
                indices.Add(indice--);
                indices.Add(indice += 3);
            }
    public static List <HomelandsLocation> GetLocationsInRadius(HomelandsLocation location, RadiusRange radiusRange)
    {
        List <Pos> posInRadius             = Pathfinder.GetPosInRadius(location._game._locations.Keys.ToList(), location._pos, radiusRange);
        List <HomelandsLocation> locations = new List <HomelandsLocation>();

        foreach (Pos p in posInRadius)
        {
            locations.Add(location._game._locations[p]);
        }
        return(locations);
    }