Beispiel #1
0
        public int GetExtractedCopiesOfResourceForCiv(IResourceDefinition resource, ICivilization civ)
        {
            int retval = 0;

            if (!TechCanon.IsResourceDiscoveredByCiv(resource, civ))
            {
                return(0);
            }

            foreach (var city in CityPossessionCanon.GetPossessionsOfOwner(civ))
            {
                foreach (var cell in CellPossessionCanon.GetPossessionsOfOwner(city))
                {
                    var nodeOnCell = NodePositionCanon.GetPossessionsOfOwner(cell).FirstOrDefault();

                    if (nodeOnCell != null && nodeOnCell.Resource == resource)
                    {
                        var improvementAtLocation = ImprovementLocationCanon.GetPossessionsOfOwner(cell).FirstOrDefault();

                        if (resource.Extractor == null || (
                                improvementAtLocation != null && improvementAtLocation.Template == resource.Extractor &&
                                improvementAtLocation.IsConstructed && !improvementAtLocation.IsPillaged
                                ))
                        {
                            if (resource.Type == MapResources.ResourceType.Strategic)
                            {
                                retval += nodeOnCell.Copies;
                            }
                            else if (resource.Type == MapResources.ResourceType.Luxury)
                            {
                                retval++;
                            }
                        }
                    }
                }
            }

            return(retval);
        }
        public bool IsResourceVisible(IResourceDefinition resource)
        {
            switch (ResourceVisibilityMode)
            {
            case ResourceVisibilityMode.ActiveCiv: return(GameCore.ActiveCiv != null && TechCanon.IsResourceDiscoveredByCiv(resource, GameCore.ActiveCiv));

            case ResourceVisibilityMode.RevealAll: return(true);

            case ResourceVisibilityMode.HideAll:   return(false);

            default: throw new NotImplementedException("No behavior defined for ResourceVisibilityMode " + ResourceVisibilityMode);
            }
        }