/// <summary> /// 单例的抓取 /// </summary> /// <returns></returns> public static SaveTalkTxt GetInstance() { if (instance == null) { instance = new SaveTalkTxt(); return(instance); } return(instance); }
/// <summary> /// 根据npc当前的状态获取到对应的文本 /// </summary> /// <param name="npcState"> npc状态</param> /// <param name="ID">npcID</param> /// <param name="talkSystem">对话系统示例</param> public void GetTxt(NpcState npcState, int ID, TalkSystem talkSystem) { talkSystem.InitTalk(); path = Application.streamingAssetsPath + "/TalkTxt/" + ID + "/" + npcState + "/1.json"; showTxts = JsonMapper.ToObject <ShowTxt[]>(JsonMapper.ToJson(JsonReader.ReadJson(path)["ShowTxt"])); for (int i = 0; i < showTxts.Length; i++) { SaveTalkTxt.GetInstance().dic.Add(i + 1, showTxts[i]); } }