public float GetTotalCost(Pawn _pawn)
        {
            float floSkillsCost = 0f;

            foreach (SkillRecord sr in _pawn.skills.skills)
            {
                if (sr.TotallyDisabled != true)
                {
                    int intSkillLevelOffset = 0;

                    foreach (Backstory bs in _pawn.story.AllBackstories)
                    {
                        foreach (KeyValuePair <SkillDef, int> kvp in bs.skillGainsResolved)
                        {
                            if (sr.def == kvp.Key && kvp.Value != 0)
                            {
                                intSkillLevelOffset += kvp.Value;
                            }
                        }
                    }

                    floSkillsCost += NewGameRules.GetSkillCost(_pawn.ageTracker.AgeBiologicalYears, sr.levelInt - intSkillLevelOffset);
                }
            }

            floSkillsCost += NewGameRules.GetPassionTotalCost(_pawn);

            return(floSkillsCost);
        }
Example #2
0
        public override void DoWindowContents(Rect inRect)
        {
            float x = 0f;
            float y = 0f;
            float w = 0f;
            float h = 0f;

            Text.Font = GameFont.Medium;
            w         = Text.CalcSize(strName).x;
            h         = Text.CalcSize(strName).y;
            Widgets.Label(new Rect(x, y, w, h), strName);
            y        += h;
            Text.Font = GameFont.Small;

            foreach (SkillRecord sk in aSKs)
            {
                int intSkillLevelOffset = 0;

                foreach (Backstory bs in pawn.story.AllBackstories)
                {
                    foreach (KeyValuePair <SkillDef, int> kvp in bs.skillGainsResolved)
                    {
                        if (sk.def == kvp.Key && kvp.Value != 0)
                        {
                            intSkillLevelOffset += kvp.Value;
                        }
                    }
                }

                w = Text.CalcSize(sk.def.skillLabel).x;
                h = Text.CalcSize(sk.def.skillLabel).y;
                string strPointsLabel = "Points: ";
                string strPoints      = String.Format("{0:0}", NewGameRules.GetSkillCost(pawn.ageTracker.AgeBiologicalYears, sk.Level - intSkillLevelOffset));

                Rect rectSkillLabel  = new Rect(x, y, w, h);
                Rect rectDownButton  = new Rect(floSkillsColumnRight, y, floAdjustButtonSize, floAdjustButtonSize);
                Rect rectSkillLevel  = new Rect(rectDownButton.x + rectDownButton.width + floAdjustButtonSize, y, floAdjustButtonSize, floAdjustButtonSize);
                Rect rectUpButton    = new Rect(rectSkillLevel.x + rectSkillLevel.width + floAdjustButtonSize, y, floAdjustButtonSize, floAdjustButtonSize);
                Rect rectPointsLabel = new Rect(rectUpButton.x + rectUpButton.width + floAdjustButtonSize, y, Text.CalcSize(strPointsLabel).x, floAdjustButtonSize);
                Rect rectPoints      = new Rect(rectPointsLabel.x + rectPointsLabel.width, y, Text.CalcSize("0000").x, floAdjustButtonSize);

                GUI.Label(rectSkillLabel, sk.def.skillLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Normal, TextAnchor.MiddleLeft));

                if (sk.TotallyDisabled != true)
                {
                    if (GUI.Button(rectDownButton, "-", "button"))
                    {
                        if (sk.Level - intSkillLevelOffset > 0 && sk.TotallyDisabled != true)
                        {
                            sk.Level--;
                            sk.xpSinceLastLevel = 0f;
                        }
                    }

                    GUI.Label(rectSkillLevel, (sk.Level - intSkillLevelOffset).ToString(), KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Normal, TextAnchor.MiddleCenter));


                    if (GUI.Button(rectUpButton, "+", "button"))
                    {
                        if (sk.Level - intSkillLevelOffset < 20 && sk.TotallyDisabled != true)
                        {
                            sk.Level++;
                            sk.xpSinceLastLevel = 0f;
                        }
                    }

                    GUI.Label(rectPointsLabel, strPointsLabel, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Normal, TextAnchor.MiddleLeft));
                    GUI.Label(rectPoints, strPoints, KrozzyUtilities.BuildStyle(Fonts.Arial_small, Colors.White, FontStyle.Normal, TextAnchor.MiddleRight));
                }

                y += h;
            }
        }