private void OnFishingEvent(object stateObj, FishingEventArgs e) { if (e.Event == FishingEvent.FishEaten) { _fishes.Add( e.Fish, new ColorAnimation(e.Fish.Sprite.Sprite, Color.TransparentWhite, 0.25f, Interpolation.InterpolateColor(Easing.Uniform))); } }
/// <summary> /// Displays the type of fish caught and its value. /// </summary> private void OnFishingEvent(object stateObj, FishingEventArgs e) { FishingState state = (FishingState)stateObj; switch (e.Event) { case FishingEvent.FishHooked: if (_showChainGuide && e.Fish.Description.Size == FishSize.Small && state.Lure != Lures.Basic) { _text.Show(Resources.GuideLureSmallFish); _textTimeout = new DelayAnimation(GuideTime); } if (e.Fish.Description.Size == FishSize.Large) { _text.Show(Resources.GuideReelInLarge); _textTimeout = new DelayAnimation(GuideTime); } break; case FishingEvent.FishEaten: if (_showChainGuide && e.Fish.Description.Size == FishSize.Small) { _showChainGuide = false; _text.Show(Resources.GuideLureMediumFish); _textTimeout = new DelayAnimation(GuideTime); } if (e.Fish.Description.Size == FishSize.Medium) { _text.Show(Resources.GuideReelInLarge); _textTimeout = new DelayAnimation(GuideTime); } break; case FishingEvent.LureBroke: _text.Show(Resources.GuideLureBroke); _textTimeout = new DelayAnimation(GuideTime); break; case FishingEvent.LureChanged: _text.Hide(); _showLureGuide = false; break; case FishingEvent.FishCaught: _text.Show(String.Format(Resources.Caught, e.Fish.Description.Name), e.Fish.Description.Value); _textTimeout = new DelayAnimation(CaughtTime); break; case FishingEvent.LureIsland: _text.Show(Resources.GuideReelInIsland); _textTimeout = new DelayAnimation(GuideTime); break; } }
/// <summary> /// Hide the fish after showing it off. /// </summary> private void OnFishingEvent(object stateObj, FishingEventArgs e) { if (e.Event == FishingEvent.FishCaught) { _fish = e.Fish; _fishAnimation = new SequentialAnimation( new DelayAnimation(4f), new ColorAnimation(_fish.Sprite.Sprite, Color.TransparentWhite, 1f, Interpolation.InterpolateColor(Easing.Uniform))); } else if (e.Event == FishingEvent.LureChanged) { CancelAnimation(); } }
/// <summary> /// Notifies this view that a fishing event (maybe a lure change) occured. /// </summary> private void OnFishingEvent(object fishing, FishingEventArgs args) { if (args.Event == FishingEvent.LureChanged) { float width = _sprite.Sprite.Size.X; TextSprite lureName = _sprite.GetSprite <TextSprite>("LureName"); lureName.Text = GetLureName(_state.Lure); lureName.Position = new Vector2((width - lureName.Size.X) / 2, lureName.Position.Y); _animation = _sprite.GetAnimation("ShowName"); _animation.Start(); Sprite selector = _sprite.GetSprite("Selector"); selector.Position = GetLureSprite(_state.Lure).Position; } }
/// <summary> /// Zooms in on caught fish. /// </summary> private void OnFishingEvent(object stateObj, FishingEventArgs e) { if (e.Event == FishingEvent.FishCaught) { _cameraAnimation = new SequentialAnimation( new CompositeAnimation( new PositionAnimation(_camera, GetFocusPosition(CatchFocus), CatchScaleTime, Interpolate), new ScaleAnimation(_camera, CatchScale, CatchScaleTime, Interpolate)), new DelayAnimation(CatchDelayTime), new CompositeAnimation( new PositionAnimation(_camera, GetFocusPosition(SwingFocus), CatchScaleTime, Interpolate), new ScaleAnimation(_camera, Vector2.One, CatchScaleTime, Interpolate))); } else if (e.Event == FishingEvent.LureChanged) { ResetForCast(); } else if (e.Event == FishingEvent.LureIsland) { _followLure = false; _followNPC = true; } }
private void OnFishingEvent(object stateObj, FishingEventArgs e) { switch (e.Event) { case FishingEvent.FishHooked: goto case FishingEvent.FishEaten; case FishingEvent.FishEaten: Vector2 vibration = GetLureFeedback(e.Fish); _context.Input.AddVibration(Vibrations.Constant(vibration.X, vibration.Y, 0.5f)); _lureHookedEffect.Play(0.3f, 0f, 0f); break; case FishingEvent.FishCaught: _caughtEffect.Play(0.4f, 0f, 0f); break; case FishingEvent.LureBroke: _context.Input.AddVibration(Vibrations.FadeOut(0.2f, 0.3f, 1f, Easing.Uniform)); _lureAnimation = new ColorAnimation(_lure, Color.TransparentWhite, 0.5f, InterpolateColor); _lureBrokeEffect.Play(0.8f, 0f, 0f); break; case FishingEvent.LureChanged: _lure = _state.LureSprites[_state.Lure]; _lureChangeEffect.Play(0.4f, 0f, 0f); break; case FishingEvent.RodChanged: _rod = _state.RodSprites[_state.Rod]; break; case FishingEvent.LureIsland: _islandEffect.Play(1f, 0f, 0f); break; } }
internal virtual void OnTrashCaught(FishingEventArgs e) { this.TrashCaught?.Invoke(this, e); }
internal void OnBeforeFishCatching(FishingEventArgs e) { this.BeforeFishCatching?.Invoke(this, e); }
private void OnPullFromNibble(FishingRod rod, Farmer user) { // Make sure this rod doesn't get the pullFishFromWater event overridden when it shouldn't be this.OverridingCatch.Add(rod); ModFishing.Instance.Monitor.Log("Overriding vanilla catch", LogLevel.Trace); if (rod == null) { throw new Exception("Fishing rod is null, please report this"); } if (user == null) { throw new Exception("User is null, please report this"); } // Get some info about the rod int clearWaterDistance = ModFishing.Instance.Helper.Reflection.GetField <int>(rod, "clearWaterDistance").GetValue(); GameLocation location = user.currentLocation; int?fish = null; // Check if legendary fish are being overridden as well if (!ModFishing.Instance.MainConfig.CustomLegendaries) { // Check if a legendary would be caught double baitValue = rod.attachments[0]?.Price / 10.0 ?? 0.0; bool bubblyZone = false; if (!(location.fishSplashPoint is null) && location.fishSplashPoint.Value != Point.Zero) { bubblyZone = new Rectangle(location.fishSplashPoint.X * 64, location.fishSplashPoint.Y * 64, 64, 64).Intersects(new Rectangle((int)rod.bobber.X - 80, (int)rod.bobber.Y - 80, 64, 64)); } // NotNull SObject normalFish = location.getFish(rod.fishingNibbleAccumulator, rod.attachments[0]?.ParentSheetIndex ?? -1, clearWaterDistance + (bubblyZone ? 1 : 0), user, baitValue + (bubblyZone ? 0.4 : 0.0)); // If so, select that fish if (ModFishing.Instance.Api.IsLegendary(normalFish.ParentSheetIndex)) { fish = normalFish.ParentSheetIndex; } } // Void mayonnaise if (location.Name.Equals("WitchSwamp") && !Game1.MasterPlayer.mailReceived.Contains("henchmanGone") && Game1.random.NextDouble() < 0.25 && !Game1.player.hasItemInInventory(308, 1)) { rod.pullFishFromWater(308, -1, 0, 0, false); return; } // Choose a random fish if one hasn't been chosen yet if (fish == null) { fish = FishHelper.GetRandomFish(user); } // Check if a fish was chosen if (fish == null) { // Secret note if (user.hasMagnifyingGlass && Game1.random.NextDouble() < 0.08) { SObject unseenSecretNote = location.tryToCreateUnseenSecretNote(user); if (unseenSecretNote != null) { rod.pullFishFromWater(unseenSecretNote.ParentSheetIndex, -1, 0, 0, false); return; } } // Trash int?trash = FishHelper.GetRandomTrash(user); if (trash.HasValue) { // Invoke event FishingEventArgs eventArgs = new FishingEventArgs(trash.Value, user, rod); ModFishing.Instance.Api.OnTrashCaught(eventArgs); trash = eventArgs.ParentSheetIndex; ModFishing.Instance.Monitor.Log($"Catching trash: {trash}", LogLevel.Trace); rod.pullFishFromWater(trash.Value, -1, 0, 0, false); } else { ModFishing.Instance.Monitor.Log($"No possible trash found for {location.Name}, using stone instead. This is probably caused by another mod removing trash data.", LogLevel.Warn); rod.pullFishFromWater(Objects.Stone, -1, 0, 0, false); } } else { // Invoke event FishingEventArgs eventArgs = new FishingEventArgs(fish.Value, user, rod); ModFishing.Instance.Api.OnBeforeFishCatching(eventArgs); fish = eventArgs.ParentSheetIndex; // Check if favBait should be set to true (still not sure what this does...) SObject fishObject = new SObject(fish.Value, 1); if (Math.Abs(fishObject.Scale.X - 1.0) < 0.001) { rod.favBait = true; } // Show hit animation rod.hit = true; ModFishing.Instance.Monitor.Log($"Catching fish: {fish}", LogLevel.Trace); Game1.screenOverlayTempSprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors", new Rectangle(612, 1913, 74, 30), 1500f, 1, 0, Game1.GlobalToLocal(Game1.viewport, rod.bobber.Value + new Vector2(-140f, -160f)), false, false, 1f, 0.005f, Color.White, 4f, 0.075f, 0.0f, 0.0f, true) { scaleChangeChange = -0.005f, motion = new Vector2(0.0f, -0.1f), endFunction = extra => this.StartMinigameEndFunction(rod, user, extra), extraInfoForEndBehavior = fish.Value }); location.localSound("FishHit"); } }
public override void update(GameTime time) { // Speed warp on catching fish float distanceFromCatching = this._distanceFromCatching.Value; float delta = distanceFromCatching - this._lastDistanceFromCatching; float mult = delta > 0 ? ModFishing.Instance.MainConfig.DifficultySettings.CatchSpeed : ModFishing.Instance.MainConfig.DifficultySettings.DrainSpeed; distanceFromCatching = this._lastDistanceFromCatching + delta * mult; this._lastDistanceFromCatching = distanceFromCatching; this._distanceFromCatching.Value = distanceFromCatching; // Speed warp on catching treasure float treasureCatchLevel = this._treasureCatchLevel.Value; delta = treasureCatchLevel - this._lastTreasureCatchLevel; mult = delta > 0 ? ModFishing.Instance.MainConfig.DifficultySettings.TreasureCatchSpeed : ModFishing.Instance.MainConfig.DifficultySettings.TreasureDrainSpeed; treasureCatchLevel = this._lastTreasureCatchLevel + delta * mult; this._lastTreasureCatchLevel = treasureCatchLevel; this._treasureCatchLevel.Value = treasureCatchLevel; bool perfect = this._perfect.Value; bool treasure = this._treasure.Value; bool treasureCaught = this._treasureCaught.Value; // Check if still perfect, otherwise apply changes to loot if (!this._perfectChanged && !perfect) { this._perfectChanged = true; this._fishQuality.Value = Math.Min(this._origQuality, ModFishing.Instance.MainConfig.DifficultySettings.PreventGoldOnNormalCatch ? 1 : 2); ModFishing.Instance.Api.SetStreak(this.User, 0); if (this._origStreak >= ModFishing.Instance.MainConfig.StreakSettings.StreakForIncreasedQuality) { Game1.showGlobalMessage(ModFishing.Translate(treasure ? "text.warnStreak" : "text.lostStreak", this._origStreak)); } } // Check if lost perfect, but got treasure if (!this._treasureChanged && !perfect && treasure && treasureCaught) { this._treasureChanged = true; int qualityBonus = (int)Math.Floor((double)this._origStreak / ModFishing.Instance.MainConfig.StreakSettings.StreakForIncreasedQuality); int quality = this._origQuality; quality = Math.Min(quality + qualityBonus, 3); if (quality == 3) { quality++; } this._fishQuality.Value = quality; } // Base call base.update(time); // Check if done fishing distanceFromCatching = this._distanceFromCatching.Value; if (this._notifiedFailOrSucceed) { return; } if (distanceFromCatching <= 0.0) { // Failed to catch fish this._notifiedFailOrSucceed = true; if (treasure) { this._notifiedFailOrSucceed = true; if (this._origStreak >= ModFishing.Instance.MainConfig.StreakSettings.StreakForIncreasedQuality) { Game1.showGlobalMessage(ModFishing.Translate("text.lostStreak", this._origStreak)); } } } else if (distanceFromCatching >= 1.0) { // Succeeded in catching the fish this._notifiedFailOrSucceed = true; if (perfect) { ModFishing.Instance.Api.SetStreak(this.User, this._origStreak + 1); } else if (treasure && treasureCaught) { if (this._origStreak >= ModFishing.Instance.MainConfig.StreakSettings.StreakForIncreasedQuality) { Game1.showGlobalMessage(ModFishing.Translate("text.keptStreak", this._origStreak)); } ModFishing.Instance.Api.SetStreak(this.User, this._origStreak); } // Invoke fish caught event int curFish = this._whichFish.Value; FishingEventArgs eventArgs = new FishingEventArgs(curFish, this.User, this.User.CurrentTool as FishingRod); ModFishing.Instance.Api.OnFishCaught(eventArgs); if (eventArgs.ParentSheetIndex != curFish) { this._whichFish.Value = eventArgs.ParentSheetIndex; } } }