public bool IsBite(Point currentBobberPosition) { if (!yPositions.Contains(currentBobberPosition.Y)) { yPositions.Add(currentBobberPosition.Y); yPositions.Sort(); } yDiff = yPositions[(int)((((double)yPositions.Count) + 0.5) / 2)] - currentBobberPosition.Y; bool thresholdReached = yDiff <= -strikeValue; timer.ExecuteIfDue(); if (thresholdReached) { RaiseEvent(new FishingEvent { Action = FishingAction.Loot }); timer.ExecuteNow(); return(true); } return(false); }
private Point FindBobber() { var timer = new TimedAction((a) => { logger.Info("Waited seconds for target: " + a.ElapsedSecs); }, 1000, 5); while (true) { var target = this.bobberFinder.Find(); if (target != Point.Empty || !timer.ExecuteIfDue()) { return(target); } } }
private void WaitForBite() { bobberFinder.Reset(); var bobberPosition = FindBobber(); if (bobberPosition == Point.Empty) { return; } this.biteWatcher.Reset(bobberPosition); logger.Info("Bobber start position: " + bobberPosition); var timedTask = new TimedAction((a) => { logger.Info("Fishing timed out!"); }, 25 * 1000, 25); // Wait for the bobber to move while (isEnabled) { var currentBobberPosition = FindBobber(); if (currentBobberPosition == Point.Empty || currentBobberPosition.X == 0) { return; } if (this.biteWatcher.IsBite(currentBobberPosition)) { Loot(bobberPosition); PressTenMinKeyIfDue(); return; } if (!timedTask.ExecuteIfDue()) { return; } } }