GetPath() public method

Gets the head of the linked-list representing the shortest path from start to end in the map coordinate system.
public GetPath ( Vector2 start, Vector2 end ) : Node
start Vector2 The start tile coordinate.
end Vector2 The end tile coordinate.
return Node
Ejemplo n.º 1
0
 public void VolunteerCitizen(MSMap map)
 {
     MS3DTile bldg = map.GetRandomCitizenSource();
     MS3DTile center = map.GetNearestVolunteerCenter(bldg);
     Node path = map.GetPath(bldg.TileCoordinate, center.TileCoordinate);
     MSVolunteeringCitizen v = new MSVolunteeringCitizen(bldg.Position + MSUnit.UNITZ_POSITION, path, map, 0);
     units.Add(v);
 }
Ejemplo n.º 2
0
        public void SendWorkers(MSMap map, MSChangeableBuilding bldg, int qty)
        {
            MSVolunteerCenter center = map.GetNearestVolunteerCenter(bldg);
            Node path = map.GetPath(center.TileCoordinate, bldg.TileCoordinate);

            for (int i = 0; i < qty; i++)
            {
                MSWorker worker = new MSWorker(center.Position + MSUnit.UNITZ_POSITION, path, bldg, map, 0);
                units.Add(worker);
            }
        }
Ejemplo n.º 3
0
        public void TryForBaby(MSMap map)
        {
            List<MSUnit> mobbers = new List<MSUnit>();

            for (int i = 0; i < 9; i++)
            {
                MSMobParam mp = this.mobTypeParam[i];
                int rnd = MSRandom.Instance.GetUniformInt(100);
                if (rnd < mp.getProbability())
                {
                    System.Console.WriteLine("SUCCESS");
                    MSUnit person;

                    MSUnchangeableBuilding source = map.GetRandomCitizenSource();

                    MSUnchangeableBuilding sink;
                    do
                    {
                        sink = map.GetRandomCitizenSource();
                    } while (source == sink);

                    Vector2 start = new Vector2(source.Row, source.Column);
                    Vector2 end = new Vector2(sink.Row, sink.Column);

                    MSMilleniumDevelopmentGoal? mdg = this.getGoal(i);

                    if (mdg != null)
                    {
                        MSMilleniumDevelopmentGoal mobmdg = (MSMilleniumDevelopmentGoal)mdg;
                        person = new MSMobber(
                                map.MapArray[(int)start.X, (int)start.Y].Position + MSUnit.UNITZ_POSITION,
                                map.GetPath(start, MSDistrictHall.getInstance().TileCoordinate), map, mobmdg, 0);
                    }
                    else
                    {
                        Node path = map.GetPath(start, end);
                        person = new MSCitizen(
                            map.MapArray[(int)start.X, (int)start.Y].Position + MSUnit.UNITZ_POSITION,
                            path, map, true, 0);
                    }

                    if (person != null)
                    {
                        if (mdg != null) units.Add(person);
                        else mobbers.Add(person);
                    }
                }
            }

            if( mobbers.Count > 0 )
                units.Add(mobbers.ElementAt<MSUnit>(MSRandom.Instance.GetUniformInt(mobbers.Count)));
        }
Ejemplo n.º 4
0
        public void SendVolunteer(MSMap map, MSUnit unit, MSTower office)
        {
            Node path1 = map.GetPath(new Vector2(office.Row, office.Column), unit.TileCoordinate);

            Node pathEnd = path1;
            while (pathEnd.next != null)
            {
                pathEnd = pathEnd.next;
            }
            pathEnd.next = unit.Path;

            MSVolunteer volunteer = new MSVolunteer
            (
                office.Position + MSUnit.UNITZ_POSITION,
                path1,
                unit,
                office,
                map,
                0
            );

            MSUnitHandler.GetInstance().AddUnit(volunteer);
        }