Esempio n. 1
0
        public IEnumerable <IPromotion> GetGlobalPromotionsOfCiv(ICivilization civ)
        {
            if (civ == null)
            {
                throw new ArgumentNullException("civ");
            }

            var retval = new List <IPromotion>();

            foreach (var city in CityPossessionCanon.GetPossessionsOfOwner(civ))
            {
                foreach (var building in BuildingPossessionCanon.GetPossessionsOfOwner(city))
                {
                    retval.AddRange(building.Template.GlobalPromotions);
                }
            }

            foreach (var policy in SocialPolicyCanon.GetPoliciesUnlockedFor(civ))
            {
                retval.AddRange(policy.Bonuses.GlobalPromotions);
            }

            foreach (var policyTree in SocialPolicyCanon.GetTreesUnlockedFor(civ))
            {
                retval.AddRange(policyTree.UnlockingBonuses.GlobalPromotions);

                if (SocialPolicyCanon.IsTreeCompletedByCiv(policyTree, civ))
                {
                    retval.AddRange(policyTree.CompletionBonuses.GlobalPromotions);
                }
            }

            return(retval);
        }
        public void Refresh()
        {
            if (PolicyRecords == null)
            {
                SetUpPolicies();
            }

            if (TreeToRecord == null)
            {
                return;
            }

            NameField.text = TreeToRecord.name;

            var unlockedTrees  = PolicyCanon.GetTreesUnlockedFor(SelectedCiv);
            var availableTrees = PolicyCanon.GetTreesAvailableFor(SelectedCiv);

            if (PolicyCanon.IsTreeCompletedByCiv(TreeToRecord, SelectedCiv))
            {
                Background.color = CompletedColor;
                UnlockPolicyButton.gameObject.SetActive(false);
            }
            else if (unlockedTrees.Contains(TreeToRecord))
            {
                Background.color = UnlockedColor;
                UnlockPolicyButton.gameObject.SetActive(false);
            }
            else if (availableTrees.Contains(TreeToRecord))
            {
                Background.color = AvailableColor;
                UnlockPolicyButton.gameObject.SetActive(true);
            }
            else
            {
                Background.color = UnavailableColor;
                UnlockPolicyButton.gameObject.SetActive(false);
            }

            var unlockedPolicies  = PolicyCanon.GetPoliciesUnlockedFor(SelectedCiv);
            var availablePolicies = PolicyCanon.GetPoliciesAvailableFor(SelectedCiv);

            foreach (var policyRecord in PolicyRecords)
            {
                var policy = policyRecord.PolicyToRecord;

                if (unlockedPolicies.Contains(policy))
                {
                    policyRecord.Status = SocialPolicyRecord.StatusType.Unlocked;
                }
                else if (availablePolicies.Contains(policy))
                {
                    policyRecord.Status = SocialPolicyRecord.StatusType.Available;
                }
                else
                {
                    policyRecord.Status = SocialPolicyRecord.StatusType.Unavailable;
                }

                policyRecord.Refresh();
            }
        }