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
        //private void RandomizeCurPawn()
        //{
        //    if (!TutorSystem.AllowAction("RandomizePawn"))
        //    {
        //        return;
        //    }
        //    int num = 0;
        //    do
        //    {
        //        this.curPawn = StartingPawnUtility.RandomizeInPlace(this.curPawn);
        //        num++;
        //        if (num <= 15)
        //        {
        //            continue;
        //        }
        //        return;
        //    }
        //    while (!StartingPawnUtility.WorkTypeRequirementsSatisfied());
        //    TutorSystem.Notify_Event("RandomizePawn");
        //}

        private IEnumerator RandomizeAllPawns()
        {
            // Temp variable to store generated pawns
            Pawn[] aPawns = new Pawn[0];

            // Try 15 times to generate pawn with WorkTypeRequirementsSatisfied?
            int num = 0;

            do
            {
                // Loop through current pawns and generate random in place
                foreach (Pawn p in Find.GameInitData.startingPawns)
                {
                    Pawn curpawn = new Pawn();

                    curpawn = StartingPawnUtility.RandomizeInPlace(p);

                    aPawns = aPawns.Concat(new Pawn[] { curpawn }).ToArray();
                }

                NewGameRules.ClearCurPawns();

                Find.GameInitData.startingPawns = aPawns.ToList();
                aPawns = new Pawn[0];

                lstCardRects            = new List <Rect>();
                lstPNC_Cards            = new List <PNC_Card>();
                lstPNC_CardsInOrder     = new List <PNC_Card>();
                templstPNC_CardsInOrder = new List <PNC_Card>();
                intCardNum = 0;

                PopulateCards(false);

                if (num > 10 && StartingPawnUtility.WorkTypeRequirementsSatisfied())
                {
                    yield break;
                }

                num++;
                if (num <= 15)
                {
                    yield return(new WaitForSeconds(.05f));

                    //Log.Message(num.ToString());
                    continue;
                }
                yield break;
            }while (num < 3);
        }
Example #3
0
        public PNC_Card(Pawn _pawn = null, int _intNumCards = 0)
        {
            if (_pawn != null)
            {
                pawn      = _pawn;
                eCardType = ePNC_Card_Type.Pawn;
                PCS       = new PNC_Card_PawnCustomStats();
                NewGameRules.AddPawnToCurPoints(pawn);
            }
            else
            {
                eCardType = ePNC_Card_Type.Items;
                ES        = new ProEquipmentShop();
            }

            intNumCards = _intNumCards;
        }
Example #4
0
        private void DoTotalCostLabel()
        {
            if (eCardType == ePNC_Card_Type.Pawn)
            {
                // Calculate variables
                Text.Font = GameFont.Medium;
                float   floTotalPrice = PCS.GetTotalCost(pawn);
                string  strTotalPrice = String.Concat("Cost: ", String.Format("{0:0}", floTotalPrice));
                Vector2 vecSize       = Text.CalcSize(strTotalPrice);
                float   floPosX       = (rectCard.width - vecSize.x) - (rectCard.width * .05f);

                // Shape the label
                Rect rectTotalCostLabel = new Rect(floPosX, rectCard.height * 0f, vecSize.x, vecSize.y);

                // Draw the label
                Widgets.Label(KrozzyUtilities.RectAddition(rectTotalCostLabel, rectCard), strTotalPrice);

                Text.Font = GameFont.Small;

                NewGameRules.UpdateCurPawnPoints(pawn, floTotalPrice);
            }
            else if (eCardType == ePNC_Card_Type.Items)
            {
                // Calculate variables
                Text.Font = GameFont.Medium;
                string  strTotalPrice = String.Concat("Cost: ", String.Format("{0:0}", ES.floTotalItemsPrice));
                Vector2 vecSize       = Text.CalcSize(strTotalPrice);
                float   floPosX       = (rectCard.width - vecSize.x) - (rectCard.width * .05f);

                // Shape the label
                Rect rectTotalCostLabel = new Rect(floPosX, rectCard.height * 0f, vecSize.x, vecSize.y);

                // Draw the label
                Widgets.Label(KrozzyUtilities.RectAddition(rectTotalCostLabel, rectCard), strTotalPrice);

                Text.Font = GameFont.Small;

                NewGameRules.floCurItemPoints = NewGameRules.floStartingItemPoints - ES.floTotalItemsPrice;
            }
        }
        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;

            string  strPassionMinor = string.Concat(" = ", NewGameRules.GetPassionCost(pawn, Passion.Minor).ToString(), " Points");
            string  strPassionMajor = string.Concat(" = ", NewGameRules.GetPassionCost(pawn, Passion.Major).ToString(), " Points");
            Vector2 vecPassionMinor = Text.CalcSize(strPassionMinor);
            Vector2 vecPassionMajor = Text.CalcSize(strPassionMajor);

            GUI.DrawTexture(new Rect(x, y, vecPassionMinor.y, vecPassionMinor.y), ProTBin.texPassionMinorIcon);
            Widgets.Label(new Rect(vecPassionMinor.y, y, vecPassionMinor.x, vecPassionMinor.y), strPassionMinor);

            y += vecPassionMinor.y;

            GUI.DrawTexture(new Rect(x, y, vecPassionMajor.y, vecPassionMajor.y), ProTBin.texPassionMajorIcon);
            Widgets.Label(new Rect(vecPassionMajor.y, y, vecPassionMajor.x, vecPassionMajor.y), strPassionMajor);

            y += vecPassionMajor.y;

            foreach (SkillRecord sk in aSKs)
            {
                w = Text.CalcSize(sk.def.skillLabel).x;
                h = Text.CalcSize(sk.def.skillLabel).y;
                //string strPointsLabel = "Points: ";
                //string strPoints = String.Format("{0:0}", NewGameRules.GetPassionCost(pawn, sk.passion));

                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.passion > Passion.None && sk.TotallyDisabled != true)
                        {
                            sk.passion--;
                        }
                    }

                    if (sk.passion == Passion.Minor)
                    {
                        GUI.DrawTexture(rectSkillLevel, ProTBin.texPassionMinorIcon);
                    }
                    else if (sk.passion == Passion.Major)
                    {
                        GUI.DrawTexture(rectSkillLevel, ProTBin.texPassionMajorIcon);
                    }

                    if (GUI.Button(rectUpButton, "+", "button"))
                    {
                        if (sk.passion < Passion.Major && sk.TotallyDisabled != true)
                        {
                            sk.passion++;
                        }
                    }

                    //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;
            }
        }
Example #6
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;
            }
        }