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)); }
public void CommandApplyUseConsumableItem(int netId, long realId) { E_Character charObj = EM_Character.s_instance.GetCharacterByNetworkId(netId); E_Bag bag = EM_Item.s_instance.GetBag(netId); if (bag == null || charObj == null) { return; } short posInBag = -1; E_ConsumableItem item = bag.GetItemByRealId(realId, out posInBag) as E_ConsumableItem; if (item == null) { return; } GL_UnitBattleAttribute.s_instance.NotifyApplyEffect(item.m_consumableDe.m_itemEffect, -1, charObj, charObj); NotifyCharacterLoseItem(netId, charObj.m_characterId, item, 1, posInBag, bag); }
public void CommandApplyBuyItemIntoBag(int netId, short itemId, short num) { if (num == 0) { return; } int charId = EM_Character.s_instance.GetCharIdByNetId(netId); E_Bag bag = EM_Item.s_instance.GetBag(netId); var wallet = EM_Wallet.s_instance.GetWallet(netId); if (charId == -1 || bag == null || wallet.Item1 == -1) { return; } // 背包容量不足 if (!bag.CanPutItem(itemId, num)) { GL_Chat.s_instance.NotifyBuyItemBagFullSendMessage(netId); return; } // 货币不正确 long needCy = EM_Item.s_instance.GetItemBuyPrice(itemId); if (needCy == -1) { GL_Chat.s_instance.NotifyBuyItemCyErrSendMessage(netId); return; } // 货币不足 needCy *= num; long charCy = wallet.Item2; if (charCy < needCy) { GL_Chat.s_instance.NotifyBuyItemShortOfCySendMessage(netId); return; } GL_Wallet.s_instance.NotifyUpdateVirtualCurrencyOnline(netId, charId, -needCy); NotifyCharacterGainItem(netId, charId, bag, itemId, num); }
public void CommandApplySellItemInBag(int netId, long realId, short num) { int charId = EM_Character.s_instance.GetCharIdByNetId(netId); E_Bag bag = EM_Item.s_instance.GetBag(netId); if (charId == -1 || bag == null) { return; } short pos; E_Item item = bag.GetItemByRealId(realId, out pos); if (item == null) { return; } // 失去物品 NotifyCharacterLoseItem(netId, charId, item, num, pos, bag); // 拿钱 var virCy = (int)(item.m_SellPrice * num); GL_Wallet.s_instance.NotifyUpdateVirtualCurrencyOnline(netId, charId, virCy); }