GetRandomCitizenSource() public method

public GetRandomCitizenSource ( ) : MSUnchangeableBuilding
return MSUnchangeableBuilding
コード例 #1
0
ファイル: MSUnitHandler.cs プロジェクト: verngutz/MoodSwing
 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);
 }
コード例 #2
0
ファイル: MSUnitHandler.cs プロジェクト: verngutz/MoodSwing
        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)));
        }