public void CollectAllRpcFuncs() { Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies(); List <MethodInfo> methods = new List <MethodInfo>(); foreach (var assembly in assemblies) { var methodsinass = assembly.GetTypes().SelectMany(x => x.GetMethods()) .Where(y => y.GetCustomAttributes() .OfType <NGRPCMethod>().Any()).ToArray(); methods.AddRange(methodsinass); foreach (var method in methodsinass) { if (name2Method.ContainsKey(method.Name)) { NGLogger.LogError("Error happens when collecting RFC methods."); } else { name2Method.Add(method.Name, method); } } } }
public void ResponseProcessor(ResponseOperationMessage rmsg) { switch (rmsg.MsgType) { case MessageType.CreateRoom: var crParams = rmsg.CrrParams; switch (crParams.ReturnValue) { case (uint)ResponseMessageInfo.CreateRoomSuccess: LocalPlayer = new NGPlayer(true, crParams.PeerId); NGEvent.OnCreatedRoom(); break; case (uint)ResponseMessageInfo.CreateRoomAlreadyExist: NGEvent.OnCreateRoomFailed(crParams.Message); break; } break; case MessageType.JoinRoom: var jrrParams = rmsg.JrrParams; switch (jrrParams.ReturnValue) { case (uint)ResponseMessageInfo.JoinRoomSuccess: NGLogger.LogDebug("JoinRoomSuccess responsee"); LocalPlayer = new NGPlayer(true, jrrParams.PeerId); NGEvent.OnJoinedRoom(); break; case (uint)ResponseMessageInfo.JoinRoomAlreadyInRoom: NGEvent.OnJoinRoomFailed(); break; case (uint)ResponseMessageInfo.JoinRoomFull: NGEvent.OnJoinRoomFailed(); break; default: NGLogger.LogError("The return value from JoinRoom or JoinOrCreateRoom" + jrrParams.ReturnValue + " cannot be identified."); break; } break; case MessageType.LeaveRoom: var lrParams = rmsg.LrrParams; switch (lrParams.ReturnValue) { case (uint)ResponseMessageInfo.LeaveRoomSuccess: NGEvent.OnLeftRoom(); break; } break; } }
void DrawLobbyMenu() { float rectwidth = 500f; float rectheight = 900f; Rect rect = new Rect(Screen.width / 2 - rectwidth / 2, Screen.height / 2 - 100f, rectwidth, rectheight); // Show a half-transparent box around the upcoming UI GUI.color = new Color(0f, 0f, 0f, 1f); GUI.Box(GUIUtils.ProcessRect(rect, 8f), ""); GUI.color = Color.white; float buttonwidth = rectwidth; float buttonheight = 80; GUILayoutOption[] buttonoptions = { GUILayout.Width(buttonwidth), GUILayout.Height(buttonheight) }; float textwidth = 270; float textheight = 60; GUILayoutOption[] textoptions = { GUILayout.Width(textwidth), GUILayout.Height(textheight) }; GUILayout.BeginArea(rect); { GUILayout.Space(20); GUILayout.BeginHorizontal(); GUILayout.Label("Room Name:"); mRoomName = GUILayout.TextField(mRoomName, textoptions); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Room Capacity:"); string roomcapacity = "10"; roomcapacity = GUILayout.TextField(roomcapacity, textoptions); GUILayout.EndHorizontal(); GUILayout.Space(30); if (!uint.TryParse(roomcapacity, out mRoomCapacity)) { NGLogger.LogError("The Room Capacity cannot be parsed to uint"); } if (GUILayout.Button("Join Or Create Room", buttonoptions)) { NGInterface.JoinOrCreateRoom(mRoomName, mRoomCapacity); } GUILayout.Space(5); if (GUILayout.Button("Create Room", buttonoptions)) { NGInterface.CreateRoom(mRoomName, mRoomCapacity); } GUILayout.Space(5); // GUILayout.BeginHorizontal(); // GUILayout.Space((rectwidth - buttonwidth) / 2); if (GUILayout.Button("Join Room", buttonoptions)) { NGInterface.JoinRoom(mRoomName); } //GUILayout.EndHorizontal(); GUI.backgroundColor = Color.white; if (!string.IsNullOrEmpty(mMessage)) { GUILayout.Label(mMessage); } } GUILayout.EndArea(); }