/// <summary> /// 点击开始游戏的委托执行,做3件事。1、判断当前是否有角色 2、跳转场景进入主城 3、和服务器交互 /// </summary> private void OnStartGameClick() { if (mIsCreate) { //1、新建角色的情况:先新建,再登录 Account_AddRoleReqProto proto = new Account_AddRoleReqProto(); proto.ClassId = (byte)mCurrentSelectedClassId; proto.RoleNickName = mUISelectRoleView.NickName.text; proto.GameServerId = GlobalCache.Instance.Account_LastLoginServerId; //Ich新增区服判断 if (proto.RoleNickName.Equals("") || proto.RoleNickName == null) { UIDialogController.Instance.Show("请输入昵称!"); return; } SocketManager.Instance.SendMessageToLocalServer(proto.ToArray()); } else { //2、已有角色的情况:直接登录 if (mCurrentSelectedRoleId == -1) { UIDialogController.Instance.Show("请选择一个角色"); return; } else { EnterGameReq(); } } }
private void OnAddRole(byte[] buffer) { Account_AddRoleReqProto proto = Account_AddRoleReqProto.GetProto(buffer); int classId = proto.ClassId; string nickName = proto.RoleNickName; int gameServerId = proto.GameServerId; AddRoleServerResp(classId, nickName, gameServerId); }
public static Account_AddRoleReqProto GetProto(byte[] buffer) { Account_AddRoleReqProto proto = new Account_AddRoleReqProto(); using (MemoryStreamUtil ms = new MemoryStreamUtil(buffer)) { proto.ClassId = (byte)ms.ReadByte(); proto.RoleNickName = ms.ReadUTF8String(); proto.GameServerId = ms.ReadInt(); } return(proto); }