using AX.NetworkSystem; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class ExitDrillButton : BaseButton { public MessagePanel mess; private void Start() { mess = transform.parent.parent.parent.Find("MessagePanel").GetComponent(); } // Start is called before the first frame update public override void RespondFun() { mess.MessageBoxShow("返回到角色选择"); mess.SureAction = ExitToSelect; } private void ExitToSelect() { EntitiesManager.Instance.Reset();//跳转场景时要清空实体管理器中的对象 //准备状态下的用户离开时需要初始化准备状态,避免再进入房间直接就是准备状态 EnterRoomPair data = new EnterRoomPair { RoomId = CurrentUserInfo.room == null ? -1 : CurrentUserInfo.room.Id, UserData = new UserData() { UserInfo = CurrentUserInfo.mySelf, Role = CurrentUserInfo.role, Org = CurrentUserInfo.organization, IsReady = false, }, TargetScene = GoTo.RolesSelection, }; if (CurrentUserInfo.mySelf.Id==CurrentUserInfo.room.Owner.UserInfo.Id) { GameSettings.othersSettings.isStartDrill = false; } UserData user = CurrentUserInfo.room.FindUserById(CurrentUserInfo.mySelf.Id); user.IsReady = false; //重置房间 CurrentUserInfo.room = null; EntitiesManager.Instance.Reset(); NetworkManager.Default.SendAsync("ROOM_LEAVE_SYNC", data); SceneManager.LoadScene(GoTo.RolesSelection.ToString()); } }