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); } }
// 装备 // 如果该骨骼已经有同类型装备, 该装备将被回收 // 装备失败的原因: 超过了 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); }