Пример #1
0
        public ResourceBalanceStrategy(
            IYieldEstimator yieldEstimator, IResourceNodeFactory resourceNodeFactory,
            IResourceRestrictionLogic resourceRestrictionCanon, ICellScorer cellScorer, ITechCanon techCanon,
            IStrategicCopiesLogic strategicCopiesLogic, IWeightedRandomSampler <IHexCell> cellRandomSampler,
            [Inject(Id = "Available Resources")] IEnumerable <IResourceDefinition> availableResources,
            IWeightedRandomSampler <IResourceDefinition> resourceRandomSampler
            )
        {
            YieldEstimator           = yieldEstimator;
            ResourceNodeFactory      = resourceNodeFactory;
            ResourceRestrictionCanon = resourceRestrictionCanon;
            CellScorer            = cellScorer;
            TechCanon             = techCanon;
            StrategicCopiesLogic  = strategicCopiesLogic;
            CellRandomSampler     = cellRandomSampler;
            ResourceRandomSampler = resourceRandomSampler;

            foreach (var yieldType in EnumUtil.GetValues <YieldType>())
            {
                BonusResourcesWithYield[yieldType] = availableResources.Where(
                    resource => resource.Type == ResourceType.Bonus &&
                    YieldEstimator.GetYieldEstimateForResource(resource)[yieldType] > 0f
                    ).ToArray();
            }

            ScoreIncreasingCandidates = availableResources.Where(resource => resource.Type != ResourceType.Luxury).ToList();
        }
Пример #2
0
 public LuxuryDistributor(
     IResourceRestrictionLogic resourceRestrictionCanon, IMapGenerationConfig config,
     IResourceNodeFactory nodeFactory, IWeightedRandomSampler <IHexCell> cellRandomSampler,
     IWeightedRandomSampler <IResourceDefinition> resourceRandomSampler
     )
 {
     ResourceRestrictionCanon = resourceRestrictionCanon;
     Config                = config;
     NodeFactory           = nodeFactory;
     CellRandomSampler     = cellRandomSampler;
     ResourceRandomSampler = resourceRandomSampler;
 }
        public ResourceNodeFactory(
            DiContainer container, IPossessionRelationship <IHexCell, IResourceNode> resourceNodeLocationCanon,
            IResourceRestrictionLogic restrictionCanon, ResourceSignals signals,
            [InjectOptional(Id = "Resource Node Container")] Transform nodeContainer
            )
        {
            Container = container;
            ResourceNodeLocationCanon = resourceNodeLocationCanon;
            RestrictionCanon          = restrictionCanon;
            NodeContainer             = nodeContainer;

            signals.NodeBeingDestroyed.Subscribe(OnNodeBeingDestroyed);
        }
Пример #4
0
        public StrategicDistributor(
            IResourceNodeFactory nodeFactory, IResourceRestrictionLogic resourceRestrictionCanon,
            IStrategicCopiesLogic strategicCopiesLogic, IWeightedRandomSampler <IHexCell> cellRandomSampler,
            [Inject(Id = "Available Resources")] IEnumerable <IResourceDefinition> availableResources,
            IWeightedRandomSampler <IResourceDefinition> resourceRandomSampler
            )
        {
            NodeFactory = nodeFactory;
            ResourceRestrictionCanon = resourceRestrictionCanon;
            StrategicCopiesLogic     = strategicCopiesLogic;
            CellRandomSampler        = cellRandomSampler;
            ResourceRandomSampler    = resourceRandomSampler;

            StrategicResources = availableResources.Where(resource => resource.Type == ResourceType.Strategic);
        }