Example #1
0
        public void addSourcePoint(SourcePoint spoint)
        {
            sourcePointsTyped[spoint.sourceType].Add(spoint.id);
            sourcePoints.Add(spoint.id, spoint);
            if (sourcePoints.Count == 1)
            {
                leftB = rightB = spoint.location.x;
                topB  = bottomB = spoint.location.y;
                return;
            }

            if (spoint.location.x < leftB)
            {
                leftB = spoint.location.x;
            }
            if (spoint.location.x > rightB)
            {
                rightB = spoint.location.x;
            }
            if (spoint.location.y < topB)
            {
                topB = spoint.location.y;
            }
            if (spoint.location.y > bottomB)
            {
                bottomB = spoint.location.y;
            }
        }
Example #2
0
 public void addSourcePoint(SourcePoint sourcePoint)
 {
     sourcePoint.id = counter;
     counter++;
     surface.addSourcePoint(sourcePoint);
     pointsManager.addStaticPoint(sourcePoint.location, sourcePoint.id, SourcePointType);
 }
Example #3
0
        public Pnt getRandomPointFromLast(Random rnd, int maxDistance)
        {
            if (sourcePoints.Count == 0)
            {
                return(new Pnt(0, 0));
            }

            SourcePoint last = sourcePoints.Values.Last();
            int         x    = rnd.Next((int)last.location.x - maxDistance, (int)last.location.x + maxDistance);
            int         y    = rnd.Next((int)last.location.y - maxDistance, (int)last.location.y + maxDistance);

            return(new Pnt(x, y));
        }
Example #4
0
        public double getEffectAtPoint(Pnt point, SourceType stype)
        {
            double effect = 0;

            foreach (long id in sourcePointsTyped[stype])
            {
                SourcePoint sp   = sourcePoints[id];
                double      dist = Vector.GetLength(point, sp.location);
                if (dist == 0)
                {
                    continue;
                }
                double coeff = 1 / dist;
                effect += coeff * sp.strength;
            }
            return(effect);
        }
Example #5
0
        public void addSource(SourceType stype, double dist)
        {
            SourcePoint spoint = new SourcePoint(world.surface.getRandomPointFromLast(rnd, (int)dist), stype, rnd);

            world.addSourcePoint(spoint);
        }