This commit is contained in:
lq 2024-12-10 23:24:15 +08:00
parent 94eb75df55
commit 0b05e7d0ef
2 changed files with 31 additions and 5 deletions

View File

@ -334,6 +334,8 @@ public class EvacuationPanel : MonoBehaviour
levelBtn.onClick.AddListener(() =>
{
jueseChoicePanel.gameObject .SetActive(true);
JueseChoicePop jueseChoicePop= jueseChoicePanel.gameObject.GetComponent<JueseChoicePop>();
jueseChoicePop.SetClass(personnelItem.sceneId);
});
ClassItem classItem = levelItem.GetComponent<ClassItem>();
classItem.classname.text = locationData.Level.ToString();

View File

@ -17,6 +17,7 @@ public class JueseChoicePop : MonoBehaviour
public List<ClassMate> classMateList = new List<ClassMate> ();
public string s;
public JSONReader jsonReader;
//Start is called before the first frame update
void Start()
{
@ -47,16 +48,39 @@ public class JueseChoicePop : MonoBehaviour
}
public void SetClass(int id)
{
// 获取指定 ID 的 LocationData
LocationData locationData = jsonReader.GetAreaDateById(id);
for (int i = 0; i < 10; i++)
// 判断 Oversee 字段
if (locationData.Oversee == "-1")
{
GameObject item = GameObject.Instantiate<GameObject>(classmatePrefab, content);
Debug.Log($"Skipping ID {id}: Oversee is -1.");
return; // 跳过
}
// 分割 Oversee 字段
string[] overseeParts = locationData.Oversee.Split(',');
foreach (string part in overseeParts)
{
// 检查每个部分的最后一位是否为 "1"
string[] elements = part.Split('|');
if (elements.Length > 1)
{
string lastElement = elements[elements.Length - 1];
if (lastElement == "1") // 如果最后一部分是 "1",实例化对象
{
GameObject item = GameObject.Instantiate(classmatePrefab, content);
ClassMate classMate = item.GetComponent<ClassMate>();
classMateList.Add(classMate);
//classMate.SetJc(this);
// 设置 ClassMate 的名称或其他字段
classMate.classmatename.text = locationData.Note;
Debug.Log($"Instantiated ClassMate for ID {id} with name {locationData.Name}");
}
}
}
}
public void SetClassItem(ClassItem classItem)
{