Пример #1
0
 public void RunThread()
 {
     try
     {
         f = new Func();
         f.SetDMPath(PicPath);
         Thread.Sleep(500);
         int pid = 0, handle = 0;
         if (this.txtPID.Text.Trim() != "")
         {
             pid = int.Parse(txtPID.Text.Trim());
         }
         if (this.txtHandle.Text.Trim() != "")
         {
             handle = int.Parse(txtHandle.Text.Trim());
         }
         f.BindDM(ClassName, pid, handle);
         string currentDT = f.GetCurrentDT();
         if (currentDT == "")
         {
             throw new Exception("获取当前地图失败");
         }
         string dtTo = this.Invoke(new GetControlText(delegate(Control c) { return c.Text; }), new object[] { this.cbxDT }).ToString().Trim();
         string npc = this.Invoke(new GetControlText(delegate(Control c) { return c.Text; }), new object[] { this.cbxNPC }).ToString().Trim();
         string strIndex = this.Invoke(new GetControlText(delegate(Control c) { return c.Text; }), new object[] { this.cbxSDIndex }).ToString();
         if (currentDT != dtTo)
         {
             f.WayfindingEx(currentDT, dtTo, 0.9);
         }
         Thread.Sleep(500);
         f.CloseSubWindows();
         if (npc != "")
         {
             Thread.Sleep(500);
             string xl = npc.Replace(PicPath, "").Replace(dtTo,"自动寻路").Replace("NPC", dtTo);
             f.Wayfinding(xl, npc, 0.9, 2);
             if (strIndex != "")
             {
                 int sdIndex = int.Parse(strIndex);
                 int x = 0, y = 0;
                 f.GetPicCenter(npc, 0.9, 2, 0, out x, out y);
                 y = y + 81 + 22 * (sdIndex - 1);//NPC名字坐标和第一个帮会列表距离88像素
                 Thread.Sleep(500);
                 f.dm.MoveTo(x, y);
                 Thread.Sleep(1000);
                 f.dm.LeftClick();
                 Thread.Sleep(10000);
                 f.UnBindDM();
                 this.Invoke(DelegateSetControl, new object[] { gbSetting, true });
                 this.Invoke(DelegateSetControl, new object[] { gbStart, true });
             }
         }
     }
     catch (Exception ex)
     {
         this.Invoke(delegateShowMsg, new object[] { ex.Message });
         if (f != null)
         {
             f.UnBindDM();
             this.Invoke(DelegateSetControl, new object[] { gbSetting, true });
             this.Invoke(DelegateSetControl, new object[] { gbStart, true });
         }
     }
 }
Пример #2
0
        public void KJThread()
        {
            try
            {
                f = new Func();
                f.SetDMPath(PicPath);
                Thread.Sleep(500);
                int pid = 0, handle = 0;
                if (this.txtPID.Text.Trim() != "")
                {
                    pid = int.Parse(txtPID.Text.Trim());
                }
                if (this.txtHandle.Text.Trim() != "")
                {
                    handle = int.Parse(txtHandle.Text.Trim());
                }
                f.BindDM(ClassName, pid, handle);
                string currentDT = f.GetCurrentDT();
                if (currentDT != "京师")
                {
                    throw new Exception("当前不在京师");
                }

                f.KJ();
                f.UnBindDM();
                this.Invoke(DelegateSetControl, new object[] { gbSetting, true });
                this.Invoke(DelegateSetControl, new object[] { gbStart, true });
                return;

            }
            catch (Exception ex)
            {
                this.Invoke(delegateShowMsg, new object[] { ex.Message });
                if (f != null)
                {
                    f.UnBindDM();
                    this.Invoke(DelegateSetControl, new object[] { gbSetting, true });
                    this.Invoke(DelegateSetControl, new object[] { gbStart, true });
                }
            }
        }