Example #1
0
        void UpdatePlayerValues()
        {
            // Handle leveling up
            if (PlayerEntity.ReadyToLevelUp)
            {
                leveling = true;
                PlayerEntity.Level++;
                PlayerEntity.MaxHealth += FormulaHelper.CalculateHitPointsPerLevelUp(PlayerEntity);
                DaggerfallUI.Instance.PlayOneShot(levelUpSound);

                // Roll bonus pool for player to distribute
                // Using maxBonusPool + 1 for inclusive range
                int bonusPool = UnityEngine.Random.Range(minBonusPool, maxBonusPool + 1);

                // Add stats rollout for leveling up
                NativePanel.Components.Add(statsRollout);

                this.statsRollout.StartingStats = PlayerEntity.Stats.Clone();
                this.statsRollout.WorkingStats  = PlayerEntity.Stats.Clone();
                this.statsRollout.BonusPool     = bonusPool;

                PlayerEntity.ReadyToLevelUp = false;
            }

            // Update main labels
            nameLabel.Text        = PlayerEntity.Name;
            raceLabel.Text        = PlayerEntity.RaceTemplate.Name;
            classLabel.Text       = PlayerEntity.Career.Name;
            levelLabel.Text       = PlayerEntity.Level.ToString();
            goldLabel.Text        = PlayerEntity.GetGoldAmount().ToString();
            fatigueLabel.Text     = string.Format("{0}/{1}", PlayerEntity.CurrentFatigue / DaggerfallEntity.FatigueMultiplier, PlayerEntity.MaxFatigue / DaggerfallEntity.FatigueMultiplier);
            healthLabel.Text      = string.Format("{0}/{1}", PlayerEntity.CurrentHealth, PlayerEntity.MaxHealth);
            encumbranceLabel.Text = string.Format("{0}/{1}", (int)PlayerEntity.CarriedWeight, PlayerEntity.MaxEncumbrance);

            // Update stat labels
            for (int i = 0; i < DaggerfallStats.Count; i++)
            {
                if (!leveling)
                {
                    statLabels[i].Text = PlayerEntity.Stats.GetLiveStatValue(i).ToString();
                }
                else
                {
                    statLabels[i].Text = ""; // If leveling, statsRollout will fill in the stat labels.
                }
                // Handle stat colour changes
                if (PlayerEntity.Stats.GetLiveStatValue(i) < PlayerEntity.Stats.GetPermanentStatValue(i))
                {
                    statLabels[i].TextColor = DaggerfallUI.DaggerfallUnityStatDrainedTextColor;
                }
                else if (PlayerEntity.Stats.GetLiveStatValue(i) > PlayerEntity.Stats.GetPermanentStatValue(i))
                {
                    statLabels[i].TextColor = DaggerfallUI.DaggerfallUnityStatIncreasedTextColor;
                }
                else
                {
                    statLabels[i].TextColor = DaggerfallUI.DaggerfallDefaultTextColor;
                }
            }
        }
        void UpdatePlayerValues()
        {
            // Handle leveling up
            if (PlayerEntity.ReadyToLevelUp)
            {
                leveling = true;
                PlayerEntity.Level++;
                PlayerEntity.MaxHealth += FormulaHelper.CalculateHitPointsPerLevelUp(PlayerEntity);
                DaggerfallUI.Instance.PlayOneShot(levelUpSound);

                // Roll bonus pool for player to distribute
                // Using maxBonusPool + 1 for inclusive range
                int bonusPool = UnityEngine.Random.Range(minBonusPool, maxBonusPool + 1);

                // Add stats rollout for leveling up
                NativePanel.Components.Add(statsRollout);

                this.statsRollout.StartingStats = PlayerEntity.Stats;
                this.statsRollout.WorkingStats  = PlayerEntity.Stats;
                this.statsRollout.BonusPool     = bonusPool;

                PlayerEntity.ReadyToLevelUp = false;
            }

            // Update main labels
            nameLabel.Text    = PlayerEntity.Name;
            raceLabel.Text    = PlayerEntity.RaceTemplate.Name;
            classLabel.Text   = PlayerEntity.Career.Name;
            levelLabel.Text   = PlayerEntity.Level.ToString();
            goldLabel.Text    = PlayerEntity.GoldPieces.ToString();
            fatigueLabel.Text = string.Format("{0}/{1}", PlayerEntity.CurrentFatigue / 64, PlayerEntity.MaxFatigue / 64);
            healthLabel.Text  = string.Format("{0}/{1}", PlayerEntity.CurrentHealth, PlayerEntity.MaxHealth);

            // Update stat labels
            for (int i = 0; i < DaggerfallStats.Count; i++)
            {
                if (!leveling)
                {
                    statLabels[i].Text = PlayerEntity.Stats.GetStatValue(i).ToString();
                }
                else
                {
                    statLabels[i].Text = ""; // If leveling, statsRollout will fill in the stat labels.
                }
            }
        }