Пример #1
0
    public static Dictionary <string, List <PointOfInterestTemplate> > ComputeLuxuryAbundance(Game game)
    {
        GridMap <PointOfInterest>      gridMap = game.World.Atlas.GetMap(WorldAtlas.Maps.PointOfInterest) as GridMap <PointOfInterest>;
        List <PointOfInterestTemplate> source  = (from POI in gridMap.Data
                                                  where POI != null && POI.IsLuxuryDeposit()
                                                  select POI.PointOfInterestDefinition.PointOfInterestTemplate).ToList <PointOfInterestTemplate>();
        Dictionary <string, List <PointOfInterestTemplate> > dictionary = new Dictionary <string, List <PointOfInterestTemplate> >();

        dictionary.Add("Tier1", new List <PointOfInterestTemplate>());
        dictionary.Add("Tier2", new List <PointOfInterestTemplate>());
        dictionary.Add("Tier3", new List <PointOfInterestTemplate>());
        foreach (PointOfInterestTemplate pointOfInterestTemplate in source.Distinct <PointOfInterestTemplate>())
        {
            string empty = string.Empty;
            pointOfInterestTemplate.Properties.TryGetValue("LuxuryTier", out empty);
            if (dictionary.ContainsKey(empty))
            {
                dictionary[empty].Add(pointOfInterestTemplate);
            }
            else
            {
                Diagnostics.LogError("Luxury resource " + pointOfInterestTemplate.Name + " doesn't have tier data!");
            }
        }
        return(dictionary);
    }