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.
79 lines
2.3 KiB
79 lines
2.3 KiB
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
using UnityEngine.SceneManagement; |
|
|
|
public class BackController : MonoBehaviour |
|
{ |
|
public GameObject BackBtns; |
|
public Button ToPrevBtn; |
|
public Button ToMenuBtn; |
|
public Button ToLoginBtn; |
|
public Action ToPrevAction; |
|
public Action ToMenuAction; |
|
public Action ToLoginAction; |
|
public Toggle MyToggle; |
|
void Awake() |
|
{ |
|
MyToggle = GetComponentInChildren<Toggle>(); |
|
MyToggle.onValueChanged.AddListener(BackToggleClick); |
|
ToPrevBtn.onClick.AddListener(ToPrevBtnClick); |
|
ToMenuBtn.onClick.AddListener(ToMenuBtnClick); |
|
ToLoginBtn.onClick.AddListener(ToLoginBtnClick); |
|
} |
|
|
|
private void ToLoginBtnClick() |
|
{ |
|
if (ToLoginAction != null) |
|
ToLoginAction.Invoke(); |
|
BackBtns.gameObject.SetActive(false); |
|
MyToggle.isOn = false; |
|
} |
|
|
|
private void ToMenuBtnClick() |
|
{ |
|
if (ToMenuAction != null) |
|
ToMenuAction.Invoke(); |
|
BackBtns.gameObject.SetActive(false); |
|
MyToggle.isOn = false; |
|
} |
|
|
|
private void ToPrevBtnClick() |
|
{ |
|
if (ToPrevAction != null) |
|
ToPrevAction.Invoke(); |
|
BackBtns.gameObject.SetActive(false); |
|
MyToggle.isOn = false; |
|
} |
|
private void BackToggleClick(bool ok) |
|
{ |
|
if (CurrentUserInfo.room!=null&&CurrentUserInfo.room.IsDrillStart) |
|
{ |
|
bool haszhihui = false; |
|
for (int i = 0; i < CurrentUserInfo.room.UserList.Count; i++) |
|
{ |
|
if (CurrentUserInfo.room.UserList[i].Role == Role.总队指挥中心 || |
|
CurrentUserInfo.room.UserList[i].Role == Role.支队指挥中心) |
|
{ |
|
haszhihui = true; |
|
break; |
|
} |
|
} |
|
if (haszhihui) |
|
{ |
|
if (CurrentUserInfo.role!= Role.总队指挥中心&& |
|
CurrentUserInfo.role != Role.支队指挥中心) |
|
{ |
|
LoadPromptWin.Instance.LoadTextPromptWindow("房间已锁定,不能进行返回操作!", 1f); |
|
BackBtns.gameObject.SetActive(false); |
|
return; |
|
} |
|
|
|
} |
|
} |
|
|
|
BackBtns.gameObject.SetActive(ok); |
|
} |
|
}
|
|
|