Beispiel #1
0
        private async void LaunchTH155()
        {
            if (executing)
            {
                return;
            }
            executing = true;
            Log($"Exec: Launch TH155");
            for (;;)
            {
                Process proc = new Process();
                proc.StartInfo.FileName               = "steam://run/716710";
                proc.StartInfo.UseShellExecute        = true;
                proc.StartInfo.RedirectStandardOutput = false;
                proc.StartInfo.RedirectStandardError  = false;
                proc.Start();
                Thread.Sleep(13000);
                if (TH155Addr.TH155AddrGetState() > 0)
                {
                    break;
                }
            }

            //await WaitingUntil(() => TH155Addr.TH155AddrGetState() > 0);
            SetTH155Foreground();
            //TH155Addr.VirtualPress(90);
            //Thread.Sleep(6000);
            await SwitchTo(512);

            Thread.Sleep(200);
            TH155Addr.VirtualPress(90);
            Thread.Sleep(300);
            Log($"Exec Finish:LaunchTH155");
            executing = false;
        }
Beispiel #2
0
        private Task SwitchTo(int loc, Func <bool> predice = null)
        {
            return(Task.Run(() =>
            {
                if (TH155Addr.TH155AddrGetState() < 1)
                {
                    return;
                }

                for (; ;)
                {
                    if (TH155Addr.TH155AddrGetState() == 0)
                    {
                        return;
                    }
                    var cursorstat_y = TH155Addr.TH155GetRTChildInt("menu/cursor/target_y");
                    SetTH155Foreground();
                    if (predice != null && predice())
                    {
                        return;
                    }
                    if (loc == cursorstat_y)
                    {
                        break;
                    }
                    TH155Addr.VirtualPressEx(0x28);//Down
                    Thread.Sleep(100);
                }
            }));
        }
Beispiel #3
0
 private Task WaitingUntil(Func <bool> predice)
 {
     return(Task.Run(() =>
     {
         for (;;)
         {
             if (predice() || TH155Addr.TH155AddrGetState() == 0)
             {
                 return;
             }
             Thread.Sleep(1000);
         }
     }));
 }
Beispiel #4
0
 private Task ReturnToGameMenu()
 {
     return(Task.Run(() =>
     {
         if (TH155Addr.TH155AddrGetState() < 1)
         {
             return;
         }
         for (; ;)
         {
             if (TH155Addr.TH155AddrGetState() == 0)
             {
                 return;
             }
             SetTH155Foreground();
             if (IsMainMenu())
             {
                 break;
             }
             var replay_state = TH155Addr.TH155GetRTChildInt("replay/state");
             var current_y = TH155Addr.TH155GetRTChildInt("menu/cursor/target_y");
             if (IsReplaying() &&
                 current_y == 216)
             {
                 TH155Addr.VirtualPress(88);//x
                 Thread.Sleep(1000);
                 SwitchTo(306, () =>
                 {
                     return !CheckCursor(-1);
                 }).Wait();
                 Thread.Sleep(100);
                 TH155Addr.VirtualPress(90);
                 Thread.Sleep(100);
             }
             TH155Addr.VirtualPress(88);//x
             Thread.Sleep(1000);
         }
     }));
 }
Beispiel #5
0
        private async void ToNetwork(string IPAddress)
        {
            if (executing)
            {
                return;
            }
            if (TH155Addr.TH155AddrGetState() < 1)
            {
                return;
            }
            executing = true;
            Log($"Exec: Network Match");
            File.WriteAllText("P1.txt", "***");
            File.WriteAllText("P2.txt", "***");
            File.Copy($"Avatar/Default.png", "P1.png", true);
            File.Copy($"Avatar/Default.png", "P2.png", true);
            Clipboard.SetText(IPAddress);
            SetTH155Foreground();
            await ReturnToGameMenu();
            await SwitchTo(424);

            TH155Addr.VirtualPress(90);
            await WaitingUntil(IsNetwork);
            await SwitchTo(396, () => !IsNetwork());// 观战

            if (IsNetwork())
            {
                TH155Addr.VirtualPress(90);
                Thread.Sleep(200);
                TH155Addr.VirtualPress(0x43);
                Thread.Sleep(200);
                TH155Addr.VirtualPress(90);

                Thread.Sleep(5000);
                if (TH155Addr.TH155IsConnect())
                {
                    //network/player_name/0
                    try
                    {
                        var P1 = TH155Addr.TH155GetRTChildStr("network/player_name/0");
                        var P2 = TH155Addr.TH155GetRTChildStr("network/player_name/1");
                        File.WriteAllText("P1.txt", P1);
                        File.WriteAllText("P2.txt", P2);
                        ApplyAvatar(P1, "P1.png");
                        ApplyAvatar(P2, "P2.png");
                    }
                    catch (Exception ex)
                    {
                        File.AppendAllText("exception.txt", ex.ToString());
                    }
                }
                await WaitingUntil(() =>
                {
                    //var is_watch = TH155Addr.TH155GetRTChildInt("network/is_watch");
                    //var is_disconnect = TH155Addr.TH155GetRTChildInt("network/is_disconnect");
                    return(!TH155Addr.TH155IsConnect());
                });
            }

            //Return to replay
            await ReturnToGameMenu();

            //Thread.Sleep(200);
            //await SwitchTo(512);
            //TH155Addr.VirtualPress(90);
            //Thread.Sleep(300);
            Log($"Exec Finish:Network Match");
            executing = false;
        }
Beispiel #6
0
        private void timer1_Tick_1(object sender, EventArgs e)
        {
            label6.Text = (executing ? "Executing" : "Idleing") + (tencoFetch ? "Fetching" : "");
            int    state = TH155Addr.TH155AddrGetState();
            string str;

            label1.Text = "State : " + state;
            if (_currentDate.Day != DateTime.Now.Day) //日替
            {
                FetchTenco();
            }
            if (state >= 1)
            {
                var cursorstat_y = TH155Addr.TH155GetRTChildInt("menu/cursor/target_y");
                var cursorstat_x = TH155Addr.TH155GetRTChildInt("menu/cursor/target_x");
                label5.Text = "cursor:" + cursorstat_x + "," + cursorstat_y;

                var replay_state = TH155Addr.TH155GetRTChildInt("replay/state");
                var play_state   = TH155Addr.TH155GetRTChildInt("replay/game_mode");
                label2.Text = "replayStat : " + play_state;

                if (play_state == -1 && TH155Addr.TH155AddrGetState() != 0)
                {
                    //无法获取到信息,重启游戏
                    TerminateTH155();
                }

                if (!IsReplaying() && (checkBox1.Checked || _LoadReplay) && !executing)
                {
                    executing = true;
                    Log($"Exec:SwitchReplay");
                    Task.Run(() => {
                        //Thread.Sleep(2500);
                        if (CheckCursor(-1)) //暂停中
                        {
                            SetTH155Foreground();
                            TH155Addr.VirtualPress(88);//x
                            Log($"Exec Finish:SwitchReplay(Pause)");
                            executing = false;
                            return;
                        }

                        string selectedReplay = "";
                        try
                        {
                            if (_current != null && _current.Count > 0)
                            {
                                selectedReplay = _current.Last().FileName;
                                _current.RemoveAt(_current.Count - 1);
                                StatusLog($"正在播放满足条件的Rep,还剩{_current.Count}个:{_filterStr}");
                            }
                            else
                            {
                                selectedReplay = _records.Replays.OrderBy(x => Guid.NewGuid()).Take(1).First().FileName;
                                StatusLog("正在随机播放所有rep");
                            }

                            var info = ReplayReader.Open(selectedReplay);
                            Func <string, string> processStr = input =>
                            {
                                string ret = input.Replace("\\", "").Trim();
                                return(ret.Length == 0 ? "无名黑幕" : ret);
                            };
                            var P1Name = processStr(info[14]);
                            var P2Name = processStr(info[16]);
                            File.WriteAllText("P1.txt", P1Name);
                            ApplyAvatar(P1Name, "P1.png");
                            File.WriteAllText("P2.txt", P2Name);
                            ApplyAvatar(P2Name, "P2.png");
                            File.Copy(selectedReplay, textBox1.Text, true);
                        }
                        catch (Exception ex)
                        {
                            File.AppendAllText("exception.txt", ex.ToString());
                        }

                        SetTH155Foreground();
                        Thread.Sleep(500);
                        if (IsMainMenu())
                        {
                            SwitchTo(512).Wait();
                            TH155Addr.VirtualPress(90);
                            Thread.Sleep(300);
                            TH155Addr.VirtualPress(90);
                            Thread.Sleep(300);
                        }
                        TH155Addr.VirtualPress(90);
                        //SendKeys.SendWait("z");
                        Thread.Sleep(2000);
                        Log($"Exec Finish:SwitchReplay");
                        _LoadReplay = false;
                        executing   = false;
                    });
                }
            }
            else if (checkBox2.Checked)
            {
                LaunchTH155();
            }
        }