/// <summary> /// 请求当前账户内的角色信息 /// </summary> public void RequestCharacterInfos() { GetPlayerInfosReq req = new GetPlayerInfosReq(); req.accountId = PlayerData.AccountId; MobaNetwork.Send((ushort)MessageId.EGetPlayerInfosReq, req); }
public override void Open(params object[] parms) { base.Open(parms); BagInfoReq req = new BagInfoReq(); req.playerId = PlayerData.Me.info.id; MobaNetwork.Send((ushort)MessageId.EBagInfoReq, req); }
/// <summary> /// 发送签到数据 /// </summary> /// <param name="id"></param> public void SendSignedRequest(int id) { SignInReq req = new SignInReq(); req.signId = id; req.SignInTime = new TimeInfo(); req.SignInTime.time = TimeSystem.ServerTime; MobaNetwork.Send((ushort)MessageId.ESignInReq, req); }
public void Login() { LoginReq req = new LoginReq(); req.username = username.text; req.password = password.text; req.serverIp = "172.16.12.1"; MobaNetwork.Send((ushort)MessageId.ELoginReq, req); }
public void Register() { //限制逻辑 RegisterReq req = new RegisterReq(); req.username = username.text; req.password = password.text; req.deviceID = SystemInfo.deviceUniqueIdentifier;//设备ID req.channel = "UC"; MobaNetwork.Send((ushort)MessageId.ERegisterReq, req); }
/// <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); }
private void EnterGameReq() { if (PlayerData.SelectPlayer == null) { MUIMgr.Instance.ShowAlert(OpenType.Long, null, null, "错误", "请选择角色或者创建角色再进入游戏", "确定"); return; } SelectPlayerReq req = new SelectPlayerReq(); req.gameServerIp = ""; req.id = PlayerData.SelectPlayer.id; MobaNetwork.Send((ushort)MessageId.ESelectPlayerReq, req); }
/// <summary> /// 创建角色 /// </summary> private void CreatePlayer() { if (currentTypeId == "" || currentTypeId == null) { MUIMgr.Instance.ShowAlert(OpenType.Long, null, null, "错误", "请选择一个职业", "确定"); return; } if (inputName.text == null || inputName.text == "") { MUIMgr.Instance.ShowAlert(OpenType.Long, null, null, "错误", "请输入角色名", "确定"); return; } CreatePlayerInfoReq req = new CreatePlayerInfoReq(); req.accountId = PlayerData.AccountId.ToString(); req.name = inputName.text; req.type = Convert.ToInt32(currentTypeId); MobaNetwork.Send((int)MessageId.ECreatePlayerInfoReq, req); }
/// <summary> /// 刷新商店道具UI的功能 /// </summary> /// <param name="parms"></param> public override void Refresh(params object[] parms) { base.Refresh(parms); props = ConfigInfo.Instance.ShopConfigs[((int)currentSelectGroup).ToString()]; //每次刷新UI之前把之前的UI清空掉 for (int i = 0; i < items.Count; i++) { Destroy(items[i]); } items.Clear(); for (int i = 0; i < props.Count; i++) { //go每一个道具的UI预制体 var go = ResourceMgr.CreateUIPrefab("GUIs/Shop/ShopItem", content); go.name = props[i].Id; items.Add(go); ShopConfig shopConfig = props[i]; PropInfoConfig propConfig = ConfigInfo.Instance.Props[shopConfig.PropId]; Text nameText = Utility.FindChild <Text>(go.transform, "Text_itemName"); Image icon = Utility.FindChild <Image>(go.transform, "Icon"); Text costText = Utility.FindChild <Text>(go.transform, "cost"); nameText.text = propConfig.Name; icon.sprite = ResourceMgr.Load <Sprite>("Sprites/Props/" + propConfig.Icon); icon.gameObject.AddComponent <Button>(); icon.gameObject.GetComponent <Button>().onClick.AddListener(() => { BuyPropReq req = new BuyPropReq(); req.id = PlayerData.Me.info.id; req.num = 1; req.storeId = Convert.ToInt32(go.name); MobaNetwork.Send((ushort)MessageId.EBuyPropReq, req); }); Image coin = Utility.FindChild <Image>(go.transform, "coin"); coin.sprite = ResourceMgr.LoadSpriteFromAtals(Utility.CTInt(shopConfig.Cost_Type), "Sprites/Coins"); costText.text = shopConfig.Cost_Num; } }
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; }