/// <summary> 服务端返回区服列表 </summary> /// <param name="role"></param> /// <param name="accountId"></param> private void LogOnGameServerResponse(Role role, int accountId) { RoleLogOnGameServerResponseProto proto = new RoleLogOnGameServerResponseProto(); List <RoleEntity> list = RoleCacheModel.Instance.GetList(condition: string.Format("[AccountId]={0}", accountId)); if (list != null && list.Count > 0) { proto.RoleCount = list.Count; proto.RoleList = new List <RoleLogOnGameServerResponseProto.RoleItem>(); for (int i = 0; i < list.Count; i++) { proto.RoleList.Add(new RoleLogOnGameServerResponseProto.RoleItem() { RoleId = list[i].Id.Value, RoleNickName = list[i].NickName, RoleJob = (byte)list[i].JobId, RoleLevel = list[i].Level }); } } else { proto.RoleCount = 0; } role.ClientSocket.SendMsg(proto.ToArray()); }
private void OnLogOnGameServerResponse(byte[] p) { RoleLogOnGameServerResponseProto proto = RoleLogOnGameServerResponseProto.GetProto(p); m_IsHaveRole = proto.RoleCount > 0; if (proto.RoleCount > 0) { DragTarget.rotation = new Quaternion(); m_IsSelectRoleView = false; SetPillarsActive(false); //有角色 进入 进入游戏界面 Debuger.Log("有角色 进入 进入游戏界面"); //m_SelectRoleView.SelectRoleContainer.gameObject.SetActive(true); m_SelectRoleView.CreateRoleContainer.gameObject.SetActive(false); int count = proto.RoleCount; m_SelectRoleItemList = new ToggleList <UISelectRoleItem>(); GameObject obj = ResourcesManager.Instance.LoadItem("SelectRoleHeadItem"); for (int i = 0; i < m_CreateCloneRoleGoList.Count; i++) { m_CreateCloneRoleGoList[i].SetActive(false); } for (int i = 0; i < count; i++) { UISelectRoleItem item = Instantiate(obj, m_SelectRoleView.SelectRoleContainer).GetComponent <UISelectRoleItem>(); JobEntity entity = JobDBModel.Instance.Get(proto.RoleList[i].RoleJob); UISelectRoleItemInfo itemInfo = new UISelectRoleItemInfo(); itemInfo.Index = i; itemInfo.AtalsName = "RoleIcon"; itemInfo.SpriteName = entity.HeadPic; itemInfo.RoleId = proto.RoleList[i].RoleId; itemInfo.RoleName = proto.RoleList[i].RoleNickName; itemInfo.Level = proto.RoleList[i].RoleLevel; itemInfo.JobName = entity.Name; //itemInfo.SpriteName = JobDBModel.Instance.get item.SetData(itemInfo, OnSelectCallBack); m_SelectRoleItemList.Add(item); item.transform.localPosition = new Vector3(0, 123 - 113 * i, 0); GameObject roleObj = AssetBundleManager.Instance.Load(string.Format("Download/Model/Player/{0}/{1}.assetbundle", entity.FloaderName, entity.PrefabName), entity.PrefabName); GameObject roleGameObject = Instantiate(roleObj, SelectRoleContainer); for (int j = 0; j < entity.WeaponPath.Length; j++) { GameObject weaponObj = AssetBundleManager.Instance.Load(string.Format("Download/Model/{0}/{1}.assetbundle", entity.WeaponFloader, entity.WeaponPath[j]), entity.WeaponPath[j]); Instantiate(weaponObj, roleGameObject.transform.GetChild(0).Find(entity.WeaponParent[j])); } roleGameObject.transform.localPosition = Vector3.zero; roleGameObject.transform.localRotation = Quaternion.Euler(Vector3.zero); roleGameObject.transform.localScale = Vector3.one; m_SelectRoleItemList.AddDepend(roleGameObject); roleGameObject.SetActive(i == 0); } OnSelectCallBack(0); } else { ShowCreateRoleView(); } }
public static RoleLogOnGameServerResponseProto GetProto(byte[] buffer) { RoleLogOnGameServerResponseProto proto = new RoleLogOnGameServerResponseProto(); using (MMO_MemoryStream ms = new MMO_MemoryStream(buffer)) { proto.RoleCount = ms.ReadInt(); proto.RoleList = new List <RoleItem>(); for (int i = 0; i < proto.RoleCount; i++) { RoleItem _Role = new RoleItem(); _Role.RoleId = ms.ReadInt(); _Role.RoleNickName = ms.ReadUTF8String(); _Role.RoleJob = (byte)ms.ReadByte(); _Role.RoleLevel = ms.ReadInt(); proto.RoleList.Add(_Role); } } return(proto); }