HKMBFZ/Assets/Scripts/Szz_Scripts/UI/181/XingJunDaoHangPage.cs

177 lines
4.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class XingJunDaoHangPage : UIPageBtnEventBase
{
public List<GameObject> myPages = new List<GameObject>();
public List<Sprite> maps=new List<Sprite>();
public KeyboardScrollView keyboardScrollView;
public CustomTMPInputField ;
public CustomTMPInputField X;
public CustomTMPInputField Y;
public CustomTMPInputField H;
public CustomTMPDropdown ;
public GameObject itemPrefab;
public Transform itemParent;
public List<GameObject> items = new List<GameObject>();
private void OnEnable()
{
enter181 = FindObjectOfType<Enter181Page>();
for (int i = 0; i < myPages.Count; i++)
{
myPages[i].SetActive(false);
}
myPages[0].SetActive(true);
currentIndex = 0;
}
public void ChangeItem(int index)
{
for (int i = 0; i < items.Count; i++)
{
items[i].SetActive(false);
}
items[index].SetActive(true);
}
public override void OnF1Click()
{
base.OnF1Click();
if (myPages[2].activeInHierarchy)
{
if (!myPages[2].transform.GetChild(1).gameObject.activeInHierarchy)
myPages[2].transform.GetChild(1).gameObject.SetActive(true);
else
{
myPages[2].transform.GetChild(1).gameObject.SetActive(false);
//扢离綴剒猁載遙賜醱
myPages[2].transform.GetChild(0).GetChild(0).GetComponent<Image>().sprite = maps[keyboardScrollView.currentIndex];
}
}
}
public override void OnF2Click()
{
base.OnF2Click();
if (currentIndex == 1)
{
if (X.text != "" && Y.text != "" && H.text != "")
{
GameObject it = Instantiate(itemPrefab, itemParent);
it.transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = .text;
it.transform.GetChild(1).GetComponent<TextMeshProUGUI>().text = X.text;
it.transform.GetChild(2).GetComponent<TextMeshProUGUI>().text = Y.text;
it.transform.GetChild(3).GetComponent<TextMeshProUGUI>().text = H.text;
it.transform.GetChild(4).GetComponent<TextMeshProUGUI>().text = .options[.value].text;
}
}
}
public override void OnF3Click()
{
base.OnF3Click();
//F3岆奻珨珜
Previous();
}
public override void OnF4Click()
{
base.OnF4Click();
Next();
}
public override void OnF5Click()
{
base.OnF5Click();
enter181.OnShow();
ResetPage(myPages);
//gameObject.SetActive(false);
Destroy(gameObject);
}
private int currentIndex = 0;
/// <summary>
/// ピ遙善狟珨跺啋匼
/// </summary>
public void Next()
{
if (myPages == null || myPages.Count == 0) return;
// ⺼彆岆郔綴珨跺啋匼ㄛ寀祥輛俴紱釬
if (currentIndex >= myPages.Count - 1) return;
// 笐紲絞ゴ啋匼
if (myPages[currentIndex] != null)
myPages[currentIndex].SetActive(false);
currentIndex++;
// 珆尨狟珨跺啋匼
if (myPages[currentIndex] != null)
myPages[currentIndex].SetActive(true);
}
/// <summary>
/// ピ遙善奻珨跺啋匼
/// </summary>
public void Previous()
{
if (myPages == null || myPages.Count == 0) return;
// ⺼彆岆菴珨跺啋匼ㄛ寀祥輛俴紱釬
if (currentIndex <= 0) return;
// 笐紲絞ゴ啋匼
if (myPages[currentIndex] != null)
myPages[currentIndex].SetActive(false);
currentIndex--;
// 珆尨奻珨跺啋匼
if (myPages[currentIndex] != null)
myPages[currentIndex].SetActive(true);
}
public Enter181Page enter181;
void ResetPage(List<GameObject> targets)
{
DeactivateAllObjects(myPages);
}
public void DeactivateAllObjects(List<GameObject> targetObjects)
{
foreach (var obj in targetObjects.Where(obj => obj != null))
{
obj.SetActive(false);
//foreach (Transform child in obj.transform)
//{
// child.gameObject.SetActive(false);
//}
}
}
}