This commit is contained in:
huyulong 2024-12-04 16:40:59 +08:00
commit 46ec56f0f6
7 changed files with 272 additions and 306 deletions

View File

@ -2232,7 +2232,7 @@ MonoBehaviour:
eventSystem: {fileID: 1579865912}
ManagerPanel: {fileID: 617308871}
peopleCountent: {fileID: 667280287}
peoplePrefab: {fileID: 0}
peoplePrefab: {fileID: 4204671800070690484, guid: 5e14c4abba3cf1a4099ba76ddf50a689, type: 3}
panelContent: {fileID: 1145997501}
dutyPrefab: {fileID: 3344224972021141760, guid: 4f774e025e4a15442aedb0588ab62396, type: 3}
dutyCount: {fileID: 1034927193}
@ -2504,7 +2504,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -193.59004, y: 309.8263}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 1}
--- !u!114 &667280288
MonoBehaviour:
@ -5861,6 +5861,10 @@ PrefabInstance:
propertyPath: m_AnchoredPosition.y
value: -62
objectReference: {fileID: 0}
- target: {fileID: 7468736064052287473, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736064090762255, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: eventName
value:
@ -5887,12 +5891,16 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7468736064090762355, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchoredPosition.x
value: 564.5
value: 206
objectReference: {fileID: 0}
- target: {fileID: 7468736064090762355, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -62
objectReference: {fileID: 0}
- target: {fileID: 7468736064090762356, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736064179597218, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMax.y
value: 0

View File

@ -31,15 +31,9 @@ public class JSONReader : MonoBehaviour
NPCDictionary = NPCParseJSON(incidentSiteJosnFile.text);
foreach (var npc in locationDictionary)
{
//.Log($"Scene ID: {npc.Value.ID}");
//Debug.Log("===========================");
}
//打印 NPC 数据
//PrintNPCData(npcDictionary);
// 打印 Location 数据
////PrintLocationData(locationDictionary);
GetNpcDataByID(8001);
}
// 解析 JSON 字符串为 NPC 数据
@ -134,43 +128,26 @@ public class JSONReader : MonoBehaviour
return locationDictionary;
}
// 打印 NPC 数据
//void PrintNPCData(Dictionary<int, NPCData> npcDictionary)
//{
// foreach (var npc in npcDictionary)
// {
// Debug.Log($"NPC ID: {npc.Value.ID}");
// Debug.Log($"Note: {npc.Value.Note}");
// Debug.Log($"Name: {npc.Value.Name}");
// Debug.Log($"ActionMode: {npc.Value.ActionMode}");
// Debug.Log($"Group: {npc.Value.Group}");
// Debug.Log($"GroupLeader: {npc.Value.GroupLeader}");
// Debug.Log($"IsLeadingNPC: {npc.Value.IsLeadingNPC}");
// Debug.Log($"ICON: {npc.Value.ICON}");
// Debug.Log($"WeightLimit: {npc.Value.WeightLimit}");
// Debug.Log($"Stats: {npc.Value.Stats}");
// Debug.Log($"Skills: {npc.Value.Skills}");
// Debug.Log($"ResPath: {npc.Value.ResPath}");
// Debug.Log("------------------------------------");
// }
//}
//将所有的数据都拿出来方便调用
// 根据给定的ID获取对应的NPC数据并返回字典中所有数据
public void GetNpcDataByID(int id)
{
// 例如,获取 NPC 字典中对应 ID 的数据
if (npcDictionary.ContainsKey(id))
{
NPCData npcData = npcDictionary[id];
// // 打印 Location 数据
//void PrintLocationData(Dictionary<int, LocationData> locationDictionary)
//{
// foreach (var location in locationDictionary)
// {
// Debug.Log($"Location ID: {location.Value.ID}");
// Debug.Log($"Note: {location.Value.Note}");
// Debug.Log($"Name: {location.Value.Name}");
// Debug.Log($"Scene: {location.Value.Scene}");
// Debug.Log($"NpcRatio: {location.Value.NpcRatio}");
// Debug.Log($"Oversee: {location.Value.Oversee}");
// Debug.Log($"RoleLimit: {location.Value.RoleLimit}");
// Debug.Log($"Level: {location.Value.Level}");
// Debug.Log("===========================");
// }
//}
// 遍历并输出字典中的所有数据
foreach (var npc in npcDictionary)
{
}
}
else
{
Debug.Log($"No NPC found with ID: {id}");
}
}
}
// 帮助类,用于解析 JSON 数组

View File

@ -13,13 +13,13 @@ using UnityEngine.UI;
public class SelectedInfo
{
public string name;
public string duty;
public string scene;
public string leader;
public string name;//角色名
public string duty;//职责
public string scene;//场景名
public string leader;//是否组长
public int dutyId;//职责的Id
}
public class Panel : MonoBehaviour
{
[Header("组件")]
@ -52,6 +52,7 @@ public class Panel : MonoBehaviour
[Header("数据")]
public string name, duty, scene;
public int dutyId;
public List<GameObject> peopleList = new List<GameObject>(); // 存储所有已加载的人员预制体
private List<GameObject> filteredPeopleList = new List<GameObject>(); // 存储筛选后的人员列表
private GameObject selectedPerson = null; // 当前选中的角色
@ -102,13 +103,14 @@ public class Panel : MonoBehaviour
//动态加载职责
public void DynamicLoadingDuty()
{
Debug.Log("||||||||||||||||||||||||||||"+ selectScenePanel.eventId);
foreach (var npcData in jsonReader1.npcDictionary)
{
string[] nameSections = npcData.Value.Name.Split('|');
foreach (var section in nameSections)
{
string[] sectionParts = section.Split(',');
//判断事件然后确定有哪些职责
if (int.Parse(sectionParts[0]) == 2001)
{
int key = int.Parse(sectionParts[1]);
@ -125,14 +127,10 @@ public class Panel : MonoBehaviour
dutuybutton.onClick.AddListener(() => OnPeopleItemClicked (item, Color.red, selectedDuty));
dutyItem.dutyNameText.text = npcData.Value.Note;
dutyItem.leader = npcData.Value.GroupLeader;
dutyItem.dutyId = npcData.Value.ID;
peopleList.Add(item);
}
}
//GameObject item = GameObject.Instantiate<GameObject>(dutyPrefab, dutyCount);
//DutyItem dutyItem = item.GetComponent<DutyItem>();
//dutyItem.dutyNameText.text = npcData.Value.Note;
//dutyItem.leader = npcData.Value.GroupLeader;
//peopleList.Add(item);// 将每个实例化的角色添加到列表中
}
}
@ -201,7 +199,6 @@ public class Panel : MonoBehaviour
GameObject managerPanelInstance = Instantiate(ManagerPanelPrefab, panelContent);
Button button = managerPanelInstance.GetComponent<Button>();
button.onClick.AddListener(() => managerPanel1.OnItemClicked(managerPanelInstance));
//ManagerPanel managerPanelScript = managerPanelInstance.GetComponentInParent<ManagerPanel>();
Text sceneText = managerPanelInstance.transform.Find("top/sceneName").GetComponent<Text>();
sceneText.text = sceneEntry.Key;
managerPanel1.CreateScenePanel(sceneEntry.Key, sceneEntry.Value, managerPanelInstance);
@ -254,11 +251,8 @@ public class Panel : MonoBehaviour
// 将当前选中的人员信息添加到对应场景的人员列表中
currentSceneInfo.Add(newSelectedInfo);
// 打印当前场景人员信息
//Debug.Log($"场景: {sceneName},选中的人员: {selectedInfo.name},职责: {selectedInfo.duty}");
// 禁用确认按钮并清空选择标志
sureBtn.interactable = false; // 禁用确认按钮
sureBtn.interactable = false;
isPersonSelected = false;
isDutySelected = false;
isSceneSelected = false;
@ -272,7 +266,6 @@ public class Panel : MonoBehaviour
Debug.LogError("请确保选择了人员、职责和场景!");
}
datePanel.NumberText.text = "共" + (sceneDataDictionary.Keys.Count * sceneDataDictionary.Values.Count).ToString() + "人参与";
// 可以在这里根据需求继续处理选中的数据
}
//处理界面关闭按钮
@ -311,7 +304,7 @@ public class Panel : MonoBehaviour
{
// 检测到点击了按钮
Button clickedButton = result.gameObject.GetComponent<Button>();
DutyItem item = clickedButton.GetComponentInParent<DutyItem>();
if (clickedButton != null)
{
Text buttonText = clickedButton.GetComponentInChildren<Text>();
@ -332,7 +325,7 @@ public class Panel : MonoBehaviour
else if (buttonText != null && buttonText.tag == Tags.duty) // 获取标签为职责的信息
{
duty = buttonText.text;
Debug.Log(duty);
dutyId = item.dutyId;
selectedInfo.duty = duty;
isDutySelected = true; // 选择了职责
}
@ -392,7 +385,7 @@ public class Panel : MonoBehaviour
public void OnPeopleItemClicked(GameObject clickedItem, Color color, GameObject select)
{
// 如果有之前选中的角色,重置其视觉效果
if (select != null)
if (select != null && select != clickedItem)
{
Text prevText = select.GetComponentInChildren<Text>();
if (prevText != null)
@ -403,7 +396,7 @@ public class Panel : MonoBehaviour
}
// 设置当前选中的角色为选中状态
select = clickedItem;
select = clickedItem; // 更新选中人物
Text personText = clickedItem.GetComponentInChildren<Text>();
if (personText != null)
{
@ -441,3 +434,4 @@ public class Panel : MonoBehaviour
}
}

View File

@ -9,6 +9,7 @@ public class DutyItem : MonoBehaviour
public Text dutyNameText;
public Button button;
public int leader;
public int dutyId;
public Color defaultColor = Color.white; // 默认颜色
public Color addedColor = Color.gray; // 已添加颜色
public Color selectedColor = Color.yellow; // 选中颜色

View File

@ -104,9 +104,6 @@ public class EvacuationPanel : MonoBehaviour
}
//private void Submit()
//{
// //int count = int.Parse(StuCountInputField.text);//×ÜÈËÊý
@ -298,9 +295,7 @@ public class EvacuationPanel : MonoBehaviour
CountsubmitBtn.onClick.AddListener(Countsubmit);
}
}
}
public void Countsubmit()
{
@ -329,9 +324,4 @@ public class EvacuationPanel : MonoBehaviour
classItemList.Add(classItem);
}
}
//Npc分配
public void NpcDistribution()
{
}
}

View File

@ -58,7 +58,6 @@ public class ManagerPanel : MonoBehaviour
// 实例化一个人员项并将其作为场景面板的子物体
GameObject item = Instantiate(personItemPrefab, contentTransform);
ArrangementItem arrangementItem = item.GetComponent<ArrangementItem>();
arrangementItem.name.text = person.name; // 设置姓名
arrangementItem.duty.text = person.duty; // 设置职责
}
@ -84,6 +83,7 @@ public class ManagerPanel : MonoBehaviour
// 使当前选中的项居中显示
//CenterOnItem(clickedItemRT);
}
// 使选中的项居中显示
private void CenterOnItem(RectTransform item)
{

View File

@ -157,10 +157,6 @@ public class SelectScenePanel : MonoBehaviour
// 将 Toggle 添加到 ToggleGroup 中
toggle.group = eventGroup;
toggle.isOn = false;
// 将 Toggle 添加到 schooltoggleList 中
// 将 SchoolInfo 对象添加到 schoolInfos 列表中
eventInfoList.Add(item);
Debug.Log("!!!!!!!!!!!!!!!!!!!!!" + eventInfoList.Count);
}