private void HookFish(FishingFish fish) { Service.Get <iOSHapticFeedback>().TriggerImpactFeedback(iOSHapticFeedback.ImpactFeedbackStyle.Medium); setGameplayState(FishingGameplayStates.Reel); _reelValue = 0f; reelSpring.SetSpringGoal(_reelValue, instant: true); for (int i = 0; i < _fishes.Count; i++) { if (fish == _fishes[i]) { _reelFishIndex = i; continue; } _fishes[i].SetVisible(isVisible: false); _fishes[i].SetActive(isActive: false); } Vector3 vector = rootTransform.TransformPoint(Vector3.forward * config.reelExtremes.x); Vector3 fishPosition = GetFishPosition(currentPatternConfig.hookInterp); float magnitude = (fishPosition - vector).magnitude; _innerReelExtreme = 0f - magnitude; CoroutineRunner.Start(loadPrizeAsset(fish.rarity), this, "loadPrizeAsset"); fxIdle.Stop(); fxUnderBobber.Stop(); fxHooked.Play(); fxReeling.Play(); playSoundEffect("SFX/Player/FishingRod/PullStartLoop"); if (_cameraDolly != null && _cameraDollyFocus != null) { _cameraDolly.Active = false; _cameraDollyFocus.Active = false; } }
private void reelIn(FishingFish fish) { eventDispatcher.RemoveListener <InputEvents.ActionEvent>(onActionEvent); eventDispatcher.DispatchEvent(default(FishingEvents.DeactivateBobberButton)); clickListener.OnClicked -= onScreenClicked; userControl.enabled = false; setGameplayState(FishingGameplayStates.Done); _fishes[_reelFishIndex].SetVisible(isVisible: false); if (fish != null && !isQuest) { minigameService.CatchFish(prizeNames[(int)fish.rarity]); Service.Get <ICPSwrveService>().Action("game.minigame.fishing", "success"); Service.Get <ICPSwrveService>().Action("game.fishing.reward", prizeNames[(int)fish.rarity]); } setGameModeInAnimators(FishingAnimationStates.Reel); if (fish != null) { Invoke("pullLineIn", config.ReelingAnimationTime); return; } Invoke("playFailedLookAnimation", 1f); EventManager.Instance.PostEvent("SFX/Player/FishingRod/PullStartLoop", EventAction.StopSound, base.gameObject); ShowFishingTryAgainPopup showFishingTryAgainPopup = new ShowFishingTryAgainPopup(config.TryAgainPopupShowTime, tooEarly: false); showFishingTryAgainPopup.PopupDismissed += onTryAgainPopupDismissed; showFishingTryAgainPopup.Init(); playSoundEffect("SFX/UI/Fishing/GotAwayOut"); Service.Get <ICPSwrveService>().Action("game.minigame.fishing", "failed"); }
private void hookAndReel() { if (_gameplayState == FishingGameplayStates.Catch) { if (!_isMissDelay) { FishingFish fish = GetFish(); if (fish != null) { HookFish(fish); } else { CoroutineRunner.Start(ExecuteMiss(), this, "ExecuteMiss"); } } } else if (_gameplayState == FishingGameplayStates.Reel) { playSoundEffect("SFX/Player/FishingRod/PullIn"); _reelValue -= config.perReelStrength; if (_reelValue <= _innerReelExtreme) { reelIn(_fishes[_reelFishIndex]); } reelSpring.SetSpringGoal(_reelValue); } }
private void LayoutFish() { int num = currentPatternConfig.fishPatternDatas.Length; for (int i = 0; i < num; i++) { if (!currentPatternConfig.fishPatternDatas[i].isEmpty) { FishingFish fishingFish = fishPrefab; if (_fishes.Count > 0) { fishingFish = UnityEngine.Object.Instantiate(fishPrefab); fishingFish.transform.SetParent(fishPrefab.transform.parent, worldPositionStays: false); } float offsetT = (float)i / ((float)num * 1f); fishingFish.Init(config, currentPatternConfig.fishPatternDatas[i], offsetT); fishingFish.SetActive(isActive: true); _fishes.Add(fishingFish); } } for (int i = 0; i < _fishes.Count; i++) { _fishes[i].SetVisible(isVisible: false, instant: true); _fishes[i].SetVisible(isVisible: true); } }
private void ScareFish() { Ray ray = new Ray(bobberRootTransform.position, Vector3.down); int num = Physics.SphereCastNonAlloc(ray, config.spherecastRadiusScare, _hits, config.spherecastDepth); for (int i = 0; i < num; i++) { FishingFish componentInParent = _hits[i].transform.GetComponentInParent <FishingFish>(); if (componentInParent != null) { componentInParent.Scare(); } } }
private FishingFish GetFish() { FishingFish result = null; Ray ray = new Ray(bobberRootTransform.position, Vector3.down); int num = Physics.SphereCastNonAlloc(ray, config.spherecastRadius, _hits, config.spherecastDepth); float num2 = -1f; for (int i = 0; i < num; i++) { FishingFish componentInParent = _hits[i].transform.GetComponentInParent <FishingFish>(); if (componentInParent != null) { float sqrMagnitude = (componentInParent.cachedTransform.position - ray.origin).sqrMagnitude; if (num2 < 0f || sqrMagnitude < num2) { num2 = sqrMagnitude; result = componentInParent; } } } return(result); }
private void Update() { if (_gameplayState == FishingGameplayStates.Catch) { _circleT += Time.deltaTime; for (int i = 0; i < _fishes.Count; i++) { FishingFish fishingFish = _fishes[i]; float t = _circleT * fishingFish.speed * config.baseFishSpeed * currentPatternConfig.baseSpeed + fishingFish.offsetT; Vector3 fishPosition = GetFishPosition(t); fishingFish.SetPosition(fishPosition); } bool flag = GetFish() != null; _bobberAnimator.SetBool(PARAM_IS_ATTACKING, flag); if (flag && !fxUnderBobber.isPlaying) { fxUnderBobber.Play(); eventDispatcher.DispatchEvent(default(FishingEvents.PulseBobberButton)); playSoundEffect("SFX/Player/FishingRod/NibbleBubbles"); } else if (!flag && fxUnderBobber.isPlaying) { fxUnderBobber.Stop(); eventDispatcher.DispatchEvent(default(FishingEvents.StopBobberButtonPulse)); } } else if (_gameplayState == FishingGameplayStates.Reel) { float num = config.baseFishReelStrength * _fishes[_reelFishIndex].reelStrength; _reelValue += Time.deltaTime * num; if (_reelValue >= config.reelExtremes.y) { reelIn(null); } reelSpring.SetSpringGoal(_reelValue); } }