This commit is contained in:
yulong 2023-11-22 19:14:19 +08:00
commit 7969fa9585
3 changed files with 10 additions and 9 deletions

View File

@ -41,7 +41,7 @@ public class GameManager : MonoSingleton<GameManager>
SyncCreateRoom.getroomusersRequset += OnGetRoomUsers; SyncCreateRoom.getroomusersRequset += OnGetRoomUsers;
SyncCreateRoom.send2roomRequset += OnOtherPlayerOnline; SyncCreateRoom.send2roomRequset += OnRoomInfo;
SyncPlayerTransform spt = Instantiate(playerTransformPrefab); SyncPlayerTransform spt = Instantiate(playerTransformPrefab);
spt.gameObject.SetActive(true); spt.gameObject.SetActive(true);
spt.gameObject.transform.position = spawnPos.position; spt.gameObject.transform.position = spawnPos.position;
@ -138,11 +138,12 @@ public class GameManager : MonoSingleton<GameManager>
{ {
Destroy(players[i].gameObject); Destroy(players[i].gameObject);
players.RemoveAt(i); players.RemoveAt(i);
userIds.Remove(playerID);
} }
} }
} }
public void OnOtherPlayerOnline(string msg) public void OnRoomInfo(string msg)
{ {
StopCoroutine(WaitSpawn(msg)); StopCoroutine(WaitSpawn(msg));
StartCoroutine(WaitSpawn(msg)); StartCoroutine(WaitSpawn(msg));
@ -202,7 +203,7 @@ public class GameManager : MonoSingleton<GameManager>
} }
break; break;
case "offline": case "offline":
RemovePlayer(ulong.Parse(data[1]));
break; break;
default: default:
break; break;
@ -311,7 +312,7 @@ public class GameManager : MonoSingleton<GameManager>
{ {
Debug.Log("OnDisable"); Debug.Log("OnDisable");
SyncCreateRoom.getroomusersRequset -= OnGetRoomUsers; SyncCreateRoom.getroomusersRequset -= OnGetRoomUsers;
SyncCreateRoom.send2roomRequset -= OnOtherPlayerOnline; SyncCreateRoom.send2roomRequset -= OnRoomInfo;
} }
} }

View File

@ -25,7 +25,7 @@ public class UIBootstrap : MonoSingleton<UIBootstrap>
t = Jsonanalyze.FromJson<Traininginformation>(editinformation.data[i].VirtualPath); t = Jsonanalyze.FromJson<Traininginformation>(editinformation.data[i].VirtualPath);
traininginformations.Add(t); traininginformations.Add(t);
} }
AdamSync.SyncCreateRoom.leaveRoomRequset += OnOtherPlayerOffline; AdamSync.SyncCreateRoom.leaveRoomRequset += OnLeaveRoomInfo;
AdamSync.SyncCreateRoom.send2worldRequset += OnGetWorldInfo; AdamSync.SyncCreateRoom.send2worldRequset += OnGetWorldInfo;
} }
@ -86,7 +86,7 @@ public class UIBootstrap : MonoSingleton<UIBootstrap>
Debug.Log("OnGetWorldInfo====" + msg); Debug.Log("OnGetWorldInfo====" + msg);
GameManager.Instance.RemovePlayer(ulong.Parse(msg)); GameManager.Instance.RemovePlayer(ulong.Parse(msg));
} }
public void OnOtherPlayerOffline(string msg) public void OnLeaveRoomInfo(string msg)
{ {
string[] data = msg.Split(','); string[] data = msg.Split(',');
Debug.Log(data[1]); Debug.Log(data[1]);
@ -100,11 +100,11 @@ public class UIBootstrap : MonoSingleton<UIBootstrap>
private void OnDisable() private void OnDisable()
{ {
Debug.Log("OnDisable"); Debug.Log("OnDisable");
AdamSync.SyncCreateRoom.leaveRoomRequset -= OnOtherPlayerOffline; AdamSync.SyncCreateRoom.leaveRoomRequset -= OnLeaveRoomInfo;
} }
private void OnDestory() private void OnDestory()
{ {
Debug.Log("OnDestory"); Debug.Log("OnDestory");
AdamSync.SyncCreateRoom.leaveRoomRequset -= OnOtherPlayerOffline; AdamSync.SyncCreateRoom.leaveRoomRequset -= OnLeaveRoomInfo;
} }
} }

View File

@ -13,7 +13,7 @@ namespace AdamSync
SyncCreateRoom.playerInfoRequset += ReceivePlayInfo; SyncCreateRoom.playerInfoRequset += ReceivePlayInfo;
if (isPlayer) if (isPlayer)
{ {
StartCoroutine(SendMsg()); //StartCoroutine(SendMsg());
} }
else else
{ {