コード例 #1
0
        private void UpdateUI()
        {
            int p = _human.wishManager.lifetimeSatisfactionPoints;

            this.Text.text = p.ToString();
            bool enoughForMajor = false;
            bool enoughForMinor = false;

            if (p != 0)
            {
                //If we already have it but it's a "negative" trait and we have enough points to remove it or
                //   we don't have it and it's a positive trait with a value higher than 1
                enoughForMajor = _human.traitSet.traits.Any(x => p >= TraitSet.GetTraitCost(x) && TraitSet.GetTraitPoints(x) > 0) ||
                                 TraitSet.changableTraits.Any(x => !_human.traitSet.HasTrait(x) && TraitSet.TraitAllowed(x, _human.traitSet.traits) && p >= TraitSet.GetTraitCost(x) && TraitSet.GetTraitPoints(x) < -1);

                //If we don't already have it and it's a positive trait
                if (!enoughForMajor)
                {
                    enoughForMinor = TraitSet.changableTraits.Any(x => !_human.traitSet.HasTrait(x) && TraitSet.TraitAllowed(x, _human.traitSet.traits) && p >= TraitSet.GetTraitCost(x) && TraitSet.GetTraitPoints(x) < 0);
                }
            }

            if (enoughForMajor)
            {
                this.Image.color = new Color(0.302f, 0.784f, 0.392f); //green
            }
            else if (enoughForMinor)
            {
                this.Image.color = new Color(0.800f, 0.800f, 0f); //yellow
            }
            else
            {
                this.Image.color = new Color(0.783f, 0.303f, 0.303f); //red
            }
            this.Tooltip.Init(Localization.GetText("witchy_UIImprovements_satisfactionTooltip_Title"),
                              String.Format(Localization.GetText("witchy_UIImprovements_satisfactionTooltip_Desc"), _human.firstName, p));
        }