public void CommandApplyTakeOffEquipmentItem(int netId, long realId) { E_Character charObj = EM_Character.s_instance.GetCharacterByNetworkId(netId); E_EquipmentRegion eqRegion = EM_Item.s_instance.GetEquiped(netId); E_Bag bag = EM_Item.s_instance.GetBag(netId); if (charObj == null || eqRegion == null || bag == null) { return; } // 得到装备 short posInEqRegion; var eq = eqRegion.GetItemByRealId(realId, out posInEqRegion) as E_EquipmentItem; if (eq == null) { return; } // 寻找背包空插槽 E_EmptyItem bagSlot; var bagPos = bag.GetEmptySlot(out bagSlot); if (bagPos < 0 || bagSlot == null) { return; } NotifyCharacterSwapItemPlace(netId, charObj.m_characterId, bag, bagPos, bagSlot, eqRegion, posInEqRegion, eq); // 装备脱下改变Attr GL_CharacterAttribute.s_instance.NotifyConcreteAttributeMinus(charObj, EquipmentToAttrList(eq)); // client TODO: 所有角色的卸除装备接口 m_networkService.SendServerCommand(SC_ApplyAllChangeEquipment.Instance(EM_Sight.s_instance.GetInSightCharacterNetworkId(netId, true), netId, eq.m_ItemId)); }
public void CommandApplyUseEquipmentItem(int netId, long realId) { E_Character charObj = EM_Character.s_instance.GetCharacterByNetworkId(netId); E_EquipmentRegion eqRegion = EM_Item.s_instance.GetEquiped(netId); E_Bag bag = EM_Item.s_instance.GetBag(netId); if (charObj == null || eqRegion == null || bag == null) { return; } short posInBag = -1; var eq = bag.GetItemByRealId(realId, out posInBag) as E_EquipmentItem; if (eq == null) { return; } // 该位置原有装备卸下 E_Item oriItem; short oriPos = eqRegion.GetEquipmentByEquipPosition(eq.m_EquipmentPosition, out oriItem); if (oriPos < 0 || oriItem == null) { return; } if (oriItem.m_Type == ItemType.EQUIPMENT) { GL_CharacterAttribute.s_instance.NotifyConcreteAttributeMinus(charObj, EquipmentToAttrList(oriItem as E_EquipmentItem)); } // 装备穿上Attr GL_CharacterAttribute.s_instance.NotifyConcreteAttributeAdd(charObj, EquipmentToAttrList(eq)); NotifyCharacterSwapItemPlace(charObj.m_networkId, charObj.m_characterId, eqRegion, oriPos, oriItem, bag, posInBag, eq); // client m_networkService.SendServerCommand(SC_ApplyAllChangeEquipment.Instance(EM_Sight.s_instance.GetInSightCharacterNetworkId(netId, true), netId, eq.m_ItemId)); }