diff --git a/Assets/Temp/Scripts/Taskpanel.cs b/Assets/Temp/Scripts/Taskpanel.cs index 1aec2e3a..122f1a95 100644 --- a/Assets/Temp/Scripts/Taskpanel.cs +++ b/Assets/Temp/Scripts/Taskpanel.cs @@ -144,7 +144,6 @@ public class Taskpanel : MonoBehaviour public void OnLeaveRoom() { - //_ = AdamSync.SyncCreateRoom.SendMessageAsync($"send2room offline,{GlobalFlag.currentUser.user_id}"); string _msg = "leaveroom "; _ = AdamSync.SyncCreateRoom.SendMessageAsync(_msg); //SceneManager.LoadScene("SampleScene"); diff --git a/Assets/Zion/Scripts/Adam/GameManager.cs b/Assets/Zion/Scripts/Adam/GameManager.cs index 657409bf..d2491c72 100644 --- a/Assets/Zion/Scripts/Adam/GameManager.cs +++ b/Assets/Zion/Scripts/Adam/GameManager.cs @@ -202,7 +202,7 @@ public class GameManager : MonoSingleton } break; case "offline": - + RemovePlayer(ulong.Parse(data[1])); break; default: break; diff --git a/Assets/Zion/Scripts/Adam/UIBootstrap.cs b/Assets/Zion/Scripts/Adam/UIBootstrap.cs index bba936a5..1bfb9ad5 100644 --- a/Assets/Zion/Scripts/Adam/UIBootstrap.cs +++ b/Assets/Zion/Scripts/Adam/UIBootstrap.cs @@ -24,13 +24,11 @@ public class UIBootstrap : MonoSingleton t = Jsonanalyze.FromJson(editinformation.data[i].VirtualPath); traininginformations.Add(t); } - AdamSync.SyncCreateRoom.getRoomsRequset += OnGetRooms; - AdamSync.SyncCreateRoom.getroomusersRequset += OnGetRoomsUsers; - AdamSync.SyncCreateRoom.send2roomRequset += OnGetRoomsInfo; AdamSync.SyncCreateRoom.leaveRoomRequset += OnOtherPlayerOffline; + AdamSync.SyncCreateRoom.send2worldRequset += OnGetWorldInfo; } - + public async void GetSceneData(string roomId) { @@ -81,73 +79,30 @@ public class UIBootstrap : MonoSingleton return "0"; } - - - public void OnGetRooms(string msg) + + public void OnGetWorldInfo(string msg) { - Debug.Log("OnGetRooms====" + msg); - } - public void OnGetRoomsUsers(string msg) - { - Debug.Log("OnGetRooms====" + msg); - } - public void OnGetRoomsInfo(string msg) - { - Debug.Log("OnGetRooms====" + msg); + Debug.Log("OnGetWorldInfo====" + msg); + GameManager.Instance.RemovePlayer(ulong.Parse(msg)); } public void OnOtherPlayerOffline(string msg) { string[] data = msg.Split(','); Debug.Log(data[1]); - if (data[0] == "offline") - { - GameManager.Instance.RemovePlayer(ulong.Parse(data[1])); - } - + _ = AdamSync.SyncCreateRoom.SendMessageAsync($"send2world {GlobalFlag.currentUser.user_id}"); } - // Update is called once per frame - void Update() - { - if (Input.GetKeyDown("o")) - { - string info = "getrooms "; - Debug.Log(info); - _ = AdamSync.SyncCreateRoom.SendMessageAsync(info); - } - if (Input.GetKeyDown("g")) - { - string info = "getroomusers "; - Debug.Log(info); - _ = AdamSync.SyncCreateRoom.SendMessageAsync(info); - } - if (Input.GetKeyDown("i")) - { - string info = "send2room " + "进入房间"; - Debug.Log(info); - _ = AdamSync.SyncCreateRoom.SendMessageAsync(info); - } - if (Input.GetKeyDown("l")) - { - string msg = "leaveroom "; - _ = AdamSync.SyncCreateRoom.SendMessageAsync(msg); - } - } + + private void OnDisable() { Debug.Log("OnDisable"); - AdamSync.SyncCreateRoom.getRoomsRequset -= OnGetRooms; - AdamSync.SyncCreateRoom.getroomusersRequset -= OnGetRoomsUsers; - AdamSync.SyncCreateRoom.send2roomRequset -= OnGetRoomsInfo; AdamSync.SyncCreateRoom.leaveRoomRequset -= OnOtherPlayerOffline; } private void OnDestory() { Debug.Log("OnDestory"); - AdamSync.SyncCreateRoom.getRoomsRequset -= OnGetRooms; - AdamSync.SyncCreateRoom.getroomusersRequset -= OnGetRoomsUsers; - AdamSync.SyncCreateRoom.send2roomRequset -= OnGetRoomsInfo; AdamSync.SyncCreateRoom.leaveRoomRequset -= OnOtherPlayerOffline; } } diff --git a/Assets/Zion/Scripts/Adam/Utility/Sync/SyncCreateRoom.cs b/Assets/Zion/Scripts/Adam/Utility/Sync/SyncCreateRoom.cs index 53f2a7a0..6ed91035 100644 --- a/Assets/Zion/Scripts/Adam/Utility/Sync/SyncCreateRoom.cs +++ b/Assets/Zion/Scripts/Adam/Utility/Sync/SyncCreateRoom.cs @@ -28,6 +28,7 @@ namespace AdamSync public static Action getroomusersRequset; public static Action send2roomRequset; public static Action send2userRequset; + public static Action send2worldRequset; public static async Task StartLinkTCPServer(string serverIp, int serverPort) @@ -118,6 +119,9 @@ namespace AdamSync case "send2user": send2userRequset?.Invoke(commands[1]); break; + case "send2world": + send2worldRequset?.Invoke(commands[1]); + break; } } }