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.
277 lines
9.2 KiB
277 lines
9.2 KiB
using UnityEngine; |
|
using System.Collections; |
|
using UnityEngine.UI; |
|
using AX.TrackRecord; |
|
using AX.MessageSystem; |
|
public class PoChaiUI : MonoBehaviour { |
|
|
|
private GameObject Part1; |
|
private GameObject Part2; |
|
private GameObject Part3; |
|
private GameObject Part4; |
|
[HideInInspector] |
|
public Toggle Toggle1; |
|
[HideInInspector] |
|
public Toggle Toggle2; |
|
[HideInInspector] |
|
public Toggle Toggle3; |
|
[HideInInspector] |
|
public Toggle Toggle4; |
|
[HideInInspector] |
|
public Toggle Toggle5; |
|
[HideInInspector] |
|
public Toggle Toggle6; |
|
|
|
private GameObject Group2; |
|
private GameObject Group3; |
|
public static PoChaiUI instance; |
|
private Text BiaoTi; |
|
[HideInInspector] |
|
public GameObject obj_Mask; |
|
int Num; |
|
void Awake() |
|
{ |
|
|
|
if (instance == null) |
|
{ |
|
instance = this; |
|
} |
|
Part1 = transform.Find("Part1").gameObject; |
|
Part2 = transform.Find("Part2").gameObject; |
|
Part3 = transform.Find("Part3").gameObject; |
|
Part4 = transform.Find("Part4").gameObject; |
|
Group2 = Part2.transform.Find("Group").gameObject; |
|
Group3 = Part3.transform.Find("Group").gameObject; |
|
BiaoTi = transform.Find("BiaoTi").Find("Text").GetComponent<Text>(); |
|
Toggle1 = Group2.transform.Find("Toggle1").GetComponent<Toggle>(); |
|
Toggle2 = Group2.transform.Find("Toggle2").GetComponent<Toggle>(); |
|
Toggle3 = Group2.transform.Find("Toggle3").GetComponent<Toggle>(); |
|
Toggle4 = Group3.transform.Find("Toggle1").GetComponent<Toggle>(); |
|
Toggle5 = Group3.transform.Find("Toggle2").GetComponent<Toggle>(); |
|
Toggle6 = Group3.transform.Find("Toggle3").GetComponent<Toggle>(); |
|
obj_Mask = transform.Find("Mask").gameObject; |
|
} |
|
void OnEnable() |
|
{ |
|
StartCoroutine(delay()); |
|
} |
|
IEnumerator delay() |
|
{ |
|
yield return new WaitForEndOfFrame(); |
|
if (TrackRecordHelpClass.CheckIfCanClickUI()) |
|
{ |
|
obj_Mask.SetActive(false); |
|
} |
|
else |
|
{ |
|
obj_Mask.SetActive(true); |
|
} |
|
} |
|
private PoChai PochaiAttri; |
|
public PoChai pochaiAttri |
|
{ |
|
get |
|
{ |
|
PochaiAttri = new PoChai(); |
|
PochaiAttri.Toggle1 = Toggle1.isOn; |
|
PochaiAttri.Toggle2 = Toggle2.isOn; |
|
PochaiAttri.Toggle3 = Toggle3.isOn; |
|
PochaiAttri.Toggle4 = Toggle4.isOn; |
|
PochaiAttri.Toggle5 = Toggle5.isOn; |
|
PochaiAttri.Toggle6 = Toggle6.isOn; |
|
return PochaiAttri; |
|
} |
|
set |
|
{ |
|
PochaiAttri = value; |
|
gameObject.SetActive(true); |
|
transform.Find("Group").Find("Toggle1").GetComponent<Toggle>().isOn = PochaiAttri.Toggle1; |
|
transform.Find("Group").Find("Toggle2").GetComponent<Toggle>().isOn = PochaiAttri.Toggle2; |
|
transform.Find("Group").Find("Toggle3").GetComponent<Toggle>().isOn = PochaiAttri.Toggle3; |
|
transform.Find("Group").Find("Toggle4").GetComponent<Toggle>().isOn = PochaiAttri.Toggle4; |
|
transform.Find("Group").Find("Toggle5").GetComponent<Toggle>().isOn = PochaiAttri.Toggle5; |
|
transform.Find("Group").Find("Toggle6").GetComponent<Toggle>().isOn = PochaiAttri.Toggle6; |
|
} |
|
|
|
} |
|
GameObject Game; |
|
public void SetPoChaiUI(GameObject obj) |
|
{ |
|
Game = obj; |
|
Part1.gameObject.SetActive(true); |
|
Part2.gameObject.SetActive(false); |
|
Part3.gameObject.SetActive(false); |
|
Part4.gameObject.SetActive(false); |
|
foreach (Transform child in Group2.transform) |
|
{ |
|
child.GetComponent<Toggle>().isOn = false; |
|
} |
|
foreach (Transform child in Group3.transform) |
|
{ |
|
child.GetComponent<Toggle>().isOn = false; |
|
} |
|
StartShow(); |
|
Num = 0; |
|
if (RecordManager.Instance.IsRecording) |
|
{ |
|
TrackRecordHelpClass.RecordOpenUIEvent(obj,this.gameObject.name); |
|
} |
|
} |
|
public void StartShow() |
|
{ |
|
BiaoTi.text = "温馨提示"; |
|
} |
|
public void ChangeShow() |
|
{ |
|
Num++; |
|
switch (Num) |
|
{ |
|
case 1: AllFalse(); BiaoTi.text = "破拆点"; |
|
Part2.gameObject.SetActive(true); |
|
break; |
|
case 2: AllFalse(); BiaoTi.text = "破拆点"; |
|
if (Toggle1.isOn == false && Toggle2.isOn == false && Toggle3.isOn == false) |
|
{ |
|
Part2.gameObject.SetActive(true); |
|
Num = 1; |
|
MessageDispatcher.SendMessage("Operatinghints", (object)"请选择处理方式"); |
|
} |
|
else |
|
{ |
|
Part3.gameObject.SetActive(true); |
|
} |
|
break; |
|
case 3: AllFalse(); BiaoTi.text = "温馨提示"; |
|
if (Toggle4.isOn == false && Toggle5.isOn == false && Toggle6.isOn == false) |
|
{ |
|
Part3.gameObject.SetActive(true); |
|
Num = 2; |
|
MessageDispatcher.SendMessage("Operatinghints", (object)"请选择处理方式"); |
|
} |
|
else |
|
{ |
|
Part4.gameObject.SetActive(true); |
|
}; |
|
break; |
|
} |
|
} |
|
public void AllFalse() |
|
{ |
|
Part1.gameObject.SetActive(false); |
|
Part2.gameObject.SetActive(false); |
|
Part3.gameObject.SetActive(false); |
|
Part4.gameObject.SetActive(false); |
|
} |
|
public void CloseUi() |
|
{ |
|
this.gameObject.SetActive(false); |
|
if (RecordManager.Instance.IsRecording) |
|
{ |
|
TrackRecordHelpClass.RecordPoChaiEvent(pochaiAttri); |
|
TrackRecordHelpClass.RecordEditPoChaiEvent(pochaiAttri); |
|
|
|
} |
|
string pName = TrackRecordHelpClass.GetParentName(Game.name); |
|
MessageDispatcher.SendMessage(pName, "DestroyObj", (object)Game.name); |
|
} |
|
|
|
public void LoadAttri(float Time)//加载数据 |
|
{ |
|
foreach (var key in LoadManager.Instance.eventListDic.Keys) |
|
{ |
|
if (LoadManager.Instance.eventListDic[key].Count > 0) |
|
{ |
|
if (Time < key) |
|
{ |
|
var EvenList = DictProcessHelpClass.GetUniqList(LoadManager.Instance.eventListDic[key]); |
|
for (int i = 0; i < EvenList.Count; i++) |
|
{ |
|
EventRecordItem_two Event = EvenList[i] as EventRecordItem_two; |
|
if (Event.eventType == eventTypeRecord.PoChaiUI) |
|
{ |
|
Toggle1.isOn = Event.PochaiAttri[0].Toggle1; |
|
Toggle2.isOn = Event.PochaiAttri[0].Toggle2; |
|
Toggle3.isOn = Event.PochaiAttri[0].Toggle3; |
|
Toggle4.isOn = Event.PochaiAttri[0].Toggle4; |
|
Toggle5.isOn = Event.PochaiAttri[0].Toggle5; |
|
Toggle6.isOn = Event.PochaiAttri[0].Toggle6; |
|
timer1 = 1; |
|
timer2 = 2; |
|
timer3 = 2; |
|
timer4 = 1; |
|
Can = true; |
|
one = true; |
|
two = false; |
|
three = false; |
|
four = false; |
|
return; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
} |
|
bool Can = false; |
|
float timer1 = 1; |
|
float timer2 = 2; |
|
float timer3 = 2; |
|
float timer4 = 1; |
|
bool one = true; |
|
bool two = false; |
|
bool three = false; |
|
bool four = false; |
|
void Update() |
|
{ |
|
|
|
if (Can && LoadManager.Instance.IsPlayBacking && !LoadManager.Instance.IsPause)//只有回放时计时自动关闭 |
|
{ |
|
if (one && timer1 > 0) |
|
{ |
|
timer1 -= Time.deltaTime * LoadManager.Instance.LoadSpeed; |
|
if (timer1 < 0) |
|
{ |
|
one = false; |
|
two = true; |
|
AllFalse(); |
|
Part2.gameObject.SetActive(true); |
|
} |
|
} |
|
else if (!one && two && timer2 > 0) |
|
{ |
|
timer2 -= Time.deltaTime * LoadManager.Instance.LoadSpeed; |
|
if (timer2 < 0) |
|
{ |
|
two = false; |
|
three = true; |
|
AllFalse(); |
|
Part3.gameObject.SetActive(true); |
|
} |
|
} |
|
else if (!two && three && timer3 > 0) |
|
{ |
|
timer3 -= Time.deltaTime * LoadManager.Instance.LoadSpeed; |
|
if (timer3 < 0) |
|
{ |
|
three = false; |
|
four = true; |
|
AllFalse(); |
|
Part4.gameObject.SetActive(true); |
|
} |
|
} |
|
else if (!three && four && timer4 > 0) |
|
{ |
|
timer4 -= Time.deltaTime * LoadManager.Instance.LoadSpeed; |
|
if (timer4 < 0) |
|
{ |
|
four = false; |
|
this.gameObject.SetActive(false); |
|
Can = false; |
|
} |
|
} |
|
|
|
|
|
} |
|
} |
|
}
|
|
|