public override void Invoke(bool isSimulate, bool async) { log.Debug(this.ToString()); bool saveScreen; Boolean.TryParse(StateContainer.ini.Read("saveScreen", "Settings"), out saveScreen); Uri proofImg = new Uri(Environment.CurrentDirectory + @"\proofImg\planetary.bmp"); planetaryProof = new BitmapImage(proofImg); StateContainer.EnterPlanetary(); int tries = 0; bool loading = false; System.Drawing.Bitmap bmpScreenshot; System.Drawing.Graphics gfx; if (isSimulate) { if (Point.X < StateContainer.ExtentMin.X || Point.Y < StateContainer.ExtentMin.Y || Point.X > StateContainer.ExtentMax.X || Point.Y < StateContainer.ExtentMax.Y) { GalaxyMovingCommand moving = new GalaxyMovingCommand(Point); moving.StateContainer = StateContainer; moving.Invoke(isSimulate, async); } Point target = new Point(); target.X = Point.X - StateContainer.ExtentMin.X + 15; target.Y = Point.Y - StateContainer.ExtentMin.Y + 67; sim.Mouse.MoveMouseTo(target.X * xf, target.Y * yf).Sleep(500); sim.Mouse.LeftButtonClick(); while (!loading) { tries++; if (tries > 30) { break; } sim.Mouse.Sleep(5000); bmpScreenshot = new System.Drawing.Bitmap(145, 23, System.Drawing.Imaging.PixelFormat.Format32bppArgb); gfx = System.Drawing.Graphics.FromImage(bmpScreenshot); gfx.CopyFromScreen(32, 32, 0, 0, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size, System.Drawing.CopyPixelOperation.SourceCopy); loading = Utils.Compare(Utils.BitmapImage2Bitmap(planetaryProof), bmpScreenshot); log.Debug("Loading..."); if (loading) { break; } else if (saveScreen) { Utils.saveScreen(Environment.CurrentDirectory + @"\planetaryTry", bmpScreenshot); } } } }
public override void Invoke(bool isSimulate, bool async) { OpenCommanderPanelCommand openCommanderPanelCommand = new OpenCommanderPanelCommand(); openCommanderPanelCommand.StateContainer = StateContainer; openCommanderPanelCommand.Invoke(isSimulate, async); RecruitCommand recruitCommand = new RecruitCommand(); recruitCommand.StateContainer = StateContainer; recruitCommand.Invoke(isSimulate, async); CloseCommanderPanelCommand closeCommanderPanelCommand = new CloseCommanderPanelCommand(); closeCommanderPanelCommand.StateContainer = StateContainer; closeCommanderPanelCommand.Invoke(isSimulate, async); StateContainer.EnterGalaxy(); Point M874 = new Point(100, 100); EnterPlanetaryCommand enterPlanetaryCommand = new EnterPlanetaryCommand(M874); enterPlanetaryCommand.StateContainer = StateContainer; enterPlanetaryCommand.Invoke(isSimulate, async); log.Debug(this.ToString()); if (isSimulate) { // 874 III sim.Mouse.MoveMouseTo(256 * xf, 704 * yf).Sleep(100).LeftButtonClick().Sleep(2000); // 集中資源 sim.Mouse.MoveMouseTo(306 * xf, 687 * yf).Sleep(100).LeftButtonClick().Sleep(2000); // 創艦隊 sim.Mouse.MoveMouseTo(990 * xf, 654 * yf).Sleep(100).LeftButtonClick().Sleep(1500); if (Formation == 1) { // 第一種船 sim.Mouse.MoveMouseTo(200 * xf, (260 + (1 * 34) - 34) * yf).Sleep(100).LeftButtonClick().Sleep(300); clikcNCell(1); //// 第二種船 //sim.Mouse.MoveMouseTo(200 * xf, (260 + (2 * 34) - 34) * yf).Sleep(100).LeftButtonClick().Sleep(300); //clikcNCell(2); //// 第三種船 //sim.Mouse.MoveMouseTo(200 * xf, (260 + (3 * 34) - 34) * yf).Sleep(100).LeftButtonClick().Sleep(300); //clikcNCell(3); } else if (Formation == 2) { clikcNCell(1); clikcNCell(2); clikcNCell(3); clikcNCell(4); clikcNCell(5); clikcNCell(6); clikcNCell(7); clikcNCell(8); clikcNCell(9); } // 艦隊名 sim.Mouse.MoveMouseTo(380 * xf, 210 * yf).Sleep(100).LeftButtonClick().Sleep(300); sim.Keyboard.TextEntry("Airborne").Sleep(100); // 下一步 sim.Mouse.MoveMouseTo(570 * xf, 670 * yf).Sleep(100).LeftButtonClick().Sleep(1500); // 大功告成 sim.Mouse.MoveMouseTo(566 * xf, 675 * yf).Sleep(100).LeftButtonClick().Sleep(5000); // 最大值 sim.Mouse.MoveMouseTo(320 * xf, 530 * yf).Sleep(100).LeftButtonClick().Sleep(1000); // 裝貨 sim.Mouse.MoveMouseTo(420 * xf, 550 * yf).Sleep(100).LeftButtonClick().Sleep(1000); // 關閉 sim.Mouse.MoveMouseTo(661 * xf, 646 * yf).Sleep(100).LeftButtonClick().Sleep(300); // safty close sim.Mouse.MoveMouseTo(600 * xf, 495 * yf).Sleep(100).LeftButtonClick().Sleep(2000); // 移動 sim.Mouse.MoveMouseTo(915 * xf, 405 * yf).Sleep(100).LeftButtonClick().Sleep(750); // 星門 sim.Mouse.MoveMouseTo(700 * xf, 700 * yf).Sleep(100).LeftButtonClick().Sleep(1000); StateContainer.EnterGalaxy(); GalaxyMovingCommand galaxyMovingCommand = new GalaxyMovingCommand(Point); galaxyMovingCommand.StateContainer = StateContainer; galaxyMovingCommand.Invoke(isSimulate, async); sim.Mouse.LeftButtonClick().Sleep(500); // 躍遷 sim.Mouse.MoveMouseTo(870 * xf, 240 * yf).Sleep(100); } }