示例#1
0
        /// <summary>
        /// 得到并展示下一条对话信息
        /// </summary>
        public void DisplayNextDialogInfo()
        {
            DialogSide diaSide = DialogSide.None;
            string     strDialogPerson;
            string     strDialogContent;

            bool boolResult = DialogDataMgr.GetInstance().GetNextDialogInfoRecoder(1, out diaSide, out strDialogPerson, out strDialogContent);

            if (boolResult)
            {
                switch (diaSide)
                {
                case DialogSide.None:
                    break;

                case DialogSide.HeroSide:
                    Txt_Side.text = "英雄";
                    break;

                case DialogSide.NPCSide:
                    Txt_Side.text = "NPC";
                    break;

                default:
                    break;
                }
                Txt_Person.text  = strDialogPerson;
                Txt_Content.text = strDialogContent;
            }
            else
            {
                Txt_Content.text = "没有输出数据了";
            }
            Log.SyncLogArrayToFile();
        }
示例#2
0
        /// <summary>
        /// 公共方法:显示下一条对话,返回真表示对话结束
        /// </summary>
        /// <param name="diaType"></param>
        /// <param name="SectionNum"></param>
        /// <returns>
        /// true: 对话结束
        /// </returns>
        public bool DisplayNextDialog(DialogType diaType, int SectionNum)
        {
            bool       isDialogEnd = false;           //会话是否结束
            DialogSide diaSide     = DialogSide.None; //正在说话的一方
            string     strPerson;                     //讲述者
            string     strContent;                    //对话内容


            //切换(选择)对话类型
            ChangeDialogType(diaType);

            //得到会话信息(数据)
            bool flag = DialogDataMgr.GetInstance().GetNextDialogInfoRecoder(SectionNum, out diaSide, out strPerson, out strContent);

            if (flag)
            {
                //显示对话信息
                DisplayDialogInfo(diaType, diaSide, strPerson, strContent);
            }
            else
            {
                //对话结束(没有对话信息了)
                isDialogEnd = true;
            }

            return(isDialogEnd);
        }
示例#3
0
        /// <summary>
        /// showing dialog info
        /// </summary>
        /// <param name="diaType">dialog type</param>
        /// <param name="dialogSide">dialog side</param>
        /// <param name="strPersonName">person name</param>
        /// <param name="strDialogContent">dialog content</param>
        private void DisplayDialogInfo(DialogType diaType, DialogSide diaSide, string PersonName, string DialogContent)
        {
            switch (diaType)
            {
            case DialogType.None:
                break;

            case DialogType.DoubleDialogs:
                //showing person name and dialog content
                if (!string.IsNullOrEmpty(PersonName) && !string.IsNullOrEmpty(DialogContent))
                {
                    if (diaSide == DialogSide.PlayerSide)
                    {
                        TxtPersonName.text = GlobalParaMgr.PlayerName;
                    }
                    else
                    {
                        TxtPersonName.text = PersonName;
                    }
                    TxtDoubleDialogContent.text = DialogContent;
                }

                //showing sprites(Player and NPC)
                switch (diaSide)
                {
                case DialogSide.None:
                    break;

                case DialogSide.PlayerSide:
                    goPlayer.GetComponent <Image>().overrideSprite    = SprPlayer[0];          //0 showing color image
                    goNPC_Right.GetComponent <Image>().overrideSprite = SprNPC_Right[1];       //1 showing black and white image
                    break;

                case DialogSide.NPCSide:
                    goPlayer.GetComponent <Image>().overrideSprite    = SprPlayer[1];          //0 showing color image
                    goNPC_Right.GetComponent <Image>().overrideSprite = SprNPC_Right[0];       // 1 showing black and white image
                    break;

                default:
                    break;
                }
                break;

            case DialogType.SingleDialogs:
                //showing peroson name and dialog content
                TxtSingleDialogContent.text = DialogContent;
                //showing sprite
                goNPC_Left.GetComponent <Image>().overrideSprite = SprNPC_Left[0];
                break;

            default:
                break;
            }
        }
示例#4
0
        /// <summary>
        /// 显示对话信息
        /// </summary>
        /// <param name="diaType">对话类型(单人/双人)</param>
        /// <param name="diaSide">对话双方</param>
        /// <param name="strPerson">对话人名</param>
        /// <param name="strContent">对话内容</param>
        private void DisplayDialogInfo(DialogType diaType, DialogSide diaSide, string strPerson, string strContent)
        {
            switch (diaType)
            {
            case DialogType.None:
                break;

            case DialogType.Single:
                //显示人名
                //if (!string.IsNullOrEmpty(strPerson) && !string.IsNullOrEmpty(strContent)) {
                //Txt_PersonName.text = strPerson;
                Txt_SingleDialogContent.text = strContent;
                //}
                break;

            case DialogType.Double:
                //显示人名,对话信息
                if (!string.IsNullOrEmpty(strPerson) && !string.IsNullOrEmpty(strContent))
                {
                    //Modify:使英雄的名字正确显示
                    if (diaSide == DialogSide.HeroSide)
                    {
                        Txt_PersonName.text = GlobalParaMgr.PlayerName;
                    }
                    Txt_PersonName.text          = strPerson;
                    Txt_DoubleDialogContent.text = strContent;
                }

                //确定显示精灵(彩色为正在说话者,灰色为旁听者)
                switch (diaSide)
                {
                case DialogSide.None:
                    break;

                case DialogSide.HeroSide:
                    goHero.GetComponent <Image>().overrideSprite      = Spr_Hero[0];                                      //0表示彩色
                    goNPC_Right.GetComponent <Image>().overrideSprite = Spr_NPC_Right[1];                                 //1表示黑白
                    break;

                case DialogSide.NPCSide:
                    goHero.GetComponent <Image>().overrideSprite      = Spr_Hero[1];                                  //1表示彩色
                    goNPC_Right.GetComponent <Image>().overrideSprite = Spr_NPC_Right[0];                             //0表示黑白
                    break;

                default:
                    break;
                }
                break;

            default:
                break;
            }
        }
示例#5
0
        /// <summary>
        /// 得到下一条对话记录
        /// </summary>
        /// <param name="diaSectionNum">输入:段落编号</param>
        /// <param name="diaSide">输出:对话方</param>
        /// <param name="diaPerson">输出:对话人名</param>
        /// <param name="diaContent">输出:对话内容</param>
        /// <returns>true: 输出了合法的对话数据</returns>
        public bool GetNextDialogInfoRecoder(int diaSectionNum, out DialogSide diaSide, out string diaPerson, out string diaContent)
        {
            //显示默认内容
            diaSide    = DialogSide.None;
            diaPerson  = "[GetNextDialogInfoRecoder()/diaPerson]";
            diaContent = "[GetNextDialogInfoRecoder()/diaContent]";

            //输出参数检查
            if (diaSectionNum < 0)
            {
                return(false);
            }
            //段落编号增大后,需要保留上一个“对话段落编号”,以方便后续逻辑处理
            //###改进### 只要是不相等。这样可以乱序访问

            if (diaSectionNum != _OriginalDialogSectionNum)
            {
                //重置“内部序号”(后续应该会执行一个自加操作)
                _IntIndexByDialogSection = 0;
                //清空“对话缓存”(已经是下一个了)
                _CurDialogCacheArray.Clear();
                //把当前的段落编号记录下来(不一定非要是连续的段落编号)
                _OriginalDialogSectionNum = diaSectionNum;
            }

            //如果当前缓存不为空
            if (_CurDialogCacheArray != null && _CurDialogCacheArray.Count > 0)
            {
                if (_IntIndexByDialogSection < _CurDialogCacheArray.Count)
                {
                    ++_IntIndexByDialogSection;                     //自增索引
                }
                else
                {
                    return(false);
                }
            }

            //如果当前缓存为空
            else
            {
                ++_IntIndexByDialogSection;                     //自增索引
            }

            //得到对话信息
            bool isEnd = GetDialogInfoRecoder(diaSectionNum, out diaSide, out diaPerson, out diaContent);

            return(isEnd);
        }
示例#6
0
        }//LoadAllDialogData_end

        /// <summary>
        /// get next dialog
        /// </summary>
        /// <param name="diaSectionNum">section number</param>
        /// <param name="dialogSide">left side of right side(showing charater icon)</param>
        /// <param name="strPersonName">character's name</param>
        /// <param name="strDialogContent">dialog content</param>
        /// <returns></returns>
        public bool GetNextDialogInfoRecoder(int diaSectionNum, out DialogSide dialogSide, out string strPersonName, out string strDialogContent)
        {
            dialogSide = DialogSide.None;

            strPersonName    = "[GetNextDialogInfoRecoder()/strPersonName]";
            strDialogContent = "[GetNextDialogInfoRecoder()/strDialogContent]";
            //input data check
            if (diaSectionNum < 0)
            {
                return(false);
            }

            //reset int Index By Dialog Section
            if (diaSectionNum != _OriginalDialogSectionNum)
            {
                _IntIndexByDialogSection = 0;

                _CurrentDialogBufferArray.Clear();

                _OriginalDialogSectionNum = diaSectionNum;
            }
            //if array isnt empty
            if (_CurrentDialogBufferArray != null && _CurrentDialogBufferArray.Count >= 1)
            {
                if (_IntIndexByDialogSection < _CurrentDialogBufferArray.Count)
                {
                    ++_IntIndexByDialogSection;
                }
                else
                {
                    return(false);
                }
            }
            //array is empty
            else
            {
                ++_IntIndexByDialogSection;
            }
            //get dialog Dialog Content
            GetDialogInfoRecoder(diaSectionNum, out dialogSide, out strPersonName, out strDialogContent);

            return(true);
        }
示例#7
0
        public void DisplayerNextDialogInfo()
        {
            DialogSide dialogSide = DialogSide.None;
            string     strDialogPersonName;
            string     strDialogPersonContent;

            bool result = DialogDataMgr.GetInstance().GetNextDialogInfoRecoder(2, out dialogSide, out strDialogPersonName, out strDialogPersonContent);

            if (result)
            {
                switch (dialogSide)
                {
                case DialogSide.None:
                    break;

                case DialogSide.PlayerSide:
                    TxtSide.text = "player";
                    break;

                case DialogSide.NPCSide:
                    TxtSide.text = "npc";
                    break;

                default:
                    break;
                }
                TxtPersonName.text    = strDialogPersonName;
                TxtPersonContent.text = strDialogPersonContent;
            }
            else
            {
                TxtPersonName.text    = "no output";
                TxtPersonContent.text = "no output";
            }
            Log.SyncLogArrayToFile();
        }
示例#8
0
        /// <summary>
        /// show next dialog
        /// </summary>
        /// <param name="diaType">dialog type</param>
        /// <param name="dialogSectionNum">dialog section number</param>
        /// <returns></returns>
        public bool DisplayNextDialog(DialogType diaType, int dialogSectionNum)
        {
            bool       isDialogEnd = false;
            DialogSide dialogSide  = DialogSide.None; //he who talks(player or npc)
            string     strPersonName;                 //person name
            string     strDialogContent;              //dialog info

            //change dialog type
            ChangeDialogType(diaType);

            //get dialog info data
            bool boolFlag = DialogDataMgr.GetInstance().GetNextDialogInfoRecoder(dialogSectionNum, out dialogSide, out strPersonName, out strDialogContent);

            if (boolFlag)
            {
                DisplayDialogInfo(diaType, dialogSide, strPersonName, strDialogContent);
            }
            else
            {
                isDialogEnd = true;
            }

            return(isDialogEnd);
        }
示例#9
0
        /// <summary>
        /// get dialog content
        /// </summary>
        /// <param name="diaSectionNum"></param>
        /// <param name="dialogSide"></param>
        /// <param name="strPersonName"></param>
        /// <param name="strDialogContent"></param>
        /// <returns></returns>
        private bool GetDialogInfoRecoder(int diaSectionNum, out DialogSide dialogSide, out string strPersonName, out string strDialogContent)
        {
            dialogSide = DialogSide.None;
            string strDialogSide = "[GetNextDialogInfoRecoder()/strDialogSide]";

            strPersonName    = "[GetNextDialogInfoRecoder()/strPersonName]";
            strDialogContent = "[GetNextDialogInfoRecoder()/strDialogContent]";

            if (diaSectionNum <= 0)
            {
                return(false);
            }

            if (_CurrentDialogBufferArray != null && _CurrentDialogBufferArray.Count >= 1)
            {
                for (int i = 0; i < _CurrentDialogBufferArray.Count; i++)
                {
                    if (_CurrentDialogBufferArray[i].DialogSecNumber == diaSectionNum)
                    {
                        if (_CurrentDialogBufferArray[i].SectionIndex == _IntIndexByDialogSection)
                        {
                            strDialogSide = _CurrentDialogBufferArray[i].DialogSide;

                            if (strDialogSide.Trim().Equals(XML_DEFINATION_HERO))
                            {
                                dialogSide = DialogSide.PlayerSide;
                            }
                            else if (strDialogSide.Trim().Equals(XML_DEFINATION_NPC))
                            {
                                dialogSide = DialogSide.NPCSide;
                            }
                            strPersonName    = _CurrentDialogBufferArray[i].DialogPerson;
                            strDialogContent = _CurrentDialogBufferArray[i].DialogContent;

                            return(true);
                        }
                    }
                }
            }//if_end

            if (_AllDialogDataArray != null && _AllDialogDataArray.Count >= 1)
            {
                for (int i = 0; i < _AllDialogDataArray.Count; i++)
                {
                    if (_AllDialogDataArray[i].DialogSecNumber == diaSectionNum)
                    {
                        if (_AllDialogDataArray[i].SectionIndex == _IntIndexByDialogSection)
                        {
                            strDialogSide = _AllDialogDataArray[i].DialogSide;

                            if (strDialogSide.Trim().Equals(XML_DEFINATION_HERO))
                            {
                                dialogSide = DialogSide.PlayerSide;
                            }
                            else if (strDialogSide.Trim().Equals(XML_DEFINATION_NPC))
                            {
                                dialogSide = DialogSide.NPCSide;
                            }
                            strPersonName    = _AllDialogDataArray[i].DialogPerson;
                            strDialogContent = _AllDialogDataArray[i].DialogContent;
                            LoadToBufferArraySectionNum(diaSectionNum);

                            return(true);
                        }
                    }
                }
            }//if_end
            return(false);
        }
示例#10
0
        /*****/

        /// <summary>
        /// 从对话数据数组中查找
        /// </summary>
        /// <param name="dialogDataArray"></param>
        /// <param name="diaSectionNum"></param>
        /// <param name="diaSide"></param>
        /// <param name="diaPerson"></param>
        /// <param name="diaContent"></param>
        /// <param name="strDiaSide"></param>
        /// <returns></returns>
        private bool SearchDialogDataArray(List <DialogDataFormat> dialogDataArray, int diaSectionNum, DialogSide diaSide, string diaPerson, string diaContent, string strDiaSide)
        {
            if (_AllDialogDataArray != null && _AllDialogDataArray.Count >= 1)
            {
                for (int i = 0; i < _CurDialogCacheArray.Count; i++)
                {
                    //如果段落编号相同
                    if (_AllDialogDataArray[i].DiaSectionNum == diaSectionNum)
                    {
                        //如果段内序号相同
                        if (_AllDialogDataArray[i].DiaIndex == _IntIndexByDialogSection)
                        {
                            //找到数据,提取数据
                            strDiaSide = _AllDialogDataArray[i].DiaSide;
                            //判断对话的讲述者,去掉空格
                            if (strDiaSide.Trim().Equals("Hero"))
                            {
                                diaSide = DialogSide.HeroSide;
                            }
                            else if (strDiaSide.Trim().Equals("NPC"))
                            {
                                diaSide = DialogSide.NPCSide;
                            }
                            diaPerson  = _AllDialogDataArray[i].DiaPerson;
                            diaContent = _AllDialogDataArray[i].DiaContent;

                            //把当前段落编号中的数据,写入“当前段落缓存集合”
                            LoadToCacheArrayBySectionNum(diaSectionNum);
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
示例#11
0
        /// <summary>
        /// 得到对话记录
        /// 开发思路:
        ///		对于输入的“段落编号”,首先在“当前对话数据集合”中进行查询
        ///		如果找到,直接返回结果;如果不能找到,则在“全部对话数据集合”中进行查询
        ///	实际测试中发现:有时候不能及时找到,显示的还是默认的内容
        /// </summary>
        /// <param name="diaSectionNum">输入:段落编号</param>
        /// <param name="diaSide">输出:对话方</param>
        /// <param name="diaPerson">输出:对话人名</param>
        /// <param name="diaContent">输出:对话内容</param>
        /// <returns>true: 输出了合法的对话数据</returns>
        private bool GetDialogInfoRecoder(int diaSectionNum, out DialogSide diaSide, out string diaPerson, out string diaContent)
        {
            //默认显示的内容
            diaSide = DialogSide.None;
            string strDiaSide = "[GetNextDialogInfoRecoder()/diaSide]";

            diaPerson  = "[GetNextDialogInfoRecoder()/diaPerson]";
            diaContent = "[GetNextDialogInfoRecoder()/diaContent]";

            if (diaSectionNum <= 0)
            {
                return(false);
            }

            //1: 对于输入的“段落编号”,首先在“当前对话数据集合”中进行查询
            if (_CurDialogCacheArray != null && _CurDialogCacheArray.Count >= 1)
            {
                for (int i = 0; i < _CurDialogCacheArray.Count; i++)
                {
                    //如果段落编号相同
                    if (_CurDialogCacheArray[i].DiaSectionNum == diaSectionNum)
                    {
                        //如果段内序号相同
                        if (_CurDialogCacheArray[i].DiaIndex == _IntIndexByDialogSection)
                        {
                            //找到数据,提取数据
                            strDiaSide = _CurDialogCacheArray[i].DiaSide;
                            //判断对话的讲述者,去掉空格
                            if (strDiaSide.Trim().Equals("Hero"))
                            {
                                diaSide = DialogSide.HeroSide;
                            }
                            else if (strDiaSide.Trim().Equals("NPC"))
                            {
                                diaSide = DialogSide.NPCSide;
                            }
                            diaPerson  = _CurDialogCacheArray[i].DiaPerson;
                            diaContent = _CurDialogCacheArray[i].DiaContent;

                            Log.Write("当前对话数据集合中查找");
                            return(true);
                        }
                    }
                }
            }

            //2: 如果不能找到,则在“全部对话数据集合”中进行查询,且把当前段落数据,加入当前的缓存集合
            if (_AllDialogDataArray != null && _AllDialogDataArray.Count >= 1)
            {
                for (int i = 0; i < _AllDialogDataArray.Count; i++)
                {
                    //如果段落编号相同
                    if (_AllDialogDataArray[i].DiaSectionNum == diaSectionNum)
                    {
                        //如果段内序号相同
                        if (_AllDialogDataArray[i].DiaIndex == _IntIndexByDialogSection)
                        {
                            //找到数据,提取数据
                            strDiaSide = _AllDialogDataArray[i].DiaSide;
                            //判断对话的讲述者,去掉空格
                            if (strDiaSide.Trim().Equals("Hero"))
                            {
                                diaSide = DialogSide.HeroSide;
                            }
                            else if (strDiaSide.Trim().Equals("NPC"))
                            {
                                diaSide = DialogSide.NPCSide;
                            }
                            diaPerson  = _AllDialogDataArray[i].DiaPerson;
                            diaContent = _AllDialogDataArray[i].DiaContent;

                            //把当前段落编号中的数据,写入“当前段落缓存集合”
                            LoadToCacheArrayBySectionNum(diaSectionNum);

                            Log.Write("全部对话数据集合中查找");
                            return(true);
                        }
                    }
                }
            }

            //根据当前段落编号,无法查询数据结果,则返回false
            Log.Write("未查找到!");
            return(false);
        }