public void CheckAndExecuteSelectionCallback(NextDialogInfo info) { if (!selectionCallbackDict.ContainsKey(info.dialogId)) { Debug.LogError("no callback with id : " + info.dialogId); return; } if (!selectionCallbackDict[info.dialogId].ContainsKey(info.index)) { Debug.LogError("Error index : " + info.index); return; } selectionCallbackDict[info.dialogId][info.index]?.Invoke(); }
public void ParseDialogInfo() { JsonData jsonData = JsonMapper.ToObject(Resources.Load <TextAsset>("DialogData/DialogTest01").text); foreach (JsonData item in jsonData) { DialogInfo dialogInfo = new DialogInfo(); dialogInfo.id = (int)item["id"]; dialogInfo.name = item["name"].ToString(); dialogInfo.text = item["text"].ToString(); if ((string)item["faceImagePath"] != "") { string iconPath = (string)item["faceImagePath"]; dialogInfo.faceSprite = Resources.Load <Sprite>(iconPath); } dialogInfo.nextDialogList = new List <NextDialogInfo>(); //TODO var nextDialogData = item["nextDialog"]; if (nextDialogData.Count > 0) { for (int i = 0; i < nextDialogData.Count; i++) { NextDialogInfo dialogToIndex = new NextDialogInfo(); dialogToIndex.dialogId = dialogInfo.id; dialogToIndex.text = (string)nextDialogData[i]["text"]; dialogToIndex.id = (int)nextDialogData[i]["id"]; dialogToIndex.index = i; dialogInfo.nextDialogList.Add(dialogToIndex); } } dialogInfoDict.Add(dialogInfo.id, dialogInfo); } //Debug.Log("对话数据加载完成,一共加载了"+ dialogInfoDict.Count.ToString() + "个对话脚本"); }
public void SetContent(NextDialogInfo info) { curInfo = info; showText.text = info.text; }