public virtual void SetID(int id) { HUDPrefab = Resources.Load <GameObject>("HUDText"); HUDPanel = GameObject.FindGameObjectWithTag("Canvas").transform.Find("HUDPanel"); animator = GetComponent <Animator>(); ID = id; NPCinfo = NPCManager.Instance.GetNPCByID(ID); NPCManager.Instance.AddAliveNPCList(this); NPCManager.Instance.AddQuestNPCList(this); NPCtype = NPCinfo.NPCtype; GetAnimation(NPCinfo.Animation); if (NPCtype != NPCInfo.NPCType.Quest) { RandomMove(); } float randomTime = Random.Range(0, 3); InvokeRepeating("ShowHUDText", randomTime, 3); }
void ParseNPCsInfo() { TextAsset NPCText = Resources.Load <TextAsset>("Json/NPCsInfo"); string strNPCText = NPCText.text; JSONObject j = new JSONObject(strNPCText); foreach (JSONObject temp in j.list) { NPCInfo npcInfo = null; int id = (int)temp["id"].n; string name = temp["name"].str; string anim = temp["animation"].str; JSONObject j2 = temp["talktext"]; List <string> talktext = new List <string>(); foreach (JSONObject temp2 in j2.list) { int talkid = (int)temp2["talkid"].n; talktext.Add(TalkTextInfo[talkid]); } NPCInfo.NPCType type = (NPCInfo.NPCType)System.Enum.Parse(typeof(NPCInfo.NPCType), temp["type"].str); if (type == NPCInfo.NPCType.Normal) { npcInfo = new NPCInfo(id, name, anim, type, talktext); } else { JSONObject j3 = temp["hudtext"]; List <string> hudtext = new List <string>(); foreach (JSONObject temp3 in j3.list) { int hudtextid = (int)temp3["hudtextid"].n; hudtext.Add(HUDTextInfo[hudtextid]); } npcInfo = new NPCInfo(id, name, anim, type, talktext, hudtext); } NPCInfoList.Add(npcInfo); } }