示例#1
0
 public DialogueEffectSecondaryAttributeModifierHandler(Character target, SecondaryAttribute attribute, int mod, bool add = true) : base()
 {
     this.target    = target;
     this.attribute = attribute;
     this.mod       = mod;
     this.add       = add;
 }
示例#2
0
 void CreateSecondaryAttribute()
 {
     secAttributes = new SecondaryAttribute[(int)SecondaryAttributeName.Count];
     for (int i = 0; i < secAttributes.Length; i++)
     {
         secAttributes[i] = new SecondaryAttribute((SecondaryAttributeName)i, GetSecondaryAttributeModifier((SecondaryAttributeName)i));
     }
 }
示例#3
0
    public static SecondaryAttribute read(BinaryReader binaryReader)
    {
        SecondaryAttribute newObj = new SecondaryAttribute();

        newObj._level_from_cp = binaryReader.ReadUInt32();
        newObj._init_level    = binaryReader.ReadUInt32();
        newObj._cp_spent      = binaryReader.ReadUInt32();
        newObj._current_level = binaryReader.ReadUInt32();
        return(newObj);
    }
示例#4
0
    public static void initReaders()
    {
        if (readers == null)
        {
            readers = new Dictionary <Type, Func <BinaryReader, dynamic> >();
            readers.Add(typeof(byte), r => r.ReadByte());
            readers.Add(typeof(ushort), r => r.ReadUInt16());
            readers.Add(typeof(short), r => r.ReadInt16());
            readers.Add(typeof(uint), r => r.ReadUInt32());
            readers.Add(typeof(int), r => r.ReadInt32());
            readers.Add(typeof(ulong), r => r.ReadUInt64());
            readers.Add(typeof(long), r => r.ReadInt64());
            readers.Add(typeof(float), r => r.ReadSingle());
            readers.Add(typeof(double), r => r.ReadDouble());

            readers.Add(typeof(PStringChar), r => PStringChar.read(r));

            readers.Add(typeof(STypeInt), r => (STypeInt)r.ReadUInt32());
            readers.Add(typeof(STypeInt64), r => (STypeInt64)r.ReadUInt32());
            readers.Add(typeof(STypeBool), r => (STypeBool)r.ReadUInt32());
            readers.Add(typeof(STypeFloat), r => (STypeFloat)r.ReadUInt32());
            readers.Add(typeof(STypeString), r => (STypeString)r.ReadUInt32());
            readers.Add(typeof(STypeDID), r => (STypeDID)r.ReadUInt32());
            readers.Add(typeof(STypePosition), r => (STypePosition)r.ReadUInt32());
            readers.Add(typeof(STypeIID), r => (STypeIID)r.ReadUInt32());
            readers.Add(typeof(STypeSkill), r => (STypeSkill)r.ReadUInt32());

            //readers.Add(typeof(CharacterTitle), r => (CharacterTitle)r.ReadUInt32());
            //readers.Add(typeof(SKILL_ADVANCEMENT_CLASS), r => (SKILL_ADVANCEMENT_CLASS)r.ReadUInt32());

            readers.Add(typeof(CM_Magic.Enchantment), r => CM_Magic.Enchantment.read(r));
            readers.Add(typeof(CM_Magic.EnchantmentID), r => CM_Magic.EnchantmentID.read(r));
            //readers.Add(typeof(CM_Social.FriendData), r => CM_Social.FriendData.read(r));
            //readers.Add(typeof(CM_Social.CContractTracker), r => CM_Social.CContractTracker.read(r));
            readers.Add(typeof(Attribute), r => Attribute.read(r));
            readers.Add(typeof(SecondaryAttribute), r => SecondaryAttribute.read(r));
            readers.Add(typeof(Position), r => Position.read(r));
            readers.Add(typeof(Skill), r => Skill.read(r));

            readers.Add(typeof(SpellID), r => (SpellID)r.ReadUInt32());
            //readers.Add(typeof(CM_Vendor.ItemProfile), r => CM_Vendor.ItemProfile.read(r));
            //readers.Add(typeof(CM_Fellowship.Fellow), r => CM_Fellowship.Fellow.read(r));
            //readers.Add(typeof(CM_Fellowship.LockedFellowshipList), r => CM_Fellowship.LockedFellowshipList.read(r));
            readers.Add(typeof(CM_Inventory.ContentProfile), r => CM_Inventory.ContentProfile.read(r));
            readers.Add(typeof(CM_Login.InventoryPlacement), r => CM_Login.InventoryPlacement.read(r));
            //readers.Add(typeof(CM_Login.MissingIteration), r => CM_Login.MissingIteration.read(r));
            //readers.Add(typeof(CM_Login.CAllIterationList), r => CM_Login.CAllIterationList.read(r));
            //readers.Add(typeof(CM_Login.PTaggedIterationList), r => CM_Login.PTaggedIterationList.read(r));
            //readers.Add(typeof(CM_Login.CMostlyConsecutiveIntSet), r => CM_Login.CMostlyConsecutiveIntSet.read(r));
            //readers.Add(typeof(CM_House.HousePayment), r => CM_House.HousePayment.read(r));
            //readers.Add(typeof(CM_Inventory.SalvageResult), r => CM_Inventory.SalvageResult.read(r));
            //readers.Add(typeof(CM_Writing.PageData), r => CM_Writing.PageData.read(r));
        }
    }
示例#5
0
        public void SerializationTest()
        {
            Assert.IsTrue(typeof(PrimaryAttribute).IsSerializable);
            Assert.IsTrue(typeof(SecondaryAttribute).IsSerializable);
            Assert.IsTrue(typeof(VolumeAttribute).IsSerializable);

            var random = new Random();

            // Serialize a PrimaryAttribute
            Body.Value    = random.Next(10, 500);
            Body.MinValue = random.Next(0, 9);
            Body.MaxValue = random.Next(501, 999);
            Body.AddModifier(new TimeBasedModifier("Test", 10, 10));
            BinarySerialize(Body);

            // Binary deserialization of PrimaryAttribute
            PrimaryAttribute binarySerializedBody = (PrimaryAttribute)BinaryDeserialize(Body);

            Assert.AreEqual(Body.Value, binarySerializedBody.Value);
            Assert.AreEqual(Body.MinValue, binarySerializedBody.MinValue);
            Assert.AreEqual(Body.MaxValue, binarySerializedBody.MaxValue);
            PrimaryAttributeTest(binarySerializedBody);

            // Serialize a SecondaryAttribute
            Experience.Value = 100;
            BinarySerialize(Level);

            // Binary deserialization of SecondaryAttribute
            SecondaryAttribute binarySerializedLevel = (SecondaryAttribute)BinaryDeserialize(Level);

            Assert.AreEqual(Level.Value, binarySerializedLevel.Value);
            Assert.AreEqual(1, binarySerializedLevel.Attributes.Length);
            Experience.Value = 0;
            binarySerializedLevel.Attributes = new BaseAttribute[] { Experience };
            binarySerializedLevel.Value      = binarySerializedLevel.MaxValue;
            SecondaryAttributeTest(binarySerializedLevel);

            // Serialize a VolumeAttribute
            Body.MinValue = 0;
            Body.MaxValue = 999;
            Body.Value    = 0;
            Life.Value    = random.Next(0, 23);
            BinarySerialize(Life);

            // Binary deserialization of VolumeAttribute
            VolumeAttribute binarySerializedLife = (VolumeAttribute)BinaryDeserialize(Life);

            Assert.AreEqual(Life.Value, binarySerializedLife.Value);
            Assert.AreEqual(2, binarySerializedLife.Attributes.Length);
            Body.Value = 0;
            binarySerializedLife.Attributes = new BaseAttribute[] { Level, Body };
            binarySerializedLife.Value      = binarySerializedLife.MaxValue;
            VolumeTest(binarySerializedLife);
        }
示例#6
0
        public static AttributeCache read(BinaryReader binaryReader)
        {
            AttributeCache newObj = new AttributeCache();

            newObj.header        = binaryReader.ReadUInt32();
            newObj._strength     = Attribute.read(binaryReader);
            newObj._endurance    = Attribute.read(binaryReader);
            newObj._quickness    = Attribute.read(binaryReader);
            newObj._coordination = Attribute.read(binaryReader);
            newObj._focus        = Attribute.read(binaryReader);
            newObj._self         = Attribute.read(binaryReader);
            newObj._health       = SecondaryAttribute.read(binaryReader);
            newObj._stamina      = SecondaryAttribute.read(binaryReader);
            newObj._mana         = SecondaryAttribute.read(binaryReader);
            return(newObj);
        }
示例#7
0
 public void SetUp()
 {
     GameTime.Reset();
     Body                  = new PrimaryAttribute("Body", 0, 999, 10);
     Experience            = new PrimaryAttribute("Experience", 0);
     MagicRegenerationRate = new PrimaryAttribute("MagicRegenerationRate", 0, 99, 1);
     Level                 = new SecondaryAttribute("Level",
                                                    x => (int)(Math.Sqrt(x[0].Value / 100)) * 1f,
                                                    new BaseAttribute[] { Experience }, 0, 99);
     Life = new VolumeAttribute("Life",
                                x => (int)(20 + 5 * x[0].Value + x[1].Value / 3) * 1f,
                                new BaseAttribute[] { Level, Body }, 0, 999);
     Magic = new VolumeAttribute("Magic",
                                 x => (int)(20 + 5 * x[0].Value + x[1].Value / 3) * 1f,
                                 new BaseAttribute[] { Level, Body }, 0, 999);
     Energy = new SimpleVolumeAttribute("Energy", 0, 999, 0);
 }
示例#8
0
    public static void initReaders()
    {
        if (readers == null)
        {
            readers = new Dictionary <Type, Func <BinaryReader, dynamic> >();
            readers.Add(typeof(byte), r => r.ReadByte());
            readers.Add(typeof(ushort), r => r.ReadUInt16());
            readers.Add(typeof(short), r => r.ReadInt16());
            readers.Add(typeof(uint), r => r.ReadUInt32());
            readers.Add(typeof(int), r => r.ReadInt32());
            readers.Add(typeof(ulong), r => r.ReadUInt64());
            readers.Add(typeof(long), r => r.ReadInt64());
            readers.Add(typeof(float), r => r.ReadSingle());
            readers.Add(typeof(double), r => r.ReadDouble());

            readers.Add(typeof(PStringChar), r => PStringChar.read(r));

            readers.Add(typeof(STypeInt), r => (STypeInt)r.ReadUInt32());
            readers.Add(typeof(STypeInt64), r => (STypeInt64)r.ReadUInt32());
            readers.Add(typeof(STypeBool), r => (STypeBool)r.ReadUInt32());
            readers.Add(typeof(STypeFloat), r => (STypeFloat)r.ReadUInt32());
            readers.Add(typeof(STypeString), r => (STypeString)r.ReadUInt32());
            readers.Add(typeof(STypeDID), r => (STypeDID)r.ReadUInt32());
            readers.Add(typeof(STypePosition), r => (STypePosition)r.ReadUInt32());
            readers.Add(typeof(STypeIID), r => (STypeIID)r.ReadUInt32());
            readers.Add(typeof(STypeSkill), r => (STypeSkill)r.ReadUInt32());

            readers.Add(typeof(CharacterTitle), r => (CharacterTitle)r.ReadUInt32());
            readers.Add(typeof(SKILL_ADVANCEMENT_CLASS), r => (SKILL_ADVANCEMENT_CLASS)r.ReadUInt32());

            readers.Add(typeof(CM_Magic.Enchantment), r => CM_Magic.Enchantment.read(r));
            readers.Add(typeof(CM_Social.FriendData), r => CM_Social.FriendData.read(r));
            readers.Add(typeof(Attribute), r => Attribute.read(r));
            readers.Add(typeof(SecondaryAttribute), r => SecondaryAttribute.read(r));
            readers.Add(typeof(Position), r => Position.read(r));
            readers.Add(typeof(Skill), r => Skill.read(r));

            readers.Add(typeof(SpellID), r => (SpellID)r.ReadUInt32());
            readers.Add(typeof(CM_Vendor.ItemProfile), r => CM_Vendor.ItemProfile.read(r));
        }
    }
示例#9
0
        public PlayerStats()
        {
            // Primary Attributes
            Body             = new PrimaryAttribute("Body", 0, 999, 0);
            Mind             = new PrimaryAttribute("Mind", 0, 999, 0);
            Soul             = new PrimaryAttribute("Soul", 0, 999, 0);
            Experience       = new PrimaryAttribute("Experience", 0, 980100, 0);
            AlertnessRange   = new PrimaryAttribute("AlertnessRange", 2, 999, 2);
            AttackRange      = new PrimaryAttribute("AttackRange", 1, 999, 1);
            Damage           = new PrimaryAttribute("Damage", 0, 999, 0);
            MovementSpeed    = new PrimaryAttribute("MovementSpeed", 1, 10, 1);
            Alertness        = new PrimaryAttribute("Alertness", 0, 10, 0);
            ChasePersistency = new PrimaryAttribute("ChasePersistency", 0, 100, 0);

            // Secondary Attributes
            Level = new SecondaryAttribute("Level",
                                           x => (int)(Math.Sqrt(x[0].Value / 100)) * 1f,
                                           new BaseAttribute[] { Experience }, 0, 99);
            MagicRegenerationRate = new SecondaryAttribute(
                "MagicRegenerationRate",
                x => 1 + (x[0].Value / 1000),
                new BaseAttribute[] { Mind }, 0, 99);
            LifeRegenerationRate = new SecondaryAttribute(
                "LifeRegenerationRate",
                x => 1 + (x[0].Value / 1000),
                new BaseAttribute[] { Body }, 0, 99);

            // Volume Attributes
            Life = new VolumeAttribute("Life",
                                       x => (int)(20 + 5 * x[0].Value + x[1].Value / 3) * 1f,
                                       new BaseAttribute[] { Level, Body }, 0, 999);
            Magic = new VolumeAttribute("Magic",
                                        x => (int)(20 + 5 * x[0].Value + x[1].Value / 3) * 1f,
                                        new BaseAttribute[] { Level, Soul }, 0, 999);

            AssignAttributesToDict();
        }
示例#10
0
        private void SecondaryAttributeTest(SecondaryAttribute attr)
        {
            // Check the default values
            Assert.AreEqual(0, attr.MinValue);
            Assert.AreEqual(99, attr.MaxValue);
            Assert.AreEqual(0, attr.Value);

            // Try directly setting it
            attr.Value = float.MaxValue;
            Assert.AreEqual(0, attr.Value);
            attr.Value = float.MinValue;
            Assert.AreEqual(0, attr.Value);

            // Change the contributing attributes
            for (int i = 0; i < 100; i++)
            {
                float xp = i * i * 100;
                Experience.Value = xp;
                Assert.AreEqual(i, attr.Value);
            }
            Experience.Reset();
            Assert.AreEqual(0, Experience.Value);
            Assert.AreEqual(0, attr.Value);
        }
示例#11
0
 public int GetSecondaryAttributeValue(SecondaryAttribute attribute)
 {
     return(secondaryAttributes[attribute].GetValue());
 }
示例#12
0
 public void SetSecondaryAttributeValue(SecondaryAttribute attribute, int value)
 {
     secondaryAttributes[attribute].SetValue(value);
 }
示例#13
0
 public void RemoveSecondaryAttributeModification(SecondaryAttribute attribute, int modification)
 {
     secondaryAttributes[attribute].RemoveModification(modification);
 }
示例#14
0
 public void AddSecondaryAttributeModification(SecondaryAttribute attribute, int modification)
 {
     secondaryAttributes[attribute].AddModification(modification);
 }