예제 #1
0
        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));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }