using System.Collections; using System.Collections.Generic; using UnityEngine; public class PaoZhangMainPage : UIPageBtnEventBase { public List pages=new List(); public Transform selectionsPar; private void Awake() { for (int i = 0; i <= 40; i++) { SetOneState(i, 0); } } public override void OnF1Click() { base.OnF1Click(); ShowPage(0); } private void OnEnable() { if (Shoot122Manager.Instance.isShoot)//打完就清空 { ShootAll(); return; } if (Shoot122Manager.Instance.choosedValue.Count != 0) { //每次打开更新一下弹孔状态 foreach (KeyValuePair kvp in Shoot122Manager.Instance.choosedValue) { int key = int.Parse(kvp.Key); int value = kvp.Value; SetOneState(key, value); } } } public void ShowSelectIcon(int index) { if (Shoot122Manager.Instance.isShoot == false) { if (Shoot122Manager.Instance.chooseShoot.Count == 0) { for (int i = 0; i < selectionsPar.childCount; i++) { for (int j = 0; j < 3; j++) { selectionsPar.GetChild(i).GetChild(j).gameObject.SetActive(false); } selectionsPar.GetChild(i).gameObject.SetActive(false); } return; } } } /// /// 设置某个弹孔的状态 /// /// /// 3空直接关闭 0有弹 1选中 2留膛 public void SetOneState(int index, int state) { string itemName = index.ToString(); if (state == 3) { selectionsPar.Find(itemName).gameObject.SetActive(false); return; } for (int i = 0; i < selectionsPar.childCount; i++) { if (selectionsPar.GetChild(i).name == itemName) { Transform item = selectionsPar.GetChild(i); item.gameObject.SetActive(true); for (int j = 0; j < item.childCount-1; j++) { item.GetChild(j).gameObject.SetActive(false); } item.GetChild(state).gameObject.SetActive(true); } } //switch (state) //{ // case 0: // break; // case 1: // break; // case 2: // break; //} } /// /// 所有弹都打空 /// void ShootAll() { for (int i = 0; i < selectionsPar.childCount; i++) { for (int j = 0; j < 3; j++) { selectionsPar.GetChild(i).GetChild(j).gameObject.SetActive(false); } selectionsPar.GetChild(i).gameObject.SetActive(false); } } //void FindPointAndShowState(string pointName, int state) //{ // for (int i = 0; i < pointLayout.childCount; i++) // { // if (pointName == pointLayout.GetChild(i).name) // { // if (state != 3) // { // for (int j = 0; j < pointLayout.GetChild(i).childCount; j++) // { // pointLayout.GetChild(i).GetChild(j).gameObject.SetActive(false); // } // pointLayout.GetChild(i).GetChild(state).gameObject.SetActive(true); // pointLayout.GetChild(i).gameObject.SetActive(true); // Debug.Log(pointLayout.GetChild(i).GetChild(state).gameObject); // } // else // { // for (int j = 0; j < pointLayout.GetChild(i).childCount; j++) // { // pointLayout.GetChild(i).GetChild(j).gameObject.SetActive(false); // } // pointLayout.GetChild(i).gameObject.SetActive(false); // } // break; // } // } //} public override void OnF2Click() { base.OnF2Click(); ShowPage(1); } public override void OnF3Click() { base.OnF3Click(); ShowPage(2); } public override void OnF4Click() { base.OnF4Click(); ShowPage(3); } public override void OnF5Click() { base.OnF5Click(); ShowPage(4); } public override void OnF6Click() { base.OnF6Click(); //目前不知道内容 ManagerPaoZhangBase.instance.ShowDownTip("提示瞄准手取消操作"); } public override void OnF7Click() { base.OnF7Click(); ShowPage(6); } GameObject currectPage; void ShowPage(int index) { //if (index == 0 || index == 2 || index == 4) //{ // showPages[index].SetActive(true); // return; //} currectPage = Instantiate(pages[index], transform.parent); currectPage.SetActive(true); gameObject.SetActive(false); } public void ShowMain() { gameObject.SetActive(true); } }