Пример #1
0
    // Use this for initialization
    void Start()
    {
        var dieDic = DieTypes.AttackDie;

        stats     = gameObject.AddComponent <RPGDefaultStats>();
        health    = stats.GetStat <RPGVital>(RPGStatType.Health);
        willpower = stats.GetStat <RPGVital>(RPGStatType.Willpower);
        stamina   = stats.GetStat <RPGVital>(RPGStatType.Stamina);
        dex       = stats.GetStat <RPGAttribute>(RPGStatType.Dexterity);
        attackDie = stats.GetStat <RPGAttribute>(RPGStatType.DieType);
        level     = stats.GetStat <RPGAttribute>(RPGStatType.Level);
        attack    = stats.GetStat <RPGAttribute>(RPGStatType.Attack);
        will      = stats.GetStat <RPGAttribute>(RPGStatType.Will);
        defense   = stats.GetStat <RPGAttribute>(RPGStatType.Defense);
        alive     = stats.GetStat <RPGAttribute>(RPGStatType.Alive);
        speed     = stats.GetStat <RPGAttribute>(RPGStatType.Speed);
        evasion   = stats.GetStat <RPGAttribute>(RPGStatType.Evasion);

        ///Modifiy base stats
        ///
        stamina.StatCurrentValue = 0;
        health.StatBaseValue     = health.StatBaseValue;
        health.SetCurrentValueToMax();
        attackDie.StatBaseValue = DieTypes.GetAttackDie(DieTypes.DieType.D4);
        dex.StatBaseValue       = dex.StatBaseValue + 2;
        dex.UpdateLinkers();
    }
Пример #2
0
        public void Integer_Attribute_Correctly_Adds_Percent_Mod(int dfValue, float pctMod, int expected)
        {
            RPGAttribute  attr = Substitute.ForPartsOf <RPGAttribute>(AttributeType.Integer, dfValue);
            IAttributeMod mod  = attr.AddPercentModifier(pctMod);

            Assert.AreEqual(expected, mod.ValueAsInt());
            Assert.AreEqual(expected, mod.ValueAsFloat());
        }
Пример #3
0
        public void Float_Attribute_Correctly_Adds_Flat_Mod(float flatMod)
        {
            RPGAttribute  attr = Setup(AttributeType.Float);
            IAttributeMod mod  = attr.AddFlatModifier(flatMod);

            float modVal = flatMod;

            Assert.AreEqual((int)modVal, mod.ValueAsInt());
            Assert.AreEqual(modVal, mod.ValueAsFloat());
        }
Пример #4
0
        public void RPG_Attribute_Empty_Constructor_Correctly_Initializes_Attribute(AttributeType type)
        {
            RPGAttribute attr = Substitute.ForPartsOf <RPGAttribute>(type);

            Assert.AreEqual(0, attr.defaultValue);
            Assert.AreEqual(-1, attr.maxValue);
            Assert.AreEqual(0, attr.ValueAsFloat());

            Assert.NotNull(attr.FlatMods);
            Assert.NotNull(attr.PercentMods);
        }
Пример #5
0
        public void SetupMockAttribute()
        {
            _changed  = false;
            _mockAttr = Substitute.ForPartsOf <RPGAttribute>(AttributeType.Float, _dfValue, _maxValue);

            _mockAttr.onAttributeChanged += () => _changed = true;

            _mockAttr.When(x => x.CalculateMods()).Do(x => {
                float total = 0;
                foreach (var pct in _mockAttr.PercentMods)
                {
                    total += pct.ValueAsFloat();
                }
                foreach (var flat in _mockAttr.FlatMods)
                {
                    total += flat.ValueAsFloat();
                }

                _mockAttr.ModsValue.Returns(total);
            });
        }
Пример #6
0
        public void RPG_Attribute_Full_Constructor_Correctly_Initializes_Attribute(
            AttributeType type, float dfVal, float maxVal
            )
        {
            RPGAttribute attr = Substitute.ForPartsOf <RPGAttribute>(type, dfVal, maxVal);

            if (type == AttributeType.Integer)
            {
                Assert.AreEqual((int)dfVal, attr.defaultValue);
                Assert.AreEqual((int)dfVal, attr.ValueAsFloat());
                Assert.AreEqual((int)maxVal, attr.maxValue);
            }
            else
            {
                Assert.AreEqual(dfVal, attr.defaultValue);
                Assert.AreEqual(dfVal, attr.ValueAsFloat());
                Assert.AreEqual(maxVal, attr.maxValue);
            }

            Assert.NotNull(attr.FlatMods);
            Assert.NotNull(attr.PercentMods);
        }
Пример #7
0
    // Use this for initialization
    void Start()
    {
        var dieDic = DieTypes.AttackDie;

        stats       = gameObject.AddComponent <RPGDefaultStats>();
        socialStats = gameObject.GetComponent <SocialStats>();
        health      = stats.GetStat <RPGVital>(RPGStatType.Health);
        willpower   = stats.GetStat <RPGVital>(RPGStatType.Willpower);
        stamina     = stats.GetStat <RPGVital>(RPGStatType.Stamina);
        dex         = stats.GetStat <RPGAttribute>(RPGStatType.Dexterity);
        attackDie   = stats.GetStat <RPGAttribute>(RPGStatType.DieType);
        level       = stats.GetStat <RPGAttribute>(RPGStatType.Level);
        attack      = stats.GetStat <RPGAttribute>(RPGStatType.Attack);
        will        = stats.GetStat <RPGAttribute>(RPGStatType.Will);
        defense     = stats.GetStat <RPGAttribute>(RPGStatType.Defense);
        alive       = stats.GetStat <RPGAttribute>(RPGStatType.Alive);
        speed       = stats.GetStat <RPGAttribute>(RPGStatType.Speed);
        evasion     = stats.GetStat <RPGAttribute>(RPGStatType.Evasion);

        if (gameObject.GetComponent <CurrentState>().inCombat)
        {
            SetPlayerStatusBars();
        }


        ///Modifiy base stats
        ///
        health.StatBaseValue += 10;
        health.SetCurrentValueToMax();
        attackDie.StatBaseValue = DieTypes.GetAttackDie(DieTypes.DieType.D4);
        dex.StatBaseValue       = dex.StatBaseValue + 1;
        dex.UpdateLinkers();
        Debug.Log("Player health is: " + health.StatBaseValue);
        Debug.Log("Extroversion: " + socialStats.GetStat(SocialStats.SocialStatType.Extroversion).StatBaseValue);

        ///Tests
        socialStats.SocialStatChange(socialStats.GetStat(SocialStats.SocialStatType.Extroversion));
        Debug.Log("Extroversion after increment: " + socialStats.GetStat(SocialStats.SocialStatType.Extroversion).StatValue);
    }