Ejemplo n.º 1
0
        // 分段移动到指定值
        public static void OpenFire()
        {
            Player player = Player.GetPlay();

            GunsViewModel gunsViewModel = GunsViewModel.GetGunsViewModel();

            JichuViewModel jichuViewModel = JichuViewModel.GetJichuViewModel();

            bool _HasAmmo = true;

            GlobalParam globalParam = GlobalParam.GetGlobalParam();

            MouseStatus mouseStatus = MouseStatus.GetMouseStatus();

            AppInfo appInfo = AppInfo.GetAppInfo();

            if (player.runLogic && player.isShoot && !player.useMissiles &&
                !string.IsNullOrEmpty(player.useWeapon.weapon) && !player.useWeapon.weapon.Equals("空"))
            {
                string[] str = player.useWeapon.modelData.datas.Split('|');
                double[] datas = Array.ConvertAll(str, double.Parse);
                int      x = 0, y = 0;
                int      count     = (int)datas[6];
                int      magNum    = 40;
                int      logicTime = (int)(datas[7] / datas[6] - 1);

                Task.Run(() =>
                {
                    ValiAmmo(ref _HasAmmo);
                });

                if (!player.runXueWuLogic && jichuViewModel.XueWu)
                {
                    player.runXueWuLogic = true;
                    Task.Run(() =>
                    {
                        ExecLogic(player);
                    });
                }

                int index = 0;

                while (mouseStatus.leftDown && _HasAmmo && player.isShoot)
                {
                    DateTime startTime = DateTime.Now;
                    // 判断是否没有子弹

                    double j = 0;
                    if (magNum == 40)
                    {
                        j     = datas[0];
                        index = 0;
                    }
                    else if (magNum < 40 && magNum >= 34)
                    {
                        j     = datas[1];
                        index = 1;
                    }
                    else if (magNum < 34 && magNum >= 27)
                    {
                        j     = datas[2];
                        index = 2;
                    }
                    else if (magNum < 27 && magNum >= 19)
                    {
                        j     = datas[3];
                        index = 3;
                    }
                    else if (magNum < 19 && magNum >= 9)
                    {
                        j     = datas[4];
                        index = 4;
                    }
                    else
                    {
                        j     = datas[5];
                        index = 5;
                    }

                    for (int i = 0; i < count; i++)
                    {
                        if (_HasAmmo && player.isShoot)
                        {
                            YouyiSdk.M_MoveR2(globalParam.m_Handle, 0, (int)j);

                            Task.Run(() =>
                            {
                                if (index != globalParam.DataIndex)
                                {
                                    globalParam.DataIndex = index;
                                    gunsViewModel.RaisePropertyChanged("Datas");
                                }
                                LogHelper.ShowLog("压枪耗时 {0} 压枪幅度:{1} 步进:{2}", 0, j, i);
                            });
                            Thread.Sleep(logicTime);
                        }
                    }
                    magNum -= 1;
                    Task.Run(() =>
                    {
                        ValiAmmo(ref _HasAmmo);
                        Task.Run(() =>
                        {
                            ValiShoot(globalParam, player);
                        });
                    });
                }
            }
        }