/// <summary> /// /// </summary> /// <param name="type"></param> /// <param name="dType"></param> /// <param name="strName"></param> /// <param name="dialogContent"></param> private object[] DisplayDialogInfo(DialogType type, DialogTalkType dType, string strName, string dialogContent, bool isLastDialog) { object[] dialogInfo = new object[3]; dialogInfo[2] = isLastDialog; switch (type) { case DialogType.None: break; case DialogType.DoubleTalk: if (!string.IsNullOrEmpty(strName) && !string.IsNullOrEmpty(dialogContent)) { if (dType == DialogTalkType.Player) { //显示玩家文本 dialogInfo[0] = "Player"; } else { //显示其他人名称 dialogInfo[0] = "NPC"; } } //双人对话内容--- dialogInfo[1] = dialogContent; //确定显示精灵----暂时不考虑 switch (dType) { case DialogTalkType.None: break; case DialogTalkType.Player: //彩色显示 //黑白显示 break; case DialogTalkType.Guid: break; case DialogTalkType.NPC: //显示NPC部分 break; default: break; } break; case DialogType.SingTalk: break; default: break; } Debug.Log(dialogInfo[0]); Debug.Log(dialogInfo[1]); // Debug.Log(dialogInfo[2]); return(dialogInfo); }
/// <summary> /// 获取对话信息 /// </summary> /// <param name="dialogNum"></param> /// <param name="type"></param> /// <param name="strName"></param> /// <param name="dialogContent"></param> /// <returns></returns> private void GetDialogInfoReconder(int dialogNum, out DialogTalkType type, out string strName, out string dialogContent) { type = DialogTalkType.Player; string dialoType = "[GetNexDialogInfoRecoder/type]"; strName = "[GetNexDialogInfoRecoder/strName]"; dialogContent = "[GetNexDialogInfoRecoder/dialogContent]"; // 定位出错的地方 //如果缓存段落的内容为空的 if (cacheList == null || cacheList.Count <= 0) { if (xmlList != null && xmlList.Count > 0)//当前缓存不存在的时候,把当前xml中的list加入缓存jihe { for (int i = 0; i < xmlList.Count; i++) { if (xmlList[i].DialogSecNum == dialogNum) { cacheList.Add(xmlList[i]); } } } } if (cacheList != null && cacheList.Count > 0) { if (cacheList[indexByDialogNum].DialogSecNum == dialogNum) { dialoType = cacheList[indexByDialogNum].DialogSide; if (dialoType.Trim().Equals("Hero")) { type = DialogTalkType.Player; } else if (dialoType.Trim().Equals("NPC")) { type = DialogTalkType.NPC; } strName = cacheList[indexByDialogNum].DialogPerson; dialogContent = cacheList[indexByDialogNum].DialogContent; } }//end if }
/// <summary> /// 获的下一条对话记录 /// </summary> /// <param name="dialogNum">对话编号</param> /// <param name="type">对话人</param> /// <param name="strName">人名</param> /// <param name="dialogContent">对话内容</param> /// <returns>对话是否返回了数据</returns> public bool GetNextDialogInfoRecoder(int dialogNum, out DialogTalkType type, out string strName, out string dialogContent, out bool isLastDialog) { type = DialogTalkType.Player; strName = "[GetNexDialogInfoRecoder/strName]"; dialogContent = "[GetNexDialogInfoRecoder/dialogContent]"; // 定位出错的地方 //输入的段落编号必须默认不为0 if (dialogNum <= 0) { isLastDialog = false; return(false); } //设置下一个对话内容 if (dialogNum != this.currentContentNum) //换下一段对话 { indexByDialogNum = 0; // 内部序号值 cacheList.Clear(); //上一对话段落内容清空 currentContentNum = dialogNum; //当前对话内容编号 } if (cacheList != null && cacheList.Count > 0) // 当前对话段落里存在对话 { if (indexByDialogNum < cacheList.Count - 1) { //当前内容编号增加 indexByDialogNum++; } else { indexByDialogNum = 0; cacheList.Clear(); isLastDialog = true; return(true); //当前序号在段落集合中 } } GetDialogInfoReconder(dialogNum, out type, out strName, out dialogContent); isLastDialog = false; return(true); }
/// <summary> /// 显示下条信息 /// </summary> /// <param name="type"></param> /// <param name="dialogNum"></param> /// <returns></returns> public object[] DiaplayNextDiaLog(DialogType type, int dialogNum) { bool isDialogEnd = false; //对话开始 DialogTalkType dType = DialogTalkType.None; string strName; string dialogContent; bool isLastDialog = false; //切换说话方 ChangeDialogType(type); //得到会话信息 bool flag = DialogDataMgr.GetInstance().GetNextDialogInfoRecoder(dialogNum, out dType, out strName, out dialogContent, out isLastDialog); if (flag) { //返回对话信息 return(DisplayDialogInfo(type, dType, strName, dialogContent, isLastDialog)); } else { isDialogEnd = true; return(null); } }