_xiaofang/xiaofang/Assets/yhj/scripts/JueseChoicePop.cs

139 lines
4.0 KiB
C#
Raw Normal View History

2024-11-30 17:43:21 +08:00
using System.Collections;
using System.Collections.Generic;
2024-12-24 18:51:35 +08:00
using System.Linq;
2024-12-01 22:24:03 +08:00
using Unity.VisualScripting;
2024-11-30 17:43:21 +08:00
using UnityEngine;
2024-12-24 18:51:35 +08:00
using UnityEngine.Assertions.Must;
2024-12-11 01:32:11 +08:00
using UnityEngine.Networking.Types;
2024-11-30 17:43:21 +08:00
using UnityEngine.UI;
public class JueseChoicePop : MonoBehaviour
{
2024-12-01 19:24:07 +08:00
public ClassMate classMate;
public ClassItem classItem;
2024-11-30 17:43:21 +08:00
public Button CloseBtn;
public Button Surebtn;
public GameObject classmatePrefab;
public Transform content;
2024-12-01 22:24:03 +08:00
public List<ClassMate> classMateList = new List<ClassMate> ();
2024-12-24 18:51:35 +08:00
// <20><EFBFBD><E6B4A2>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GameObject <20>б<EFBFBD>
private List<GameObject> instantiatedObjects = new List<GameObject>();
2024-12-27 23:42:19 +08:00
// <20><><EFBFBD>ڼ<EFBFBD>¼<EFBFBD>Ѽ<EFBFBD><D1BC>ص<EFBFBD>SceneId<49><64><EFBFBD><EFBFBD>DutyId
HashSet<string> loadedSceneIds = new HashSet<string>(); // <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
2024-12-01 22:24:03 +08:00
2024-12-10 18:14:08 +08:00
public string s;
2024-12-10 23:24:15 +08:00
public JSONReader jsonReader;
2024-12-11 01:32:11 +08:00
public Panel panel;
2024-12-27 11:53:50 +08:00
public WarningPopPanel WarningPopPanel;
2024-12-10 18:14:08 +08:00
//Start is called before the first frame update
2024-11-30 17:43:21 +08:00
void Start()
{
this.gameObject.SetActive(false);
CloseBtn.onClick.AddListener(CLosePop);
Surebtn.onClick.AddListener(CLosePop);
2024-12-11 01:32:11 +08:00
//Surebtn.onClick.AddListener(SetFenguan);
2024-12-10 21:34:19 +08:00
//SetClass();
2024-12-24 18:51:35 +08:00
}
void Update()
{
2024-12-26 17:36:12 +08:00
2024-11-30 17:43:21 +08:00
}
void CLosePop()
{
2024-12-27 23:42:19 +08:00
//ClearAll();
2024-11-30 17:43:21 +08:00
this.gameObject.SetActive(false);
}
public void openPop()
{
this.gameObject.SetActive(true);
}
void SetFenguan()
{
//<2F><><EFBFBD>ô<EFBFBD><C3B4><EFBFBD><EFBFBD>ֵķֹ<C4B7><D6B9><EFBFBD>ԱΪ<D4B1>û<EFBFBD>ѡ<EFBFBD>еĽ<D0B5>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>ˢ<EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD><EFBFBD>Ϣ
2024-12-01 19:24:07 +08:00
classItem.isSet = true;
//classItem.setClassItem();
2024-11-30 17:43:21 +08:00
}
2024-12-24 18:51:35 +08:00
//<2F><><EFBFBD>طֹ<D8B7><D6B9><EFBFBD>Ա
2024-12-27 23:42:19 +08:00
public void SetClass(string a)
{
foreach(var all in panel.sceneDataDictionary)
2024-11-30 17:43:21 +08:00
{
2024-12-27 23:42:19 +08:00
foreach (var info in all.Value)
2024-11-30 17:43:21 +08:00
{
2024-12-27 23:42:19 +08:00
Debug.LogError("-------------------------"+ info.sceneId);
LocationData locationData = jsonReader.GetAreaDateById(int.Parse(info.sceneId));
if (locationData.Oversee == "-1")
2024-12-27 11:53:50 +08:00
{
2024-12-27 23:42:19 +08:00
Debug.Log($"Skipping ID{info.sceneId}: Oversee is -1.");
continue; // <20><><EFBFBD><EFBFBD>
}
string[] overseeParts = locationData.Oversee.Split(',');
string firstElement = overseeParts[0];
string lastElement = overseeParts[1];
if (overseeParts.Length > 0 && firstElement == info.dutyId && lastElement == "1")
{
Debug.LogError(loadedSceneIds.Contains(info.name));
// <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ع<EFBFBD><D8B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (loadedSceneIds.Contains(info.name))
2024-12-26 17:36:12 +08:00
{
2024-12-27 23:42:19 +08:00
Debug.Log($"Scene ID {info.sceneId} already loaded. Skipping.");
continue; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>sceneId<49>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ع<EFBFBD><D8B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-12-26 17:36:12 +08:00
}
2024-12-27 23:42:19 +08:00
// <20><><EFBFBD><EFBFBD>û<EFBFBD>м<EFBFBD><D0BC>ع<EFBFBD><D8B9><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ԥ<EFBFBD><D4A4><EFBFBD><EFBFBD>
GameObject item = GameObject.Instantiate(classmatePrefab, content);
ClassMate classMate = item.GetComponent<ClassMate>();
Button button = item.GetComponent<Button>();
button.onClick.AddListener(() =>
2024-12-10 23:24:15 +08:00
{
2024-12-27 23:42:19 +08:00
SetClassMate(classMate, a);
});
classMate.name = info.name;
classMate.classmatename.text = classMate.name;
// classMate.id = info.dutyId;
instantiatedObjects.Add(item);
// <20><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ص<EFBFBD>sceneId<49><64><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
loadedSceneIds.Add(info.name);
2024-12-10 23:24:15 +08:00
}
2024-12-27 11:53:50 +08:00
}
2024-11-30 17:43:21 +08:00
}
2024-12-27 23:42:19 +08:00
// <20><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>
if (panel.sceneDataDictionary.Count == 0)
{
WarningPopPanel.OpenPanel("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD>Ӧ<EFBFBD><D3A6>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>");
}
}
2024-12-24 18:51:35 +08:00
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>õķ<C3B5><C4B7><EFBFBD>
2024-12-10 18:14:08 +08:00
public void SetClassMate(ClassMate classMate, string a = "")
2024-12-01 19:24:07 +08:00
{
this.classMate = classMate;
2024-12-27 20:32:05 +08:00
this.classMate.classText.text = "(" + a + ")";
2024-12-24 18:51:35 +08:00
classMate.isBeSet = false;
}
public void SetClassItem(ClassItem classItem)
{
this.classItem = classItem;
2024-12-01 22:24:03 +08:00
}
2024-12-27 11:53:50 +08:00
//<2F>رս<D8B1><D5BD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public void ClearAll()
{
foreach(Transform child in content)
{
Destroy(child.gameObject);
}
}
2024-11-30 17:43:21 +08:00
}