Compare commits

...

2 Commits

6 changed files with 57 additions and 23 deletions

View File

@ -146,7 +146,6 @@ public class Taskpanel : MonoBehaviour
{
string _msg = "leaveroom ";
_ = AdamSync.SyncCreateRoom.SendMessageAsync(_msg);
}
}

View File

@ -245,12 +245,12 @@ public class View_Panel2 : XUIPanel
}
OnRegisterFunction();
}
public void OnRegisterFunction()
{
AdamSync.SyncCreateRoom.joinRoomRequset += OnJoinRoom;
}
public void OnJoinRoom(string msg)
{
Debug.Log("OnJoinRoom ViewPanel===" + msg);
@ -476,6 +476,9 @@ public class View_Panel2 : XUIPanel
//SceneManager.LoadScene("AdamTraining_pilot_terminal_panl 1");
//加入房间
Debug.Log("进入训练");
string RoomName = "joinroom " + currentRoomName;
_ = AdamSync.SyncCreateRoom.SendMessageAsync(RoomName);
});

View File

@ -222,7 +222,7 @@ public class GameManager : MonoSingleton<GameManager>
}
}
//}
@ -241,7 +241,7 @@ public class GameManager : MonoSingleton<GameManager>
{
if (deviceData.data[i].id == deviceInfo[7])
{
SpawnDevice(devicePrefab, deviceData.data[i],deviceInfo);
SpawnDevice(devicePrefab, deviceData.data[i], deviceInfo);
}
}
}
@ -269,10 +269,10 @@ public class GameManager : MonoSingleton<GameManager>
}
public void SpawnDevice(GameObject obj, AdamThinkDevicesData.DataItem data,string[] tran = null )
public void SpawnDevice(GameObject obj, AdamThinkDevicesData.DataItem data, string[] tran = null)
{
GameObject device = Instantiate(obj);
if(tran != null)
if (tran != null)
{
device.transform.position = new Vector3(float.Parse(tran[1]), float.Parse(tran[2]), float.Parse(tran[3]));
device.transform.eulerAngles = new Vector3(float.Parse(tran[4]), float.Parse(tran[5]), float.Parse(tran[6]));
@ -283,24 +283,26 @@ public class GameManager : MonoSingleton<GameManager>
private void OnGetRoomUsers(string obj)
{
if (string.IsNullOrWhiteSpace(obj)) return;
string[] data = obj.Split(';');
//Debug.Log("datas=" + data[0]);
for (int i = 0; i < data.Length; i++)
if (!string.IsNullOrWhiteSpace(obj))
{
int index = i;
string[] userInfo = data[index].Split(',');
if (!userIds.Contains(ulong.Parse(userInfo[0])))
string[] data = obj.Split(';');
for (int i = 0; i < data.Length; i++)
{
SyncPlayerTransform spt = Instantiate(playerTransformPrefab);
spt.gameObject.SetActive(true);
spt.SetPlayerInfo(ulong.Parse(userInfo[0]), userInfo[1], ulong.Parse(userInfo[2]), false);
spt.transform.position = new Vector3(spawnPos.position.x + index * 0.5f, spawnPos.position.y, spawnPos.position.z + index * 0.5f);
spt.transform.eulerAngles = spawnPos.eulerAngles;
AddPlayers(spt);
userIds.Add(ulong.Parse(userInfo[0]));
int index = i;
string[] userInfo = data[index].Split(',');
if (!userIds.Contains(ulong.Parse(userInfo[0])))
{
SyncPlayerTransform spt = Instantiate(playerTransformPrefab);
spt.gameObject.SetActive(true);
spt.SetPlayerInfo(ulong.Parse(userInfo[0]), userInfo[1], ulong.Parse(userInfo[2]), false);
spt.transform.position = new Vector3(spawnPos.position.x + index * 0.5f, spawnPos.position.y, spawnPos.position.z + index * 0.5f);
spt.transform.eulerAngles = spawnPos.eulerAngles;
AddPlayers(spt);
userIds.Add(ulong.Parse(userInfo[0]));
}
}
}
Debug.Log($"<color=yellow>OnGetRoomUsers={obj}</color>");
SpawnDevice();
string msg = $"send2room online,{ulong.Parse(GlobalFlag.currentUser.user_id)},{GlobalFlag.currentUser.login_name},{ulong.Parse(GlobalFlag.roomID)}";
_ = SyncCreateRoom.SendMessageAsync(msg);
@ -340,8 +342,17 @@ public class GameManager : MonoSingleton<GameManager>
private void OnDisable()
{
Debug.Log("OnDisable");
Reset();
}
private void Reset()
{
SyncCreateRoom.getroomusersRequset -= OnGetRoomUsers;
SyncCreateRoom.send2roomRequset -= OnRoomInfo;
string _msg = "leaveroom ";
_ = AdamSync.SyncCreateRoom.SendMessageAsync(_msg);
}
}

View File

@ -168,4 +168,10 @@ public class ToolsBootstrap : MonoSingleton<ToolsBootstrap>
{
wrjManager.wrjMenuSetPanel.gameObject.SetActive(false);
}
private void OnApplicationQuit()
{
string _msg = "leaveroom ";
_ = AdamSync.SyncCreateRoom.SendMessageAsync(_msg);
}
}

View File

@ -80,13 +80,26 @@ public class UIBootstrap : MonoSingleton<UIBootstrap>
}
return "0";
}
///// <summary>
///// 是否分配角色
///// </summary>
//public bool IsAllocate()
//{
// string currentName =
// for(int i = 0;i < subjectInfo.Count; i++)
// {
// }
//}
public void OnGetWorldInfo(string msg)
{
Debug.Log("OnGetWorldInfo====" + msg);
GameManager.Instance.RemovePlayer(ulong.Parse(msg));
}
public void OnLeaveRoomInfo(string msg)
{
string[] data = msg.Split(',');
@ -102,6 +115,8 @@ public class UIBootstrap : MonoSingleton<UIBootstrap>
{
Debug.Log("OnDisable");
AdamSync.SyncCreateRoom.leaveRoomRequset -= OnLeaveRoomInfo;
string _msg = "leaveroom ";
_ = AdamSync.SyncCreateRoom.SendMessageAsync(_msg);
}
private void OnDestory()
{

View File

@ -73,7 +73,7 @@ namespace AdamSync
if (commands.Length > 0)
{
//Debug.Log("commands[0]====" + commands[0]);
Debug.Log($"<color=green>commands[0]===={commands[0]}</color>");
switch (commands[0])
{
case "regist":