_xiaofang/xiaofang/Assets/Script/UI/PanelUI/EvacuationPanel.cs

129 lines
3.3 KiB
C#
Raw Normal View History

2024-12-01 19:24:07 +08:00
using System;
2024-11-29 09:47:47 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class EvacuationPanel : MonoBehaviour
{
public Transform personnelContent;
public Panel panel;
public GameObject personnelPrefabs;
2024-11-29 16:20:58 +08:00
public GameObject classPrefab;
public Transform content;
2024-11-30 17:43:21 +08:00
public Text topText;
2024-12-01 19:24:07 +08:00
public List<ClassItem> classItemList = new List<ClassItem>();
2024-11-30 17:43:21 +08:00
[Header("ѧ<><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")]
public InputField StuCountInputField;
public Button CountsubmitBtn;
public Sprite rsprite;
public Sprite fsprite;
public GameObject JuesechoicePop;
2024-12-01 19:24:07 +08:00
public JueseChoicePop jc = new JueseChoicePop();
2024-11-30 17:43:21 +08:00
[Header("<22>ܰ<EFBFBD>ť")]
public Button redistributeBtn;
public Button submitBtn;
2024-11-29 16:20:58 +08:00
2024-12-01 15:06:22 +08:00
[Header("Npc<70><63><EFBFBD><EFBFBD>")]
public int npcNum;
2024-11-29 09:47:47 +08:00
// Start is called before the first frame update
void Start()
{
2024-12-01 19:24:07 +08:00
jc = JuesechoicePop.GetComponent<JueseChoicePop>();
redistributeBtn.onClick.AddListener(ClearData);
submitBtn.onClick.AddListener(Submit);
2024-11-30 17:43:21 +08:00
StuCountInputField.onEndEdit.AddListener(CheckInput);
SetClass();
2024-11-29 09:47:47 +08:00
}
2024-12-01 19:24:07 +08:00
private void Submit()
{
}
private void ClearData()
{
foreach(var item in classItemList)
{
item.isSet = false;
item.setClassItem("");
}
}
2024-11-29 09:47:47 +08:00
// Update is called once per frame
void Update()
{
2024-11-30 17:43:21 +08:00
CheckInput(StuCountInputField.text);
2024-11-29 09:47:47 +08:00
}
public void SetPersonnel()
{
foreach (Transform child in personnelContent)
{
Destroy(child.gameObject);
}
foreach (var sceneEntry in panel.sceneDataDictionary)
{
GameObject item = GameObject.Instantiate<GameObject>(personnelPrefabs, personnelContent);
PersonnelItem personnelItem=item.GetComponent<PersonnelItem>();
personnelItem.sceneText.text = sceneEntry.Key;
personnelItem.personnelNum.text = sceneEntry.Value.Count.ToString();
}
}
2024-11-30 17:43:21 +08:00
//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>1
void CheckInput(string input)
{
// <20><><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
if (float.TryParse(input, out float result))
{
// <20>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>1
if (result > 1)
{
CountsubmitBtn.GetComponent<Image>().sprite = rsprite;
CountsubmitBtn.onClick.AddListener(Countsubmit);
}
}
}
public void Countsubmit()
{
//<2F><>ť<EFBFBD>û<EFBFBD>
CountsubmitBtn.GetComponent<Image>().sprite = fsprite;
StuCountInputField.text = string.Empty;
//<2F><><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Npc<70><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
//ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CountsubmitBtn.onClick.RemoveAllListeners();
}
//<2F><><EFBFBD><EFBFBD>ID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public void SettopText()
{
topText.text = "<22><><EFBFBD>°༶<C2B0><E0BCB6>Ҫ<EFBFBD><EFBFBD><E8B6A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʦ<EFBFBD><CAA6>";
topText.text = "<22><><EFBFBD><EFBFBD>¥<EFBFBD><C2A5><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD>ʦ<EFBFBD><CAA6>";
}
//ʵ<><CAB5><EFBFBD><EFBFBD>ClassItem
public void SetClass()
{
for (int i = 0; i < 10; i++)
{
GameObject item = GameObject.Instantiate<GameObject>(classPrefab, content);
ClassItem classItem = item.GetComponent<ClassItem>();
classItem.JuesechoicePop = JuesechoicePop;
2024-12-01 19:24:07 +08:00
classItemList.Add(classItem);
2024-11-30 17:43:21 +08:00
}
}
2024-12-01 15:06:22 +08:00
//Npc<70><63><EFBFBD><EFBFBD>
public void NpcDistribution()
{
2024-12-01 15:06:22 +08:00
}
2024-11-29 09:47:47 +08:00
}