网演高层钦州
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

178 lines
5.3 KiB

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using AX.NetworkSystem;
public enum GoTo
{
Login = 1,
Menu = 2,
RolesSelection,
Lobby,
DongYouLiQing,
}
public enum NowScene
{
RolesSelection = 2,
Lobby,
// RoomWaiting,
DongYouLiQing
}
public class BackButton : MonoBehaviour
{
public NowScene MyScene;
private BackController btncollor;
public MessagePanel mess;
void Start()
{
btncollor = GetComponent<BackController>();
btncollor.ToPrevAction = ToPrev;
btncollor.ToMenuAction = ToMenu;
btncollor.ToLoginAction = ToLogin;
}
/// <summary>
/// 返回上一级
/// </summary>
private void ToPrev()
{
string SceneName = MyScene.ToString();
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)((int)MyScene),
};
string BackScene = "";
switch (data.TargetScene)
{
case GoTo.Login:
BackScene = "登录";
break;
case GoTo.Menu:
BackScene = "主菜单";
break;
case GoTo.RolesSelection:
BackScene = "角色选择";
break;
case GoTo.Lobby:
BackScene = "大厅";
break;
case GoTo.DongYouLiQing:
BackScene = "房间等待";
break;
}
mess.MessageBoxShow("返回到" + BackScene);
mess.SureAction = () =>
{
switch (MyScene)
{
case NowScene.DongYouLiQing:
//从房间等待返回到大厅
NetworkManager.Default.SendAsync("ROOM_LEAVE_SYNC", data);
break;
case NowScene.Lobby:
//从大厅返回到角色选择
NetworkManager.Default.SendAsync("LOBBY_LEAVE_SYNC", data);
break;
case NowScene.RolesSelection:
//从角色选择返回主菜单
CurrentUserInfo.role = Role.None;
SceneManager.LoadScene(data.TargetScene.ToString());
break;
}
};
}
/// <summary>
/// 返回到主菜单
/// </summary>
private void ToMenu()
{
mess.MessageBoxShow("跳转到主菜单");
mess.SureAction = () =>
{
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.Menu,
};
switch (MyScene)
{
case NowScene.DongYouLiQing:
//从房间等待返回到主菜单
NetworkManager.Default.SendAsync("ROOM_LEAVE_SYNC", data);
break;
case NowScene.Lobby:
//从大厅返回到主菜单
NetworkManager.Default.SendAsync("LOBBY_LEAVE_SYNC", data);
break;
case NowScene.RolesSelection:
//从角色选择返回到主菜单
CurrentUserInfo.role = Role.None;
SceneManager.LoadScene(data.TargetScene.ToString());
break;
}
};
}
/// <summary>
/// 返回到登陆
/// </summary>
private void ToLogin()
{
mess.MessageBoxShow("跳转到重新登入");
mess.SureAction = () =>
{
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.Login,
};
switch (MyScene)
{
case NowScene.DongYouLiQing:
//从房间等待返回到登陆
NetworkManager.Default.SendAsync("ROOM_LEAVE_SYNC", data);
break;
case NowScene.Lobby:
//从大厅返回到登陆
NetworkManager.Default.SendAsync("LOBBY_LEAVE_SYNC", data);
break;
case NowScene.RolesSelection:
//从角色选择返回到登陆
NetworkManager.Default.SendAsync("LOGOUT_SYNC", data.UserData);
break;
}
};
}
}