Ejemplo n.º 1
0
        private void SetTalk(int iTm)
        {
            try
            {
                //如果序号是最后一段对话
                if (iTm >= _drTalk.Length)
                {
                    //如果有后续对话
                    if (_sEndAdd != "0" || string.IsNullOrEmpty(_sEndAdd))
                    {
                        //用第一个事件的结尾查找另一个事件的开端
                        _drDq = DataHelper.XkfyData.Tables["DevelopQuestData"].Select("iID='" + _sEndAdd + "'");
                        if (_drDq.Length == 0)
                        {
                            //一般而言不会执行到这段
                            return;
                        }

                        string iType = _drDq[0]["iType"].ToString();
                        if (iType == "3")
                        {
                            Satisfy();
                            return;
                        }
                        else
                        {
                            //触发战斗,优先执行战斗
                            if (_drDq[0]["iDevelopType"].ToString() == "3")
                            {
                                _drBa        = DataHelper.XkfyData.Tables["BattleAreaData"].Select("iID$0='" + _drDq[0]["iArg3"].ToString() + "'");
                                gbZd.Visible = true;
                                return;
                            }
                            //无条件就直接执行
                            SetTalkDr(_drDq[0]["iArg3"].ToString());
                            iTm = 0;
                        }
                    }
                    else
                    {
                        //事件结束
                        txtNext.Text = "结束";
                        //txtNext.Enabled = false;
                        return;
                    }
                }
                StringBuilder sbMsg       = new StringBuilder();
                string        sBackground = _drDq[0]["sBackground"].ToString();
                string        path        = "";
                if (PicFile.ContainsKey(sBackground))
                {
                    path = PicFile[sBackground];
                }

                //画出背景图
                if (File.Exists(path))
                {
                    Image img = Image.FromFile(path);
                    panelBackground.BackgroundImage = img;
                }
                else
                {
                    sbMsg.AppendFormat("没有找到名称为【{0}】的背景图片文件!", _drDq[0]["sBackground"]);
                }

                //判断是否有选项
                if (_drTalk[iTm]["bInFields"].ToString() == "1")
                {
                    for (int i = 1; i < 5; i++)
                    {
                        string sButtonName = _drTalk[iTm]["sButtonName" + i].ToString();
                        if (sButtonName == "0" || string.IsNullOrEmpty(sButtonName))
                        {
                            continue;
                        }

                        switch (i)
                        {
                        case 1:
                            btnA.Visible = true;
                            btnA.Text    = sButtonName;
                            btnA.Tag     = _drTalk[iTm]["sBArg" + i].ToString();
                            break;

                        case 2:
                            btnB.Visible = true;
                            btnB.Text    = sButtonName;
                            btnB.Tag     = _drTalk[iTm]["sBArg" + i].ToString();
                            break;

                        case 3:
                            btnC.Visible = true;
                            btnC.Text    = sButtonName;
                            btnC.Tag     = _drTalk[iTm]["sBArg" + i].ToString();
                            break;

                        case 4:
                            btnD.Visible = true;
                            btnD.Text    = sButtonName;
                            btnD.Tag     = _drTalk[iTm]["sBArg" + i].ToString();
                            break;
                        }
                    }
                }

                //显示对话内容
                txtTalk.Text = _drTalk[iTm]["sManager"].ToString();
                _curIndex    = iTm;
                int iMasgPlace = int.Parse(_drTalk[iTm]["iMasgPlace"].ToString());

                //画出人物位置
                Graphics g = panel1.CreateGraphics();//pictureBox1.CreateGraphics();
                g.Clear(panel1.BackColor);
                for (int i = 1; i < 9; i++)
                {
                    string sNpcQName = _drTalk[iTm]["sNpcQName" + i].ToString();
                    if (sNpcQName == "0" || string.IsNullOrEmpty(sNpcQName))
                    {
                        continue;
                    }
                    DrawTalk(iMasgPlace);
                    path = "";
                    if (PicFile.ContainsKey(sNpcQName))
                    {
                        path = PicFile[sNpcQName];
                    }
                    if (File.Exists(path))
                    {
                        Image img = Image.FromFile(path);
                        DrawImage(img, i, g);
                    }
                    else
                    {
                        sbMsg.AppendFormat("\r\n没有找到名称为【{0}】的人物贴图文件!", sNpcQName);
                    }
                }
                g.Dispose();

                if (chkTalk.Checked)
                {
                    TalkManagerEdit msgForm = null;
                    bool            wExist  = _tl.CheckFormIsOpen("TalkManager_Edit");

                    if (!wExist)
                    {
                        msgForm = new TalkManagerEdit("debug");
                        msgForm.Show();
                        msgForm.BindData(_drTalk[iTm]);
                    }
                    else
                    {
                        msgForm = (TalkManagerEdit)Application.OpenForms["TalkManager_Edit"];
                        msgForm.Show();
                        msgForm.BindData(_drTalk[iTm]);
                    }
                }
                lblMsg.Text       = sbMsg.ToString();
                lblWin.Text      += _tl.ExplainTalkManager(_drTalk[iTm]);
                panelTalk.Visible = true;
                iTm++;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }