数据串联

This commit is contained in:
lq 2024-12-01 22:36:41 +08:00
parent c28cca2d95
commit 44ea8baf75
6 changed files with 173 additions and 78 deletions

View File

@ -0,0 +1,12 @@
[
{
"ID": 2001,
"Note": "厨房起火",
"Name": 2001,
"Scene": 9003,
"Position": "36,1,2",
"Volume": -1,
"Difficulty": "1|2|6",
"SpecialEvent": "-1,-1,-1,-1|1,50,10,20|1,50,20,20"
}
]

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1efa4372b10d4294199638c49173ff4c
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -2243,6 +2243,7 @@ MonoBehaviour:
scene:
managerPanel1: {fileID: 617308873}
jsonReader1: {fileID: 1417128757}
selectScenePanel: {fileID: 1138062886}
--- !u!1 &625672672
GameObject:
m_ObjectHideFlags: 0
@ -2372,6 +2373,17 @@ RectTransform:
m_CorrespondingSourceObject: {fileID: 6740850324693622956, guid: a15ee694d5f79864d816998fae77116d, type: 3}
m_PrefabInstance: {fileID: 1677529559}
m_PrefabAsset: {fileID: 0}
--- !u!114 &654779790 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 7468736064578063281, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
m_PrefabInstance: {fileID: 865567720}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &666058189
GameObject:
m_ObjectHideFlags: 0
@ -2501,7 +2513,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: 0, y: 0}
m_SizeDelta: {x: 388.1544, y: 58.599}
m_Pivot: {x: 0, y: 1}
--- !u!114 &667280288
MonoBehaviour:
@ -5650,6 +5662,10 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 618256459}
m_Modifications:
- target: {fileID: 7468736063766935910, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: title
value:
objectReference: {fileID: 654779790}
- target: {fileID: 7468736063766935910, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: MainPanel
value:
@ -5728,11 +5744,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7468736063766935915, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_SizeDelta.x
value: 1834
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736063766935915, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_SizeDelta.y
value: 1577.3936
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736063766935915, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_LocalPosition.x
@ -5788,39 +5804,39 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7468736063766935916, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7468736063812420174, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736063812420174, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7468736063812420174, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736063812420174, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchoredPosition.x
value: 543.7644
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736063812420174, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -55
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736063881909988, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736063881909988, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736063881909988, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchoredPosition.x
value: 917
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736063881909988, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -53.335
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736064052287372, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: eventName
@ -5854,6 +5870,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:
@ -5880,12 +5900,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
@ -5912,51 +5936,51 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7468736064250338014, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736064250338014, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736064250338014, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchoredPosition.x
value: 917
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736064250338014, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -343.34674
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736064349377664, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736064349377664, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736064349377664, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchoredPosition.x
value: 334.1322
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736064349377664, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -55
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736064407837105, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736064407837105, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736064407837105, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchoredPosition.x
value: 753.3966
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736064407837105, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -55
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736064424568481, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
@ -6020,7 +6044,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7468736064580561832, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_SizeDelta.x
value: -1792
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736065055436938, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMax.y
@ -6044,35 +6068,35 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7468736065668749935, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736065668749935, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736065668749935, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchoredPosition.x
value: 124.5
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736065668749935, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -55
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736065685524838, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMax.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736065685524838, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchorMin.y
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736065685524838, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchoredPosition.x
value: 917
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736065685524838, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_AnchoredPosition.y
value: -1328.051
value: 0
objectReference: {fileID: 0}
- target: {fileID: 7468736065685524839, guid: 90919b88a71f0054bb1cf84429cb3a1e, type: 3}
propertyPath: m_IsActive
@ -8729,6 +8753,7 @@ MonoBehaviour:
eventJsonFile: {fileID: 4900000, guid: 2ef075e4830019a42b84d8d05d13d81c, type: 3}
matialJsonFile: {fileID: 4900000, guid: d98cb351d1a87dc4887a37106b9745d4, type: 3}
sceneJsonFile: {fileID: 4900000, guid: 06c09fd1c8b0a0a45951a1065189d922, type: 3}
incidentSiteJosnFile: {fileID: 4900000, guid: 1efa4372b10d4294199638c49173ff4c, type: 3}
--- !u!4 &1417128758
Transform:
m_ObjectHideFlags: 0
@ -9548,7 +9573,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &1600693806
RectTransform:
m_ObjectHideFlags: 0

View File

@ -9,11 +9,13 @@ public class JSONReader : MonoBehaviour
public TextAsset eventJsonFile;
public TextAsset matialJsonFile;
public TextAsset sceneJsonFile;
public TextAsset incidentSiteJosnFile;
public Dictionary<int, NPCData> npcDictionary = new Dictionary<int, NPCData>();
public Dictionary<int, LocationData> locationDictionary = new Dictionary<int, LocationData>();
public Dictionary<int, EventData> eventDictionary = new Dictionary<int, EventData>();
public Dictionary<int, MatialData> matialDictionary = new Dictionary<int, MatialData>();
public Dictionary<int, SceneData> sceneDictionary = new Dictionary<int, SceneData>();
public Dictionary<int, IncidentSite> incidentSiteDictionary = new Dictionary<int, IncidentSite>();
void Awake()
{
@ -23,16 +25,11 @@ public class JSONReader : MonoBehaviour
eventDictionary = EventParseJSON(eventJsonFile.text);
matialDictionary = MatialParseJSON(matialJsonFile.text);
sceneDictionary = SceneParseJSON(sceneJsonFile.text);
foreach (var npc in sceneDictionary)
incidentSiteDictionary = IncidentSiteParseJSON(incidentSiteJosnFile.text);
foreach (var npc in locationDictionary)
{
Debug.Log($"Scene ID: {npc.Value.ID}");
Debug.Log($"Scene Name: {npc.Value.Name}");
Debug.Log($"Scene Type: {npc.Value.Type}");
Debug.Log($"Incident Type: {npc.Value.IncidentType}");
Debug.Log($"Object List: {npc.Value.ObjList}");
Debug.Log($"Area List: {npc.Value.AreaList}");
Debug.Log($"Storeroom: {npc.Value.Storeroom}");
Debug.Log("===========================");
//.Log($"Scene ID: {npc.Value.ID}");
//Debug.Log("===========================");
}
//´òÓ¡ NPC Êý¾Ý
@ -109,6 +106,19 @@ public class JSONReader : MonoBehaviour
return locationDictionary;
}
public Dictionary<int, IncidentSite> IncidentSiteParseJSON(string json)
{
IncidentSite[] locationArray = JsonHelper.FromJson<IncidentSite>(json);
Dictionary<int, IncidentSite> locationDictionary = new Dictionary<int, IncidentSite>();
foreach (var location in locationArray)
{
locationDictionary[location.ID] = location;
}
return locationDictionary;
}
// ´òÓ¡ NPC Êý¾Ý
//void PrintNPCData(Dictionary<int, NPCData> npcDictionary)
//{
@ -232,5 +242,17 @@ public class SceneData
public string AreaList;
public int Storeroom;
}
[System.Serializable]
public class IncidentSite
{
public int ID;
public string Note;
public int Name;
public int Scene;
public string Position;
public int Volume;
public string Difficulty;
public string SpecialEvent;
}

View File

@ -57,6 +57,7 @@ public class Panel : MonoBehaviour
public Dictionary<string, List<SelectedInfo>> sceneDataDictionary = new Dictionary<string, List<SelectedInfo>>();//不同的场景存取不同的人员数据
public ManagerPanel managerPanel1;
public JSONReader jsonReader1;
public SelectScenePanel selectScenePanel;
private bool isPersonSelected = false; // 标志是否选择了人员
private bool isDutySelected = false; // 标志是否选择了职责
private bool isSceneSelected = false; // 标志是否选择了场景
@ -93,14 +94,37 @@ public class Panel : MonoBehaviour
//动态加载职责
public void DynamicLoadingDuty()
{
Debug.Log("||||||||||||||||||||||||||||"+ selectScenePanel.eventId);
foreach (var npcData in jsonReader1.npcDictionary)
{
GameObject item = GameObject.Instantiate<GameObject>(dutyPrefab, dutyCount);
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]);
if (jsonReader1.npcDictionary.ContainsKey(key))
{
var npcInfo = jsonReader1.npcDictionary[key];
// 在此处可以使用npcInfo做进一步的处理
Debug.Log("Found NPC: " + npcInfo.Name);
// 创建DutyItem实例
GameObject item = GameObject.Instantiate(dutyPrefab, dutyCount);
DutyItem dutyItem = item.GetComponent<DutyItem>();
dutyItem.dutyNameText.text = npcData.Value.Note;
dutyItem.leader = npcData.Value.GroupLeader;
//Debug.Log("$$$$$$$$$$$$$$" + dutyItem.dutyNameText.text);
peopleList.Add(item);// 将每个实例化的角色添加到列表中
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);// 将每个实例化的角色添加到列表中
}
}
}

View File

@ -52,7 +52,7 @@ public class SelectScenePanel : MonoBehaviour
eventChoiceLable.gameObject.SetActive(false);
InstantiateScenePrefab();
InstantiateSchoolPrefab();
InstantiateIncidentPrefab();
InstantiateIncidentPrefab(2001);
SetEventToggleOpenorClose(eventInfoList);
continueBtn.onClick.AddListener(OnClickContinueBtn);
SetFirstChoise(toggleList);
@ -140,12 +140,12 @@ public class SelectScenePanel : MonoBehaviour
}
//动态加载事件选择预制体
public void InstantiateIncidentPrefab()
public void InstantiateIncidentPrefab(int eventId)
{
foreach(var eventData in jsonReader.eventDictionary)
foreach (var eventData in jsonReader.incidentSiteDictionary)
{
if(eventData.Key==eventId)
{
GameObject slot = GameObject.Instantiate<GameObject>(eventPrefab, eventList);
EventInfo item = slot.GetComponent<EventInfo>();
item.eventName.text = eventData.Value.Note;
@ -155,7 +155,7 @@ public class SelectScenePanel : MonoBehaviour
if (toggle != null)
{
// 将 Toggle 添加到 ToggleGroup 中
toggle.group = schoolGroup;
toggle.group = eventGroup;
toggle.isOn = false;
// 将 Toggle 添加到 schooltoggleList 中
@ -165,6 +165,11 @@ public class SelectScenePanel : MonoBehaviour
Debug.Log("!!!!!!!!!!!!!!!!!!!!!" + eventInfoList.Count);
}
}
else
{
break;
}
}
}
//点击继续按钮后更换场景图片及名称