修改
This commit is contained in:
parent
94eb75df55
commit
0b05e7d0ef
@ -334,6 +334,8 @@ public class EvacuationPanel : MonoBehaviour
|
|||||||
levelBtn.onClick.AddListener(() =>
|
levelBtn.onClick.AddListener(() =>
|
||||||
{
|
{
|
||||||
jueseChoicePanel.gameObject .SetActive(true);
|
jueseChoicePanel.gameObject .SetActive(true);
|
||||||
|
JueseChoicePop jueseChoicePop= jueseChoicePanel.gameObject.GetComponent<JueseChoicePop>();
|
||||||
|
jueseChoicePop.SetClass(personnelItem.sceneId);
|
||||||
});
|
});
|
||||||
ClassItem classItem = levelItem.GetComponent<ClassItem>();
|
ClassItem classItem = levelItem.GetComponent<ClassItem>();
|
||||||
classItem.classname.text = locationData.Level.ToString();
|
classItem.classname.text = locationData.Level.ToString();
|
||||||
|
@ -17,6 +17,7 @@ public class JueseChoicePop : MonoBehaviour
|
|||||||
public List<ClassMate> classMateList = new List<ClassMate> ();
|
public List<ClassMate> classMateList = new List<ClassMate> ();
|
||||||
|
|
||||||
public string s;
|
public string s;
|
||||||
|
public JSONReader jsonReader;
|
||||||
//Start is called before the first frame update
|
//Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
@ -47,17 +48,40 @@ public class JueseChoicePop : MonoBehaviour
|
|||||||
}
|
}
|
||||||
public void SetClass(int id)
|
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; // 跳过
|
||||||
|
}
|
||||||
|
|
||||||
ClassMate classMate = item.GetComponent<ClassMate>();
|
// 分割 Oversee 字段
|
||||||
classMateList.Add(classMate);
|
string[] overseeParts = locationData.Oversee.Split(',');
|
||||||
//classMate.SetJc(this);
|
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>();
|
||||||
|
|
||||||
|
// 设置 ClassMate 的名称或其他字段
|
||||||
|
classMate.classmatename.text = locationData.Note;
|
||||||
|
|
||||||
|
Debug.Log($"Instantiated ClassMate for ID {id} with name {locationData.Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void SetClassItem(ClassItem classItem)
|
public void SetClassItem(ClassItem classItem)
|
||||||
{
|
{
|
||||||
this.classItem = classItem;
|
this.classItem = classItem;
|
||||||
|
Loading…
Reference in New Issue
Block a user