Esempio n. 1
0
    /// <summary>
    /// 发送道具装备数据
    /// </summary>
    /// <param name="instanceId"></param>
    /// <param name="propId"></param>
    /// <param name="slot"></param>
    public void SendPropEquipInfo(int instanceId, int propId, int slot)
    {
        BagInfoEquipReq request = new BagInfoEquipReq();
        EquipPropInfo   prop    = new EquipPropInfo();

        prop.id     = instanceId;
        prop.propId = propId;
        prop.slot   = slot;
        request.equipedProps.Add(prop);
        request.playerId = PlayerData.Me.info.id;
        Debug.Log("SendPropEquipInfo" + prop.propId + "  " + prop.slot);
        MobaNetwork.Send((ushort)MessageId.EBagInfoEquipReq, request);
    }
Esempio n. 2
0
    public void OnEndDrag(PointerEventData eventData)
    {
        GameObject hitObject  = eventData.pointerCurrentRaycast.gameObject;
        int        instanceId = Convert.ToInt32(gameObject.name);
        int        propId     = PlayerData.BagInfos[instanceId].propId;

        Debug.LogError(hitObject);

        if (hitObject == null)
        {
            ResetParent(father.gameObject);
        }
        else
        {
            BagBlock block = hitObject.GetComponent <BagBlock>();

            if (block != null)
            {
                if (block.type == BagBlock.BlockType.CharacterBag)
                {
                    if (hitObject.name == ConfigInfo.GetProp(info.propId.ToString()).Type)
                    {
                        ResetParent(hitObject, true);
                        SendPropEquipInfo(instanceId, propId, Convert.ToInt32(block.name));
                    }
                    else
                    {
                        ResetParent(father.gameObject);
                    }
                }
                else if (block.type == BagBlock.BlockType.Bag)
                {
                    ResetParent(hitObject, true);
                    SendPropEquipInfo(instanceId, propId, Convert.ToInt32(block.name));
                }
                else
                {
                    ResetParent(father.gameObject);
                }
            }
            else
            {
                BagProp bp = hitObject.GetComponent <BagProp>();
                if (bp != null)
                { ///替换装备
                    if (bp.transform.parent.GetComponent <BagBlock>().type == BagBlock.BlockType.CharacterBag)
                    {
                        ResetParent(hitObject.transform.parent.gameObject, true);
                        BagInfoEquipReq request = new BagInfoEquipReq();

                        PropInfo swapedInfo = PlayerData.BagInfos[Convert.ToInt32(hitObject.name)];
                        PropInfo dragInfo   = PlayerData.BagInfos[Convert.ToInt32(gameObject.name)];

                        EquipPropInfo reprop = new EquipPropInfo();
                        reprop.id     = swapedInfo.id;
                        reprop.propId = swapedInfo.propId;


                        EquipPropInfo prop = new EquipPropInfo();
                        prop.id     = dragInfo.id;
                        prop.propId = dragInfo.propId;

                        reprop.slot = dragInfo.slot;
                        int swapSlot = swapedInfo.slot;
                        prop.slot = swapSlot;


                        request.playerId = PlayerData.Me.info.id;
                        request.equipedProps.Add(reprop);
                        request.equipedProps.Add(prop);

                        MobaNetwork.Send((ushort)MessageId.EBagInfoEquipReq, request);
                    }
                    else
                    {
                        ResetParent(father.gameObject);
                    }
                }
                else
                {
                    ResetParent(father.gameObject);
                }
            }
        }
        icon.raycastTarget = true;
    }