json文件接入
This commit is contained in:
parent
44ea8baf75
commit
ffffa196a4
8
xiaofang/Assets/HYLjson.meta
Normal file
8
xiaofang/Assets/HYLjson.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 905fe61b66262644c914cba2ae456956
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
28
xiaofang/Assets/HYLjson/NPC.json
Normal file
28
xiaofang/Assets/HYLjson/NPC.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"ID": "6001",
|
||||||
|
"Note": "小学生",
|
||||||
|
"Name": "6001",
|
||||||
|
"PlayScript": "5001,0",
|
||||||
|
"ResPath": "Path1001",
|
||||||
|
"State1": "1",
|
||||||
|
"StateRes1": "Path1002|Path1003",
|
||||||
|
"State2": "2",
|
||||||
|
"StateRes2": "Path1004|Path1005",
|
||||||
|
"Stats1": "10,1.3|11,100",
|
||||||
|
"Stats2": "2,12,50|3,12,50|6,12,55"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ID": "6002",
|
||||||
|
"Note": "外部增援NPC",
|
||||||
|
"Name": "6002",
|
||||||
|
"PlayScript": "5001,1",
|
||||||
|
"ResPath": "Path2",
|
||||||
|
"State1": "-1",
|
||||||
|
"StateRes1": "-1",
|
||||||
|
"State2": "-1",
|
||||||
|
"StateRes2": "-1",
|
||||||
|
"Stats1": "-1",
|
||||||
|
"Stats2": "-1"
|
||||||
|
}
|
||||||
|
]
|
7
xiaofang/Assets/HYLjson/NPC.json.meta
Normal file
7
xiaofang/Assets/HYLjson/NPC.json.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 41009f009f0718647a782c7e1aec97dd
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -2243,6 +2243,7 @@ MonoBehaviour:
|
|||||||
scene:
|
scene:
|
||||||
managerPanel1: {fileID: 617308873}
|
managerPanel1: {fileID: 617308873}
|
||||||
jsonReader1: {fileID: 1417128757}
|
jsonReader1: {fileID: 1417128757}
|
||||||
|
selectScenePanel: {fileID: 0}
|
||||||
--- !u!1 &625672672
|
--- !u!1 &625672672
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -8744,6 +8745,8 @@ MonoBehaviour:
|
|||||||
eventJsonFile: {fileID: 4900000, guid: 2ef075e4830019a42b84d8d05d13d81c, type: 3}
|
eventJsonFile: {fileID: 4900000, guid: 2ef075e4830019a42b84d8d05d13d81c, type: 3}
|
||||||
matialJsonFile: {fileID: 4900000, guid: d98cb351d1a87dc4887a37106b9745d4, type: 3}
|
matialJsonFile: {fileID: 4900000, guid: d98cb351d1a87dc4887a37106b9745d4, type: 3}
|
||||||
sceneJsonFile: {fileID: 4900000, guid: 06c09fd1c8b0a0a45951a1065189d922, type: 3}
|
sceneJsonFile: {fileID: 4900000, guid: 06c09fd1c8b0a0a45951a1065189d922, type: 3}
|
||||||
|
incidentSiteJosnFile: {fileID: 4900000, guid: 1efa4372b10d4294199638c49173ff4c, type: 3}
|
||||||
|
NPCJosnFile: {fileID: 4900000, guid: 41009f009f0718647a782c7e1aec97dd, type: 3}
|
||||||
--- !u!4 &1417128758
|
--- !u!4 &1417128758
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -10,12 +10,14 @@ public class JSONReader : MonoBehaviour
|
|||||||
public TextAsset matialJsonFile;
|
public TextAsset matialJsonFile;
|
||||||
public TextAsset sceneJsonFile;
|
public TextAsset sceneJsonFile;
|
||||||
public TextAsset incidentSiteJosnFile;
|
public TextAsset incidentSiteJosnFile;
|
||||||
|
public TextAsset NPCJosnFile;
|
||||||
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>();
|
||||||
public Dictionary<int, MatialData> matialDictionary = new Dictionary<int, MatialData>();
|
public Dictionary<int, MatialData> matialDictionary = new Dictionary<int, MatialData>();
|
||||||
public Dictionary<int, SceneData> sceneDictionary = new Dictionary<int, SceneData>();
|
public Dictionary<int, SceneData> sceneDictionary = new Dictionary<int, SceneData>();
|
||||||
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>();
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
@ -26,6 +28,7 @@ public class JSONReader : MonoBehaviour
|
|||||||
matialDictionary = MatialParseJSON(matialJsonFile.text);
|
matialDictionary = MatialParseJSON(matialJsonFile.text);
|
||||||
sceneDictionary = SceneParseJSON(sceneJsonFile.text);
|
sceneDictionary = SceneParseJSON(sceneJsonFile.text);
|
||||||
incidentSiteDictionary = IncidentSiteParseJSON(incidentSiteJosnFile.text);
|
incidentSiteDictionary = IncidentSiteParseJSON(incidentSiteJosnFile.text);
|
||||||
|
NPCDictionary = NPCParseJSON(incidentSiteJosnFile.text);
|
||||||
foreach (var npc in locationDictionary)
|
foreach (var npc in locationDictionary)
|
||||||
{
|
{
|
||||||
//.Log($"Scene ID: {npc.Value.ID}");
|
//.Log($"Scene ID: {npc.Value.ID}");
|
||||||
@ -118,6 +121,18 @@ public class JSONReader : MonoBehaviour
|
|||||||
|
|
||||||
return locationDictionary;
|
return locationDictionary;
|
||||||
}
|
}
|
||||||
|
public Dictionary<int, NPC> NPCParseJSON(string json)
|
||||||
|
{
|
||||||
|
NPC[] locationArray = JsonHelper.FromJson<NPC>(json);
|
||||||
|
Dictionary<int, NPC> locationDictionary = new Dictionary<int, NPC>();
|
||||||
|
|
||||||
|
foreach (var location in locationArray)
|
||||||
|
{
|
||||||
|
locationDictionary[location.ID] = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
return locationDictionary;
|
||||||
|
}
|
||||||
|
|
||||||
// ´òÓ¡ NPC Êý¾Ý
|
// ´òÓ¡ NPC Êý¾Ý
|
||||||
//void PrintNPCData(Dictionary<int, NPCData> npcDictionary)
|
//void PrintNPCData(Dictionary<int, NPCData> npcDictionary)
|
||||||
@ -255,4 +270,18 @@ public class IncidentSite
|
|||||||
public string SpecialEvent;
|
public string SpecialEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class NPC
|
||||||
|
{
|
||||||
|
public int ID;
|
||||||
|
public string Note;
|
||||||
|
public string Name;
|
||||||
|
public string PlayScript;
|
||||||
|
public string ResPath;
|
||||||
|
public string State1;
|
||||||
|
public string StateRes1;
|
||||||
|
public string State2;
|
||||||
|
public string StateRes2;
|
||||||
|
public string Stats1;
|
||||||
|
public string Stats2;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user