Ejemplo n.º 1
0
        /// <summary>
        /// 读取距离目标最近的点位
        /// </summary>
        /// <param name="data"></param>
        /// <param name="toAxis"></param>
        /// <returns></returns>
        public int readAxis(byte[] data, bean.Axis toAxis)
        {
            List <bean.Axis> list = new List <bean.Axis>();

            data = data.Skip(13).Take(data.Length - 13).ToArray();
            for (int i = 0; i < data.Length; i++)
            {
                bean.Axis a = new bean.Axis(toAxis.x, toAxis.y);
                a.x = BitConverter.ToInt16(new byte[] { data[i], data[i + 1] }, 0);
                a.y = BitConverter.ToInt16(new byte[] { data[i + 2], data[i + 3] }, 0);
                i  += 3;
                list.Add(a);
            }
            //计算距离最近坐标点
            int idx = 0;
            int j   = -1;

            for (int i = 0; i < list.Count; i++)
            {
                int x   = System.Math.Abs(list[i].x - toAxis.x);
                int y   = System.Math.Abs(list[i].y - toAxis.y);
                int tmp = (int)Math.Sqrt(x * x + y * y);
                if (j == -1)
                {
                    j = tmp;
                }
                if (tmp < j)
                {
                    idx = i;
                    j   = tmp;
                }
            }
            return(idx);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///开始地图和目标
 /// </summary>
 /// <param name="mapID"></param>
 /// <param name="targetId"></param>
 public Distance(Execute e, int mapID, int targetId, FinishCallBack callback)
 {
     list          = model.MhxyRouterRec.GetRouterAll(mapID, targetId);
     this.hwnd     = e.hwnd.ToInt32();
     this.ex       = e;
     this.callback = callback;
     //判断当前地图所在位置,是否需要继续寻路
     for (int i = 0; i < list.Count; i++)
     {
         if (list[i].mapExit.toMap.map_no == Global.addr.GetMapID(hwnd))
         {
             if (list.Count - 1 > i)
             {
                 idx = i + 1;
             }
             else
             {
                 idx = i;
             }
         }
         //坐标偏移
         bean.Axis      a  = OffsetAxis(list[i].mapExit.wait_x, list[i].mapExit.wait_y, -1, 2, -2, 2);
         model.MhxyAxis ma = RandomAxis(list[i].mapExit.id, 1);
         if (ma != null)
         {
             a = new bean.Axis(ma.x, ma.y);
         }
         list[i].mapExit.wait_x = a.x;
         list[i].mapExit.wait_y = a.y;
     }
     if (idx <= list.Count - 1)
     {
         Log.WriteLine("开始地图:{0}", list[idx].mapExit.myMap.name);
     }
 }
Ejemplo n.º 3
0
 public Flight(int mapID, Execute ex, bean.Axis toAxis)
 {
     this.ex     = ex;
     this.mapID  = mapID;
     this.hwnd   = ex.hwnd.ToInt32();
     this.toAxis = toAxis;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 坐标偏移
        /// </summary>
        /// <returns></returns>
        public bean.Axis OffsetAxis(int x, int y, int xs, int xe, int ys, int ye)
        {
            Random r = new Random();

            x = x + r.Next(xs, xe);
            y = y + r.Next(ys, ye);
            bean.Axis a = new bean.Axis(x, y);
            return(a);
        }
Ejemplo n.º 5
0
 public void regBiao()
 {
     //注册,二级对话回复被打开
     //FA 47 01 3E 00 00 00 05
     ex.RegMsgCallBack(0xFA, new MsgCallBack(false, delegate(int msgType, byte[] data)
     {
         System.Threading.Thread.Sleep(1500);
         bean.Axis ax = mhxy.CallFunc.ReadDialogOption(hwnd, moneyType);
         mhxy.CallFunc.taskClick(hwnd, ax.x, ax.y);
     }, true, new Dictionary <int, int>()
     {
         { 3, 0x3E },
         { 4, 0x00 },
         { 5, 0x00 },
         { 6, 0x00 },
         { 7, 0x05 }
     }));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 接货
        /// </summary>
        public void recvDelivery()
        {
            //注册,一级对话回复被打开  //FA 47 01 3E 00 00 00 05
            ex.RegMsgCallBack(0xFA, new MsgCallBack(false, delegate(int msgType, byte[] data)
            {
                CallNPCOpen = true;

                System.Threading.Thread.Sleep(1000);
                regBiao();
                bean.Axis ax = mhxy.CallFunc.ReadDialogOption(hwnd, goodsLv);
                mhxy.CallFunc.taskClick(hwnd, ax.x, ax.y);
            }, true, new Dictionary <int, int>()
            {
                { 3, 0x3E },
                { 4, 0x00 },
                { 5, 0x00 },
                { 6, 0x00 },
                { 7, 0x05 }
            }));

            //打开郑镖头对话框
            while (!CallNPCOpen)
            {
                mxCheck.WaitOne();

                string cmd = mhxy.CallNPC.GetNpcDialog(536871314, 0, 0);
                LoadDll.sendMsg((IntPtr)hwnd, cmd);
                mxCheck.ReleaseMutex();
                Log.WriteLine("NPC郑镖头放锁");
                System.Threading.Thread.Sleep(4000);
            }
            //判断身上有没有货物,如果没有继续回调
            System.Threading.Thread.Sleep(20000);
            if (GetBiaoYinID() == 0)
            {
                recvDelivery();
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 读取对话选项
        /// </summary>
        /// <param name="hwnd">句柄</param>
        /// <param name="option">第几个选项</param>
        /// <returns></returns>
        public static bean.Axis ReadDialogOption(int hwnd, int option)
        {
            bean.Axis a   = null;
            int       idx = 0;
            Random    r   = new Random();

            for (int i = 0; i < 20; i++)
            {
                //获取对话框的x,y起点
                int x    = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, i * 4, 0x08);
                int y    = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, i * 4, 0x0C);
                int type = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, i * 4, 0x18);
                int show = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, i * 4, 0x28);
                if (type != 550 || show == 1)
                {
                    continue;
                }
                for (int n = 0; n < 10; n++)
                {
                    int tz = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, i * 4, 0x68, 56 + n * 4, 0x00);

                    int nx = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, i * 4, 0x68, 56 + n * 4, 0x08);
                    if (nx == 30)
                    {
                        idx++;
                        if (idx == option)
                        {
                            int ny = LoadDll.ReadHwndMemoryOffsetValue((IntPtr)hwnd, Global.addr.win, 0x68, 0x8, 0x68, i * 4, 0x68, 56 + n * 4, 0x0C);
                            x = nx + x + r.Next(10, 20);
                            y = ny + y;
                            a = new bean.Axis(x, y);
                        }
                    }
                }
            }
            return(a);
        }
Ejemplo n.º 8
0
        public void MoveNPC(int npcid)
        {
            //获取NPC坐标
            model.MhxyNPC npc = model.MhxyNPC.GetNPCID(npcid);
            if (npc == null || npc.x == 0 || npc.y == 0)
            {
                return;
            }
            //坐标偏移
            bean.Axis      a  = OffsetAxis(npc.x, npc.y, -3, 3, -4, 4);
            model.MhxyAxis ma = RandomAxis(npcid, 0);
            if (ma != null)
            {
                a = new bean.Axis(ma.x, ma.y);
            }


            npc.x = a.x;
            npc.y = a.y;
            am.ReSetMove(Global.addr.GetMapID(hwnd), npc.x, npc.y, 0);
            bool to = true;

            while (to)
            {
                int[] xy = Global.addr.getPeopleXY(hwnd);
                if (xy[0] == npc.x && xy[1] == npc.y)
                {
                    Log.WriteLine("已到达NPC所在坐标!");
                    to = false;
                    if (callback != null)
                    {
                        callback();
                    }
                }
                System.Threading.Thread.Sleep(1000);
            }
        }