private bool WaitActive(int ms = 500, int times = 20) { while (times > 0 && WindowFinder.GetForegroundWindow() != Handle) { StaticSleeper.Sleep(ms); times--; } return(times > 0); }
public void AutoResearch(object sender, EventArgs e) { UIMap.PopulationAndProduction.MakeActive(); UIMap.PopulationAndProduction.SelectResearchTab(); UIMap.PopulationAndProduction.MatchingScientistsOnly.Select(); StaticSleeper.Sleep(500); if (int.Parse(UIMap.PopulationAndProduction.AvailableLabs.Text) != 0) { var scientists = new List <string[]>(); var research = new List <string[]>(); // UIMap.PopulationAndProduction.SelectBiology(); // StaticSleeper.Sleep(500); // research.AddRange(UIMap.PopulationAndProduction.ResearchTable.GetTable().Select((x, index) => new[] { x[0], x[1], "bg", ""+index })); // scientists.AddRange(UIMap.PopulationAndProduction.AvailableScientistsTable.GetTable().Select(x => new[] { x[0], "bg" })); // UIMap.PopulationAndProduction.SelectConstruction(); // StaticSleeper.Sleep(500); // research.AddRange(UIMap.PopulationAndProduction.ResearchTable.GetTable().Select((x, index) => new[] { x[0], x[1], "cp", "" + index })); // scientists.AddRange(UIMap.PopulationAndProduction.AvailableScientistsTable.GetTable().Select(x => new[] { x[0], "cp" })); // UIMap.PopulationAndProduction.SelectDefensive(); // StaticSleeper.Sleep(500); // research.AddRange(UIMap.PopulationAndProduction.ResearchTable.GetTable().Select((x, index) => new[] { x[0], x[1], "ds", "" + index })); // scientists.AddRange(UIMap.PopulationAndProduction.AvailableScientistsTable.GetTable().Select(x => new[] { x[0], "ds" })); // UIMap.PopulationAndProduction.SelectEnergy(); // StaticSleeper.Sleep(500); // research.AddRange(UIMap.PopulationAndProduction.ResearchTable.GetTable().Select((x, index) => new[] { x[0], x[1], "ew", "" + index })); // scientists.AddRange(UIMap.PopulationAndProduction.AvailableScientistsTable.GetTable().Select(x => new[] { x[0], "ew" })); // UIMap.PopulationAndProduction.SelectLogistics(); // StaticSleeper.Sleep(500); // research.AddRange(UIMap.PopulationAndProduction.ResearchTable.GetTable().Select((x, index) => new[] { x[0], x[1], "lg", "" + index })); // scientists.AddRange(UIMap.PopulationAndProduction.AvailableScientistsTable.GetTable().Select(x => new[] { x[0], "lg" })); // UIMap.PopulationAndProduction.SelectMissiles(); // StaticSleeper.Sleep(500); // research.AddRange(UIMap.PopulationAndProduction.ResearchTable.GetTable().Select((x, index) => new[] { x[0], x[1], "mk", "" + index })); // scientists.AddRange(UIMap.PopulationAndProduction.AvailableScientistsTable.GetTable().Select(x => new[] { x[0], "mk" })); // UIMap.PopulationAndProduction.SelectPower(); // StaticSleeper.Sleep(500); // research.AddRange(UIMap.PopulationAndProduction.ResearchTable.GetTable().Select((x, index) => new[] { x[0], x[1], "pp", "" + index })); // scientists.AddRange(UIMap.PopulationAndProduction.AvailableScientistsTable.GetTable().Select(x => new[] { x[0], "pp" })); // UIMap.PopulationAndProduction.SelectSensors(); // StaticSleeper.Sleep(500); // research.AddRange(UIMap.PopulationAndProduction.ResearchTable.GetTable().Select((x, index) => new[] { x[0], x[1], "sf", "" + index })); // scientists.AddRange(UIMap.PopulationAndProduction.AvailableScientistsTable.GetTable().Select(x => new[] { x[0], "sf" })); if (SelectScience(research, scientists)) { return; } //new MessageCommands(Settings).PrintError("[AutoResearch] Failed to assign a new research project."); } }
public void MakeActive() { for (var i = 0; i < 12; i++) { WindowFinder.SetForegroundWindow(Handle); if (!WaitActive()) { continue; } Screen.Dirty(); StaticSleeper.Sleep(500); return; } throw new Exception("Window never opened!"); }
private void BalanceResearch(object sender, EventArgs e) { StaticSleeper.Sleep(500); var labs = UIMap.PopulationAndProduction.CurrentResearchProject.GetTable()[0][2]; var occupied = int.Parse(labs.Split('/')[0]); if (occupied >= 2) { UIMap.PopulationAndProduction.CurrentResearchProject.ClickRow(0); for (int i = 0; i < occupied / 2; i++) { UIMap.PopulationAndProduction.RemoveRL.Click(); } //Timeline.AddEvent(AutoResearch); throw new NotImplementedException(); } }
public bool ParseUsingEventWindow(Time time) { UIMap.Events.MakeActive(); UIMap.Events.TextFileButton.Click(); StaticSleeper.Sleep(1500); var file = Settings.EventLogLocation; var allEvents = File.ReadAllLines(file); if (!Time.Within(GetLatestTime(allEvents), time, new Time { Second = 60 })) { return(false); } var list = GetLatestEvents(allEvents).Select(IsStopEvent).ToList(); return(list.Any(x => x)); }
private bool SelectTargetedScience(List <string[]> research, List <string[]> scientists) { var totalScientists = scientists.Count(x => x[0] != ""); foreach (var searchFor in Settings.Research) { var sci = scientists.Where(x => x[0] != "" && x[1] == searchFor.Value).ToList(); if (!sci.Any()) { continue; } foreach (var searchAgainst in research) { if (searchFor.Key.SimilarTo(searchAgainst[0]) && searchFor.Value == searchAgainst[2]) { UIMap.PopulationAndProduction.SelectResearchByCategory(searchFor.Value); StaticSleeper.Sleep(500); var res = UIMap.PopulationAndProduction.ResearchTable.GetTable(); for (int i = 0; i < res.Count; i++) { if (res[i][0] == searchAgainst[0]) { //ResearchTechCommand(searchFor.Value, i, 0, -1); //new MessageCommands(Settings).PrintFeedback(string.Format("[AutoResearch] Successfully selected research {0}.", searchFor.Key)); if (totalScientists > 1) { throw new NotImplementedException(); } //Timeline.AddEvent(BalanceResearch); return(true); } } break; } } } return(false); }
public void Begin(ILogger handler) { handler.Write("Beginning event manager."); if (Settings.ResearchFocuses != null && Settings.ResearchFocuses.Any()) { Settings.Research = Settings.ResearchFocuses["beamfocus"]; } _worker = new BackgroundWorker { WorkerSupportsCancellation = true }; _worker.DoWork += (sender, e) => { while (true) { if (_worker.CancellationPending) { handler.Write("Cancellation pending."); e.Cancel = true; break; } CompleteOneRound(handler); StaticSleeper.Sleep(1000); } }; _worker.RunWorkerCompleted += (sender, e) => { handler.Write("Stopping event manager."); if (e.Error != null) { handler.Error(e.Error.Message, e.Error.StackTrace); } }; _worker.RunWorkerAsync(); }
public void SelectResearchByCategory(string name) { if (name == "bio" || name == "bg") { SelectBiology(); } else if (name == "con" || name == "cp") { SelectConstruction(); } else if (name == "def" || name == "ds") { SelectDefensive(); } else if (name == "eng" || name == "ew") { SelectEnergy(); } else if (name == "log" || name == "lg") { SelectLogistics(); } else if (name == "mis" || name == "mk") { SelectMissiles(); } else if (name == "pow" || name == "pp") { SelectPower(); } else if (name == "sen" || name == "sf") { SelectSensors(); } StaticSleeper.Sleep(1000); Dirty(); }
protected override void OpenIfNotFound() { new BaseAuroraWindow(Screen, WindowFinder, InputDevice, Settings).MakeActive(); StaticSleeper.Sleep(1000); SendKeys.SendWait("^{F3}"); }