Beispiel #1
0
        /// <summary>
        ///     Deserialization Constructor
        /// </summary>
        public AbilityData(AbilityPacket abilityPacket)
        {
            this.id      = new SaveableGuid(abilityPacket.abilityId);
            this.ability = RpgDataRegistry.Instance.SearchAbility(this.id.GuidData);

            Debug.Assert(this.ability != null, "An AbilityData instance could not be serialized because the definition file was not found! ID: " + abilityPacket.abilityId);
        }
        //
        // Serilaization
        //


        /// <summary>
        ///     Only to be called by the RpgCharacterSerializer
        /// </summary>
        public RpgCharacterPacket ExportSerializationPacket()
        {
            RpgCharacterPacket newPacket = new RpgCharacterPacket();

            newPacket.id                = this.id.GuidString;
            newPacket.name              = this.name;
            newPacket.hp                = this.hp;
            newPacket.maxHp             = this.maxHp;
            newPacket.additionalMaxHp   = this.additionalMaxHp;
            newPacket.unallocatedSpPool = this.unallocatedSpPool;
            newPacket.assignmentType    = this.assignmentType;

            newPacket.xpDataPacket = this.xpData.ExportSerializationPacket();

            foreach (StatData stat in this.appliedStats)
            {
                StatPacket newStatPacket = stat.ExportSerializationPacket();
                newPacket.appliedStats.Add(newStatPacket);
            }

            foreach (AbilityData ability in this.appliedAbilities)
            {
                AbilityPacket newAbilityPacket = ability.ExportSerializationPacket();
                newPacket.appliedAbilities.Add(newAbilityPacket);
            }

            return(newPacket);
        }
Beispiel #3
0
        /// <summary>
        ///     Only to be called by the RpgCharacterSerializer
        /// </summary>
        public AbilityPacket ExportSerializationPacket()
        {
            AbilityPacket newPacket = new AbilityPacket();

            newPacket.abilityId = this.id.GuidString;

            return(newPacket);
        }