Select表的添加和读取
This commit is contained in:
parent
d10d3775d8
commit
e170fc08c3
6216
xiaofang/Assets/Resources/JsonAsset/Select.json
Normal file
6216
xiaofang/Assets/Resources/JsonAsset/Select.json
Normal file
File diff suppressed because it is too large
Load Diff
7
xiaofang/Assets/Resources/JsonAsset/Select.json.meta
Normal file
7
xiaofang/Assets/Resources/JsonAsset/Select.json.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3efd15f4195557144a45659d2baa1ba3
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -18152,6 +18152,7 @@ MonoBehaviour:
|
|||||||
incidentSiteJosnFile: {fileID: 4900000, guid: 1efa4372b10d4294199638c49173ff4c, type: 3}
|
incidentSiteJosnFile: {fileID: 4900000, guid: 1efa4372b10d4294199638c49173ff4c, type: 3}
|
||||||
NPCJosnFile: {fileID: 4900000, guid: 41009f009f0718647a782c7e1aec97dd, type: 3}
|
NPCJosnFile: {fileID: 4900000, guid: 41009f009f0718647a782c7e1aec97dd, type: 3}
|
||||||
LanguageJsonFile: {fileID: 4900000, guid: 62a41129c4663ee41a06274114d28feb, type: 3}
|
LanguageJsonFile: {fileID: 4900000, guid: 62a41129c4663ee41a06274114d28feb, type: 3}
|
||||||
|
SelectJsonFile: {fileID: 4900000, guid: 3efd15f4195557144a45659d2baa1ba3, type: 3}
|
||||||
--- !u!1001 &1542437476
|
--- !u!1001 &1542437476
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using Google.Protobuf.WellKnownTypes;
|
||||||
|
|
||||||
public class JSONReader : MonoBehaviour
|
public class JSONReader : MonoBehaviour
|
||||||
{
|
{
|
||||||
@ -15,6 +16,7 @@ public class JSONReader : MonoBehaviour
|
|||||||
public TextAsset incidentSiteJosnFile;
|
public TextAsset incidentSiteJosnFile;
|
||||||
public TextAsset NPCJosnFile;
|
public TextAsset NPCJosnFile;
|
||||||
public TextAsset LanguageJsonFile;
|
public TextAsset LanguageJsonFile;
|
||||||
|
public TextAsset SelectJsonFile;
|
||||||
public Dictionary<int, NPCData> npcDictionary = new Dictionary<int, NPCData>();
|
public Dictionary<int, NPCData> npcDictionary = new Dictionary<int, NPCData>();
|
||||||
public Dictionary<int, LocationData> locationDictionary = new Dictionary<int, LocationData>();
|
public Dictionary<int, LocationData> locationDictionary = new Dictionary<int, LocationData>();
|
||||||
public Dictionary<int, EventData> eventDictionary = new Dictionary<int, EventData>();
|
public Dictionary<int, EventData> eventDictionary = new Dictionary<int, EventData>();
|
||||||
@ -23,6 +25,7 @@ public class JSONReader : MonoBehaviour
|
|||||||
public Dictionary<int, IncidentSite> incidentSiteDictionary = new Dictionary<int, IncidentSite>();
|
public Dictionary<int, IncidentSite> incidentSiteDictionary = new Dictionary<int, IncidentSite>();
|
||||||
public Dictionary<int, NPC> NPCDictionary = new Dictionary<int, NPC>();
|
public Dictionary<int, NPC> NPCDictionary = new Dictionary<int, NPC>();
|
||||||
public Dictionary<int, Language> LanguageDictionary = new Dictionary<int, Language>();
|
public Dictionary<int, Language> LanguageDictionary = new Dictionary<int, Language>();
|
||||||
|
private Dictionary<string, Select> SelectDictionary = new Dictionary<string, Select>();
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
@ -34,7 +37,10 @@ public class JSONReader : MonoBehaviour
|
|||||||
sceneDictionary = SceneParseJSON(sceneJsonFile.text);
|
sceneDictionary = SceneParseJSON(sceneJsonFile.text);
|
||||||
incidentSiteDictionary = IncidentSiteParseJSON(incidentSiteJosnFile.text);
|
incidentSiteDictionary = IncidentSiteParseJSON(incidentSiteJosnFile.text);
|
||||||
NPCDictionary = NPCParseJSON(incidentSiteJosnFile.text);
|
NPCDictionary = NPCParseJSON(incidentSiteJosnFile.text);
|
||||||
LanguageDictionary = LanguageParseJSON(LanguageJsonFile.text);
|
LanguageDictionary = LanguageParseJSON(LanguageJsonFile.text);
|
||||||
|
SelectDictionary = SelectJSON(SelectJsonFile.text);
|
||||||
|
|
||||||
|
|
||||||
GetLanguageByID(20008);
|
GetLanguageByID(20008);
|
||||||
foreach (var npc in sceneDictionary)
|
foreach (var npc in sceneDictionary)
|
||||||
{
|
{
|
||||||
@ -44,6 +50,20 @@ public class JSONReader : MonoBehaviour
|
|||||||
GetNpcDataByID(8001);
|
GetNpcDataByID(8001);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 解析 JSON 字符串为 Select 数据
|
||||||
|
public Dictionary<string, Select> SelectJSON(string json)
|
||||||
|
{
|
||||||
|
NPCData[] npcArray = JsonHelper.FromJson<NPCData>(json);
|
||||||
|
Dictionary<string, Select> selectDictionary = new Dictionary<string, Select>();
|
||||||
|
|
||||||
|
foreach (var npc in npcArray)
|
||||||
|
{
|
||||||
|
npcDictionary[npc.ID] = npc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectDictionary;
|
||||||
|
}
|
||||||
|
|
||||||
// ½âÎö JSON ×Ö·û´®Îª NPC Êý¾Ý
|
// ½âÎö JSON ×Ö·û´®Îª NPC Êý¾Ý
|
||||||
public Dictionary<int, NPCData> ParseJSON(string json)
|
public Dictionary<int, NPCData> ParseJSON(string json)
|
||||||
{
|
{
|
||||||
@ -380,3 +400,32 @@ public class Language
|
|||||||
public string Note;
|
public string Note;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class Select
|
||||||
|
{
|
||||||
|
public string ID;
|
||||||
|
public string Note;
|
||||||
|
public string PlayScript;
|
||||||
|
public string Group;
|
||||||
|
public string ShowText;
|
||||||
|
public string Icon;
|
||||||
|
public string Precondition;
|
||||||
|
public string Exclusive;
|
||||||
|
public string TakeTime;
|
||||||
|
public string TimeLimit;
|
||||||
|
public string NextSelect;
|
||||||
|
public string TaskLink;
|
||||||
|
public string TaskLinkDetails;
|
||||||
|
public string CallMode;
|
||||||
|
public string CallRecipient;
|
||||||
|
public string CorrectOption;
|
||||||
|
public string Reward;
|
||||||
|
public string Result;
|
||||||
|
public string Route;
|
||||||
|
public string TimingChange;
|
||||||
|
public string AppliedUI;
|
||||||
|
public string UIDetails;
|
||||||
|
public string Seq;
|
||||||
|
|
||||||
|
// 其他字段可根据需要添加
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user