コード例 #1
0
        void Spinner_OnUpButtonClicked()
        {
            const int maxFreeEditValue = 75;

            // Get working stat value
            int workingValue = workingStats.GetPermanentStatValue(selectedStat);

            // Get max working value
            int maxWorkingValue = FormulaHelper.MaxStatValue();

            // Working value cannot rise above maxWorkingValue and bonus cannot fall below zero, unless freeEdit active
            if ((freeEdit && workingValue == maxFreeEditValue) ||
                !freeEdit && (workingValue == maxWorkingValue || bonusPool == 0))
            {
                return;
            }

            // Remove a point from pool stat and assign to working stat
            bonusPool -= 1;
            workingStats.SetPermanentStatValue(selectedStat, workingValue + 1);
            spinner.Value = bonusPool;
            UpdateStatLabels();
            RaiseOnStatChanged();
            if (freeEdit)
            {
                DaggerfallUI.Instance.PlayOneShot(SoundClips.ButtonClick);
            }
        }
コード例 #2
0
        void Spinner_OnUpButtonClicked()
        {
            // Get working stat value
            int workingValue = workingStats.GetPermanentStatValue(selectedStat);

            // Working value cannot rise above maxWorkingValue and bonus cannot fall below zero
            if (workingValue == maxWorkingValue || bonusPool == 0)
            {
                return;
            }

            // Remove a point from pool stat and assign to working stat
            bonusPool -= 1;
            workingStats.SetPermanentStatValue(selectedStat, workingValue + 1);
            spinner.Value = bonusPool;
            UpdateStatLabels();
            RaiseOnStatChanged();
        }
コード例 #3
0
        DaggerfallStats ReadStats(BinaryReader reader)
        {
            DaggerfallStats result = new DaggerfallStats();
            for (int i = 0; i < 8; i++)
            {
                result.SetPermanentStatValue(i, reader.ReadInt16());
            }

            return result;
        }
コード例 #4
0
        public static DaggerfallStats GetClassBaseStats(DFCareer dfClass)
        {
            DaggerfallStats stats = new DaggerfallStats();

            stats.SetPermanentStatValue(DFCareer.Stats.Strength, dfClass.Strength);
            stats.SetPermanentStatValue(DFCareer.Stats.Intelligence, dfClass.Intelligence);
            stats.SetPermanentStatValue(DFCareer.Stats.Willpower, dfClass.Willpower);
            stats.SetPermanentStatValue(DFCareer.Stats.Agility, dfClass.Agility);
            stats.SetPermanentStatValue(DFCareer.Stats.Endurance, dfClass.Endurance);
            stats.SetPermanentStatValue(DFCareer.Stats.Personality, dfClass.Personality);
            stats.SetPermanentStatValue(DFCareer.Stats.Speed, dfClass.Speed);
            stats.SetPermanentStatValue(DFCareer.Stats.Luck, dfClass.Luck);

            return(stats);
        }
コード例 #5
0
        public void Reroll(DFCareer dfClass)
        {
            // Assign base stats from class template
            DaggerfallStats rolledStats = CharacterDocument.GetClassBaseStats(dfClass);

            // Roll bonus value for each base stat
            // Using maxBonusRoll + 1 as Unity's Random.Range(int,int) is exclusive
            // of maximum value and we want to be inclusive of maximum value
            int strength     = rolledStats.PermanentStrength + UnityEngine.Random.Range(minBonusRoll, maxBonusRoll + 1);
            int intelligence = rolledStats.PermanentIntelligence + UnityEngine.Random.Range(minBonusRoll, maxBonusRoll + 1);
            int willpower    = rolledStats.PermanentWillpower + UnityEngine.Random.Range(minBonusRoll, maxBonusRoll + 1);
            int agility      = rolledStats.PermanentAgility + UnityEngine.Random.Range(minBonusRoll, maxBonusRoll + 1);
            int endurance    = rolledStats.PermanentEndurance + UnityEngine.Random.Range(minBonusRoll, maxBonusRoll + 1);
            int personality  = rolledStats.PermanentPersonality + UnityEngine.Random.Range(minBonusRoll, maxBonusRoll + 1);
            int speed        = rolledStats.PermanentSpeed + UnityEngine.Random.Range(minBonusRoll, maxBonusRoll + 1);
            int luck         = rolledStats.PermanentLuck + UnityEngine.Random.Range(minBonusRoll, maxBonusRoll + 1);

            rolledStats.SetPermanentStatValue(DFCareer.Stats.Strength, strength);
            rolledStats.SetPermanentStatValue(DFCareer.Stats.Intelligence, intelligence);
            rolledStats.SetPermanentStatValue(DFCareer.Stats.Willpower, willpower);
            rolledStats.SetPermanentStatValue(DFCareer.Stats.Agility, agility);
            rolledStats.SetPermanentStatValue(DFCareer.Stats.Endurance, endurance);
            rolledStats.SetPermanentStatValue(DFCareer.Stats.Personality, personality);
            rolledStats.SetPermanentStatValue(DFCareer.Stats.Speed, speed);
            rolledStats.SetPermanentStatValue(DFCareer.Stats.Luck, luck);

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

            // Apply stats to control
            SetStats(rolledStats, rolledStats, bonusPool);
            UpdateStatLabels();

            // Play "rolling dice" sound
            DaggerfallUI.Instance.PlayOneShot(SoundClips.DiceRoll);
        }
コード例 #6
0
ファイル: RacesRedone.cs プロジェクト: bp-tags/RacesRedone
        private static void SetAttributes()
        {
            PlayerEntity    playerEntity = GameManager.Instance.PlayerEntity;
            DaggerfallStats stats        = playerEntity.Stats;
            RaceTemplate    playerRace   = playerEntity.RaceTemplate;
            int             maxStat      = FormulaHelper.MaxStatValue();

            if (agility > maxStat || endurance > maxStat || intelligence > maxStat || luck > maxStat || personality > maxStat || speed > maxStat || strength > maxStat || willpower > maxStat)
            {
                string[] messages = new string[] { "Your racial modifiers have increased one or", "more Attribute over the maximum limit. It will be reduced." };
                StatusPopup(messages);
            }

            if (agility > maxStat)
            {
                agility = maxStat;
            }
            if (endurance > maxStat)
            {
                endurance = maxStat;
            }
            if (intelligence > maxStat)
            {
                intelligence = maxStat;
            }
            if (luck > maxStat)
            {
                luck = maxStat;
            }
            if (personality > maxStat)
            {
                personality = maxStat;
            }
            if (speed > maxStat)
            {
                speed = maxStat;
            }
            if (strength > maxStat)
            {
                strength = maxStat;
            }
            if (willpower > maxStat)
            {
                willpower = maxStat;
            }

            if (agility <= 0)
            {
                dumbPlayer = true;
            }
            if (endurance <= 0)
            {
                dumbPlayer = true;
            }
            if (intelligence <= 0)
            {
                dumbPlayer = true;
            }
            if (luck <= 0)
            {
                dumbPlayer = true;
            }
            if (personality <= 0)
            {
                dumbPlayer = true;
            }
            if (speed <= 0)
            {
                dumbPlayer = true;
            }
            if (strength <= 0)
            {
                dumbPlayer = true;
            }
            if (willpower <= 0)
            {
                dumbPlayer = true;
            }

            stats.SetPermanentStatValue(DFCareer.Stats.Agility, agility);
            stats.SetPermanentStatValue(DFCareer.Stats.Endurance, endurance);
            stats.SetPermanentStatValue(DFCareer.Stats.Intelligence, intelligence);
            stats.SetPermanentStatValue(DFCareer.Stats.Luck, luck);
            stats.SetPermanentStatValue(DFCareer.Stats.Personality, personality);
            stats.SetPermanentStatValue(DFCareer.Stats.Speed, speed);
            stats.SetPermanentStatValue(DFCareer.Stats.Strength, strength);
            stats.SetPermanentStatValue(DFCareer.Stats.Willpower, willpower);
        }
コード例 #7
0
ファイル: LevelUp.cs プロジェクト: bp-tags/LevelUp
        private static void StartAttrbutes_OnStartGame(object sender, EventArgs e)
        {
            int maxStat = FormulaHelper.MaxStatValue();

            DaggerfallStats stats = playerEntity.Stats;

            int agility      = playerEntity.Stats.PermanentAgility + startAttribute;
            int endurance    = playerEntity.Stats.PermanentEndurance + startAttribute;
            int intelligence = playerEntity.Stats.PermanentIntelligence + startAttribute;
            int luck         = playerEntity.Stats.PermanentLuck + startAttribute;
            int personality  = playerEntity.Stats.PermanentPersonality + startAttribute;
            int speed        = playerEntity.Stats.PermanentSpeed + startAttribute;
            int strength     = playerEntity.Stats.PermanentStrength + startAttribute;
            int willpower    = playerEntity.Stats.PermanentWillpower + startAttribute;

            if (agility - startAttribute < 2 || endurance + startAttribute < 2 || intelligence + startAttribute < 2 || luck + startAttribute < 2 || personality + startAttribute < 2 || speed + startAttribute < 2 || strength + startAttribute < 2 || willpower + startAttribute < 2)
            {
                string[] messages = new string[] { "LevelUp Adjuster has changed all starting attributes by " + startAttribute.ToString() + ".", "One or more of your attributes is reduced 1 or 0, which kills you." };
                StatusPopup(messages);
            }
            else if (agility + startAttribute > maxStat || endurance + startAttribute > maxStat || intelligence + startAttribute > maxStat || luck + startAttribute > maxStat || personality + startAttribute > maxStat || speed + startAttribute > maxStat || strength + startAttribute > maxStat || willpower + startAttribute > maxStat)
            {
                string[] messages = new string[] { "LevelUp Adjuster has changed all starting attributes by " + startAttribute.ToString() + ".", "One or more of your attributes is higher than the allowed maximum of " + maxStat.ToString() + " and will be adjusted down." };
                StatusPopup(messages);

                if (agility > maxStat)
                {
                    agility = maxStat;
                }
                if (endurance > maxStat)
                {
                    endurance = maxStat;
                }
                if (intelligence > maxStat)
                {
                    intelligence = maxStat;
                }
                if (luck > maxStat)
                {
                    luck = maxStat;
                }
                if (personality > maxStat)
                {
                    personality = maxStat;
                }
                if (speed > maxStat)
                {
                    speed = maxStat;
                }
                if (strength > maxStat)
                {
                    strength = maxStat;
                }
                if (willpower > maxStat)
                {
                    willpower = maxStat;
                }
            }
            else
            {
                string[] messages = new string[] { "LevelUp Adjuster has changed all starting attributes by " + startAttribute.ToString() + "." };
                StatusPopup(messages);
            }

            stats.SetPermanentStatValue(DFCareer.Stats.Agility, agility);
            stats.SetPermanentStatValue(DFCareer.Stats.Endurance, endurance);
            stats.SetPermanentStatValue(DFCareer.Stats.Intelligence, intelligence);
            stats.SetPermanentStatValue(DFCareer.Stats.Luck, luck);
            stats.SetPermanentStatValue(DFCareer.Stats.Personality, personality);
            stats.SetPermanentStatValue(DFCareer.Stats.Speed, speed);
            stats.SetPermanentStatValue(DFCareer.Stats.Strength, strength);
            stats.SetPermanentStatValue(DFCareer.Stats.Willpower, willpower);
        }