diff --git a/xiaofang/Assets/HYLjson.meta b/xiaofang/Assets/HYLjson.meta new file mode 100644 index 00000000..78e0d80a --- /dev/null +++ b/xiaofang/Assets/HYLjson.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 905fe61b66262644c914cba2ae456956 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/xiaofang/Assets/HYLjson/NPC.json b/xiaofang/Assets/HYLjson/NPC.json new file mode 100644 index 00000000..76a93f1c --- /dev/null +++ b/xiaofang/Assets/HYLjson/NPC.json @@ -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" + } +] \ No newline at end of file diff --git a/xiaofang/Assets/HYLjson/NPC.json.meta b/xiaofang/Assets/HYLjson/NPC.json.meta new file mode 100644 index 00000000..fddae36f --- /dev/null +++ b/xiaofang/Assets/HYLjson/NPC.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 41009f009f0718647a782c7e1aec97dd +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/xiaofang/Assets/Scenes/Schedule_03333333333.unity b/xiaofang/Assets/Scenes/Schedule_03333333333.unity index 13ff75d2..5751bc3a 100644 --- a/xiaofang/Assets/Scenes/Schedule_03333333333.unity +++ b/xiaofang/Assets/Scenes/Schedule_03333333333.unity @@ -2243,6 +2243,7 @@ MonoBehaviour: scene: managerPanel1: {fileID: 617308873} jsonReader1: {fileID: 1417128757} + selectScenePanel: {fileID: 0} --- !u!1 &625672672 GameObject: m_ObjectHideFlags: 0 @@ -8744,6 +8745,8 @@ 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} + NPCJosnFile: {fileID: 4900000, guid: 41009f009f0718647a782c7e1aec97dd, type: 3} --- !u!4 &1417128758 Transform: m_ObjectHideFlags: 0 diff --git a/xiaofang/Assets/Script/JSONReader/JSONReader.cs b/xiaofang/Assets/Script/JSONReader/JSONReader.cs index 41e6ca2f..c869cd3f 100644 --- a/xiaofang/Assets/Script/JSONReader/JSONReader.cs +++ b/xiaofang/Assets/Script/JSONReader/JSONReader.cs @@ -10,12 +10,14 @@ public class JSONReader : MonoBehaviour public TextAsset matialJsonFile; public TextAsset sceneJsonFile; public TextAsset incidentSiteJosnFile; + public TextAsset NPCJosnFile; public Dictionary npcDictionary = new Dictionary(); public Dictionary locationDictionary = new Dictionary(); public Dictionary eventDictionary = new Dictionary(); public Dictionary matialDictionary = new Dictionary(); public Dictionary sceneDictionary = new Dictionary(); public Dictionary incidentSiteDictionary = new Dictionary(); + public Dictionary NPCDictionary = new Dictionary(); void Awake() { @@ -26,6 +28,7 @@ public class JSONReader : MonoBehaviour matialDictionary = MatialParseJSON(matialJsonFile.text); sceneDictionary = SceneParseJSON(sceneJsonFile.text); incidentSiteDictionary = IncidentSiteParseJSON(incidentSiteJosnFile.text); + NPCDictionary = NPCParseJSON(incidentSiteJosnFile.text); foreach (var npc in locationDictionary) { //.Log($"Scene ID: {npc.Value.ID}"); @@ -118,6 +121,18 @@ public class JSONReader : MonoBehaviour return locationDictionary; } + public Dictionary NPCParseJSON(string json) + { + NPC[] locationArray = JsonHelper.FromJson(json); + Dictionary locationDictionary = new Dictionary(); + + foreach (var location in locationArray) + { + locationDictionary[location.ID] = location; + } + + return locationDictionary; + } // ӡ NPC //void PrintNPCData(Dictionary npcDictionary) @@ -255,4 +270,18 @@ public class IncidentSite 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; +}