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); } })); }
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); } })); }
private bool IsMainMenu() { /* * 424:network * 512:replay * * 396:watch * * 72-88:main menu * 310:network * 350:replay * * * 0,0 开始界面 * * * -1,-1 输入ip地址 */ var cursorstat_x = TH155Addr.TH155GetRTChildInt("menu/cursor/target_x"); return(cursorstat_x >= 72 && cursorstat_x <= 88); }
private bool CheckCursor(int value) { var cursorstat_x = TH155Addr.TH155GetRTChildInt("menu/cursor/target_x"); return(cursorstat_x == value); }
private bool IsReplaying() { var cursorstat_x = TH155Addr.TH155GetRTChildInt("menu/cursor/target_x"); return(cursorstat_x == -100); }
private bool IsNetwork() { var cursorstat_x = TH155Addr.TH155GetRTChildInt("menu/cursor/target_x"); return(cursorstat_x == 310 || cursorstat_x == -1); }
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(); } }