void BtnRegistClick() { if (string.IsNullOrEmpty(id.text)) { promptMsg.ChangeText("账号不能为空", Color.red); Dispatch(AreaCode.UI, UIEvent.PROMPTA_ANIM, promptMsg); return; } if (string.IsNullOrEmpty(password.text)) { promptMsg.ChangeText("密码不能为空", Color.red); Dispatch(AreaCode.UI, UIEvent.PROMPTA_ANIM, promptMsg); return; } if (string.IsNullOrEmpty(repeat.text) || repeat.text != password.text) { promptMsg.ChangeText("账号密码不一致", Color.red); Dispatch(AreaCode.UI, UIEvent.PROMPTA_ANIM, promptMsg); return; } AccountDto dto = new AccountDto(id.text, password.text); socketMsg.Change(OpCode.ACCOUNT, AccountCode.REGIST_CREQ, dto); Dispatch(AreaCode.NET, 0, socketMsg); //ClearText(); }
/// <summary> /// 他人进入的的处理 /// </summary> private void EnterBroadcast(UserDto newUser) { MatchRoomDto room = Model.gameModel.matchRoomDto; //更新房间数据 room.Add(newUser); //重置玩家位置 //显示现在房间内的玩家 ResetPositon(); if (room.leftId != -1) { UserDto leftDto = room.uIdUserDtoDict[room.leftId]; Dispatch(AreaCode.UI, UIEvent.SET_LEFT_PLAYER_DATA, leftDto); } if (room.rightId != -1) { UserDto rightDto = room.uIdUserDtoDict[room.rightId]; Dispatch(AreaCode.UI, UIEvent.SET_RIGHT_PLAYER_DATA, rightDto); } //发消息 打开玩家状态面板所有物体 Dispatch(AreaCode.UI, UIEvent.PLAYER_ENTER, newUser.id); //告诉用户玩家进入 msg.ChangeText(newUser.name + "进入了游戏", Color.yellow); Dispatch(AreaCode.UI, UIEvent.PROMPTA_ANIM, msg); }
void BtnCreatClick() { if (string.IsNullOrEmpty(inputName.text)) { msg.ChangeText("你在逗我么?", Color.red); Dispatch(AreaCode.UI, UIEvent.PROMPTA_ANIM, msg); return; } // 向服务器发起创建请求 socketmsg.Change(OpCode.USER, UserCode.CREAT_CREQ, inputName.text); Dispatch(AreaCode.NET, 0, socketmsg); }
void LoginClick() { if (string.IsNullOrEmpty(textID.text)) { promptMsg.ChangeText("账号不能为空", Color.red); Dispatch(AreaCode.UI, UIEvent.PROMPTA_ANIM, promptMsg); return; } if (string.IsNullOrEmpty(textPasword.text)) { promptMsg.ChangeText("密码不能为空", Color.red); Dispatch(AreaCode.UI, UIEvent.PROMPTA_ANIM, promptMsg); return; } AccountDto dto = new AccountDto(textID.text, textPasword.text); socketMsg.Change(OpCode.ACCOUNT, AccountCode.LOGIN, dto); Dispatch(AreaCode.NET, 0, socketMsg); //ClearText(); }
/// <summary> /// 出选中的牌 并发送给服务器 /// </summary> private void DealSelectCard() { List <CardDto> selectCardList = GetSelectCard(); DealDto dto = new DealDto(selectCardList, Model.gameModel.UserDto.id); //如果出牌不合法 if (dto.isRegular == false) { promptMsg.ChangeText("卡牌不对", Color.red); Dispatch(AreaCode.UI, UIEvent.PROMPTA_ANIM, promptMsg); return; } else //可以出牌 { socketMsg.Change(OpCode.FIGHT, FightCode.DEAL_CREQ, dto); Dispatch(AreaCode.NET, 0, socketMsg); } }
/// <summary> /// 登录响应 /// </summary> /// <param name="value"></param> private void LoginResponse(int result) { switch (result) { case 0: LoadSceneMsg msg = new LoadSceneMsg(1, delegate() { //向服务器获取信息 SocketMsg socketMsg = new SocketMsg(OpCode.USER, UserCode.GET_INFO_CREQ, null); Dispatch(AreaCode.NET, 0, socketMsg); }); Dispatch(AreaCode.SCENE, SceneEvent.LOAD_SCENE, msg); break; case -1: promptMsg.ChangeText("账号错误", Color.red); Dispatch(AreaCode.UI, UIEvent.PROMPTA_ANIM, promptMsg); break; case -2: promptMsg.ChangeText("账号密码不匹配", Color.red); Dispatch(AreaCode.UI, UIEvent.PROMPTA_ANIM, promptMsg); break; case -3: promptMsg.ChangeText("账号已登录", Color.red); Dispatch(AreaCode.UI, UIEvent.PROMPTA_ANIM, promptMsg); break; } //if (result == "登录成功") //{ // promptMsg.ChangeText(result.ToString(), Color.green); // Dispatch(AreaCode.UI,UIEvent.PROMPTA_ANIM,promptMsg); // return; //} //promptMsg.ChangeText(result.ToString(), Color.red); //Dispatch(AreaCode.UI, UIEvent.PROMPTA_ANIM, promptMsg); }