示例#1
0
            // 反序列化
            public static ArmorPartData Deserialize(BinaryReader r)
            {
                var data = new ArmorPartData();

                data._itemId = r.ReadInt32();
                data._type   = (ArmorType)(r.ReadByte());

                // 7: mirrored; 654: boneGroup; 3210: boneIndex
                byte tmp = r.ReadByte();

                data.mirrored  = (tmp & 0x80) != 0;
                data.boneGroup = (tmp & 0x70) >> 4;
                data.boneIndex = tmp & 0x0F;

                data.localPosition.x = r.ReadSingle();
                data.localPosition.y = r.ReadSingle();
                data.localPosition.z = r.ReadSingle();

                data.localEulerAngles.x = r.ReadSingle();
                data.localEulerAngles.y = r.ReadSingle();
                data.localEulerAngles.z = r.ReadSingle();

                data.localScale.x = r.ReadSingle();
                data.localScale.y = r.ReadSingle();
                data.localScale.z = r.ReadSingle();

                return(data);
            }
示例#2
0
        // 读取数据
        public override void Deserialize(BinaryReader r)
        {
            // 版本号
            r.ReadByte();

            // 当前装备
            _currentSuitIndex = r.ReadByte();

            // 套装总数
            int suitCount = r.ReadByte();

            _data = new List <List <ArmorPartData> >(suitCount < 8 ? 8 : suitCount);

            for (int i = 0; i < suitCount; i++)
            {
                // 部件总数
                int partCount = r.ReadByte();
                _data.Add(new List <ArmorPartData>(20));

                for (int j = 0; j < partCount; j++)
                {
                    _data[i].Add(ArmorPartData.Deserialize(r));
                }
            }
        }
示例#3
0
            // 构造对象
            public ArmorPartObject(PlayerArmorCmpt character, ArmorPartData data, ItemObject item)
            {
                _character  = character;
                _data       = data;
                _item       = item;
                _armorID[0] = item.instanceId;

                _boneGroup = -1;
                _boneIndex = -1;

                if (data.type == ArmorType.Decoration)
                {
                    _character._decorationCount++;
                }
                _durability = _item.GetCmpt <Durability>();

                SyncAttachedBone();

                // 添加防御效果
                AddDefence();

                if (_character.hasModelLayer)
                {
                    CreateModel();
                }

                _character.TriggerAddOrRemoveEvent();
            }
示例#4
0
        public void S2C_EquipArmorPartFromPackage(int itemID, int typeValue, int boneGroup, int boneIndex, bool success)
        {
            if (success)
            {
                ItemObject item = ItemMgr.Instance.Get(itemID);
                ArmorType  type = (ArmorType)typeValue;

                ArmorPartObject oldArmor = null;
                if (type == ArmorType.Decoration)
                {
                    oldArmor = _boneNodes[boneGroup][boneIndex].decoration;
                }
                else
                {
                    oldArmor = _boneNodes[boneGroup][boneIndex].normal;
                }

                // 回收旧部件

                if (oldArmor != null)
                {
                    oldArmor.RemoveArmorPart();
                    int index = _armorObjects.FindIndex(armor => armor == oldArmor);
                    if (index >= 0)
                    {
                        _armorObjects.RemoveAt(index);
                        _data[_currentSuitIndex].RemoveAt(index);
                    }
                }

                // 装备新部件

                ArmorPartData partData = new ArmorPartData(item.instanceId, type);
                partData.boneGroup = boneGroup;
                partData.boneIndex = boneIndex;

                _data[_currentSuitIndex].Add(partData);
                _armorObjects.Add(new ArmorPartObject(this, partData, item));
            }

            //
            _requestCount--;
            if (_equipArmorPartFromPackageCallback != null)
            {
                _equipArmorPartFromPackageCallback(success);
            }
        }
示例#5
0
        // 装备
        // 如果该骨骼已经有同类型装备, 该装备将被回收
        // 装备失败的原因: 超过了 4 个 Decoration; 发生了其他的一些奇怪的事情...
        public bool EquipArmorPartFromPackage(ItemObject item, ArmorType type, int boneGroup, int boneIndex)
        {
            if (item == null || type == ArmorType.None)
            {
                return(false);
            }

            if (type == ArmorType.Decoration)
            {
                if (_decorationCount == 4 && _boneNodes[boneGroup][boneIndex].decoration == null)
                {
                    return(false);
                }
            }
            else
            {
                if ((int)type != boneGroup)
                {
                    return(false);
                }
            }

            // 从背包移出部件
            int index = _slotList.FindItemIndexById(item.instanceId);

            if (index < 0)
            {
                return(false);
            }
            _slotList[index] = null;

            ArmorPartObject oldArmor = null;

            if (type == ArmorType.Decoration)
            {
                oldArmor = _boneNodes[boneGroup][boneIndex].decoration;
            }
            else
            {
                oldArmor = _boneNodes[boneGroup][boneIndex].normal;
            }

            // 回收旧部件
            if (oldArmor != null)
            {
                _slotList.Add(oldArmor.item);
                oldArmor.RemoveArmorPart();
                index = _armorObjects.FindIndex(armor => armor == oldArmor);
                if (index >= 0)
                {
                    _armorObjects.RemoveAt(index);
                    _data[_currentSuitIndex].RemoveAt(index);
                }
            }

            // 装备新部件
            ArmorPartData partData = new ArmorPartData(item.instanceId, type);

            partData.boneGroup = boneGroup;
            partData.boneIndex = boneIndex;

            _data[_currentSuitIndex].Add(partData);
            _armorObjects.Add(new ArmorPartObject(this, partData, item));

            return(true);
        }