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.
226 lines
7.7 KiB
226 lines
7.7 KiB
using AX.MessageSystem; |
|
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.SceneManagement; |
|
using UnityEngine.UI; |
|
|
|
public class ToolsPanelManager : MonoBehaviour |
|
{ |
|
private Transform MovePanel; |
|
private UIMoveManager moveManager; |
|
private Toggle MyToggle; |
|
private WeatherSettingManager weatherSettingManager; |
|
private Toggle weatherToggle; |
|
private Button TeamNameBtn; |
|
private Toggle ShowNameToggle; |
|
private Button ClearAllBtn; |
|
private Button backScene; |
|
private float timmer; |
|
private void Start() |
|
{ |
|
MovePanel = transform.Find("MovePanel"); |
|
moveManager = MovePanel.GetComponent<UIMoveManager>(); |
|
MovePanel.GetComponent<ToolsMovePanelManager>().Init(); |
|
MyToggle = transform.parent.Find("ToolsToggle").GetComponent<Toggle>(); |
|
MyToggle.onValueChanged.AddListener(MyToggleValueChanged); |
|
moveManager.SetMoving(); |
|
weatherSettingManager = GameObject.Find("Canvas").transform.Find("WeatherSettingPanel").GetComponent<WeatherSettingManager>(); |
|
weatherToggle = MovePanel.Find("SettingToggle").GetComponent<Toggle>(); |
|
weatherToggle.onValueChanged.AddListener(weatherToggleValueChanged); |
|
weatherSettingManager.Init(weatherToggle); |
|
TeamNameBtn = MovePanel.Find("TeamNameBtn").GetComponent<Button>(); |
|
TeamNameBtn.onClick.AddListener(TeamName); |
|
ShowNameToggle = MovePanel.Find("ShowNameToggle").GetComponent<Toggle>(); |
|
ShowNameToggle.onValueChanged.AddListener(ShowName); |
|
ClearAllBtn = MovePanel.Find("ClearAllBtn").GetComponent<Button>(); |
|
ClearAllBtn.onClick.AddListener(ClearAll); |
|
backScene = MovePanel.Find("ReturnBtn").GetComponent<Button>(); |
|
backScene.onClick.AddListener(BackTo); |
|
MessageDispatcher.AddListener("ReplayFrame", ReplayFrameWeatherSetting); |
|
MessageDispatcher.AddListener("ReplayEvent", ReplayEventWeatherSetting); |
|
MessageDispatcher.AddListener("FloorsOn", FloorsOnChanged); |
|
} |
|
|
|
private void FloorsOnChanged(IMessage obj) |
|
{ |
|
if (MyToggle.isOn) |
|
MyToggle.isOn = false; |
|
} |
|
|
|
private void BackTo() |
|
{ |
|
ResourceLoadWindow.Instance.LoadTipWindow("确定返回上级菜单吗?", BackToMenu, null); |
|
} |
|
|
|
private void BackToMenu() |
|
{ |
|
EntitiesManager.Instance.Reset(); |
|
GlobalVariable.FloorsOn = true; |
|
GlobalVariable.ToolsOn = false; |
|
ReplaySetting.PlayStatus = PlayStatus.normal; |
|
SceneManager.LoadScene("StartScene"); |
|
} |
|
|
|
private void ClearAll() |
|
{ |
|
if (ReplaySetting.PlayStatus == PlayStatus.isReplay) |
|
{ |
|
ResourceLoadWindow.Instance.LoadTextHintWindow("当前正在回放,请结束后再操作!", 2f); |
|
return; |
|
} |
|
ResourceLoadWindow.Instance.LoadTipWindow("确定清空场景吗?", ClearAllObjects, null); |
|
} |
|
|
|
private void ClearAllObjects() |
|
{ |
|
if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal) |
|
{ |
|
var eventData = new EventData(); |
|
eventData.time = RecordManager.Instance.RecordTimer; |
|
eventData.cloneObjType = CloneObjType.None; |
|
eventData.eventType = RecordEventType.ClearAll; |
|
RecordManager.Instance.jsonData.eventDataList.Add(eventData); |
|
} |
|
|
|
MessageDispatcher.SendMessage("ClearObject"); |
|
} |
|
|
|
private void ShowName(bool arg0) |
|
{ |
|
GlobalVariable.InfoActive = arg0; |
|
MessageDispatcher.SendMessage("ShowHideInfo"); |
|
} |
|
|
|
private void TeamName() |
|
{ |
|
TeamNameSetting.GetInstance.gameObject.SetActive(true); |
|
} |
|
|
|
private void OnDestroy() |
|
{ |
|
GlobalVariable.FloorsOn = true; |
|
GlobalVariable.ToolsOn = false; |
|
MessageDispatcher.RemoveListener("ReplayFrame", ReplayFrameWeatherSetting); |
|
MessageDispatcher.RemoveListener("ReplayEvent", ReplayEventWeatherSetting); |
|
MessageDispatcher.RemoveListener("FloorsOn", FloorsOnChanged); |
|
} |
|
private void ReplayEventWeatherSetting(IMessage obj) |
|
{ |
|
var eventData = (EventData)obj.Data; |
|
if (eventData.eventType == RecordEventType.WeatherSetting) |
|
{ |
|
weatherSettingManager.TianQiSettingData = JsonUtility.FromJson<TianQiSetting>(eventData.json); |
|
//if (!MyToggle.isOn) |
|
//{ |
|
// MyToggle.isOn = true; |
|
//} |
|
//if (!weatherToggle.isOn) |
|
//{ |
|
// weatherToggle.isOn = true; |
|
//} |
|
weatherSettingManager.InitTianQi(); |
|
//StartCoroutine(HideTianQiPanel(1f)); |
|
} |
|
else if (eventData.eventType == RecordEventType.ToolsOn) |
|
{ |
|
MyToggle.isOn = bool.Parse(eventData.json); |
|
} |
|
else if (eventData.eventType == RecordEventType.ClearAll) |
|
{ |
|
ClearAllObjects(); |
|
} |
|
} |
|
|
|
|
|
private void ReplayFrameWeatherSetting(IMessage obj) |
|
{ |
|
var objectData = (ObjectData)obj.Data; |
|
if (objectData.cloneObjType == CloneObjType.Weather) |
|
{ |
|
weatherSettingManager.TianQiSettingData = JsonUtility.FromJson<TianQiSetting>(objectData.json); |
|
//if (!MyToggle.isOn) |
|
//{ |
|
// MyToggle.isOn = true; |
|
//} |
|
//if (!weatherToggle.isOn) |
|
//{ |
|
// weatherToggle.isOn = true; |
|
//} |
|
weatherSettingManager.InitTianQi(); |
|
//StartCoroutine(HideTianQiPanel(1f)); |
|
} |
|
else if (objectData.cloneObjType == CloneObjType.ToolsOn) |
|
{ |
|
MyToggle.isOn = bool.Parse(objectData.json); |
|
} |
|
} |
|
private void MyToggleValueChanged(bool IsOn) |
|
{ |
|
MyToggle.interactable = false; |
|
if (IsOn) |
|
{ |
|
StartCoroutine(InMethord(moveManager.MoveTime + 0.01f)); |
|
GlobalVariable.ToolsOn = true; |
|
MessageDispatcher.SendMessage("ToolsOn"); |
|
} |
|
else |
|
{ |
|
StartCoroutine(OutMethord(moveManager.MoveTime + 0.01f)); |
|
GlobalVariable.ToolsOn = false; |
|
} |
|
if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal) |
|
{ |
|
|
|
var eventData = new EventData(); |
|
eventData.time = RecordManager.Instance.RecordTimer; |
|
eventData.cloneObjType = CloneObjType.None; |
|
eventData.eventType = RecordEventType.ToolsOn; |
|
eventData.json = IsOn.ToString(); |
|
|
|
RecordManager.Instance.jsonData.eventDataList.Add(eventData); |
|
} |
|
} |
|
IEnumerator InMethord(float time) |
|
{ |
|
moveManager.gameObject.SetActive(true); |
|
moveManager.MoveIn_Click(); |
|
yield return new WaitForSeconds(time); |
|
MyToggle.interactable = true; |
|
} |
|
IEnumerator OutMethord(float time) |
|
{ |
|
moveManager.MoveOut_Click(); |
|
yield return new WaitForSeconds(time); |
|
MyToggle.interactable = true; |
|
moveManager.gameObject.SetActive(false); |
|
} |
|
IEnumerator HideTianQiPanel(float time) |
|
{ |
|
yield return new WaitForSeconds(time); |
|
if (MyToggle.isOn) |
|
{ |
|
MyToggle.isOn = false; |
|
} |
|
} |
|
|
|
private void weatherToggleValueChanged(bool IsOn) |
|
{ |
|
weatherSettingManager.gameObject.SetActive(IsOn); |
|
} |
|
|
|
// Update is called once per frame |
|
void Update() |
|
{ |
|
if (weatherSettingManager.HasNeightChange)//如果有昼夜交替 |
|
{ |
|
weatherSettingManager.NeightTimeInput.interactable = false; |
|
weatherSettingManager.DateTimeSlider.value = weatherSettingManager.skyController.TIME_of_DAY / 24 * ReplayManager.playSpeed; |
|
} |
|
else |
|
{ |
|
weatherSettingManager.NeightTimeInput.interactable = true; |
|
} |
|
} |
|
}
|
|
|