using RootMotion.FinalIK; using UnityEngine; public class Reel : MonoBehaviour { public AudioSource _audioSourceReeling; public AudioSource _audioSourceLineOut; public AudioSource _audioSourceLineOutByThrowing; public float maxReelStrength = 5f; [HideInInspector] public float currentReelStrength; [SerializeField] public float reelingSpeed = 1f; [SerializeField] public float reelingDrag = 1f; public bool isDamage; private float reelSpeedFactor = 2f; private float reelSpeedStep = 0.05f; private float reelSpeedMax = 1f; private float reelSpeedMin = 0.1f; private float reelDragStep = 0.1f; public InteractionObject interactionObject; public InteractionObject interactionUnlockObject; [HideInInspector] public Rod currentRod; public bool isKablagOpen; public Animator animator; public GameObject szpulaObject; public Transform SzpulaLinepoint_0; public Transform SzpulaLinepoint_1; private void Start() { } private void Update() { if (currentRod == null || ScriptsHandler.Instance == null || ScriptsHandler.Instance.m_PlayerMain == null || SRDebug.Instance.IsDebugPanelVisible) { return; } if (ScriptsHandler.Instance.m_PlayerMain.currentRightHandObject == currentRod.gameObject) { if (!isDamage) { if (InputManager.isReelSpeedUp) { reelingSpeed += reelSpeedStep; } if (InputManager.isReelSpeedDown) { reelingSpeed -= reelSpeedStep; } reelingSpeed = Mathf.Clamp(reelingSpeed, reelSpeedMin, reelSpeedMax); if (InputManager.isReelDragUp) { reelingDrag += reelDragStep; } if (InputManager.isReelDragDown) { reelingDrag -= reelDragStep; } reelingDrag += Input.mouseScrollDelta.y * reelDragStep; reelingDrag = Mathf.Clamp(reelingDrag, 0f, 1f); } else { reelingDrag = 0f; } if (InputManager.isReelReeling && ScriptsHandler.Instance.m_InteractionControl.LeftHandInteractionWithReel && currentRod.fishingLine.ropeOut > 0f) { animator.SetFloat("Reeling", reelingSpeed * reelSpeedFactor); currentRod.fishingLine.RollLine(reelingSpeed * reelSpeedFactor * 0.5f); ScriptsHandler.Instance.m_PlayerMain.ReelindAddactiveAnim(reelingSpeed * reelSpeedFactor); if (_audioSourceReeling.enabled) { if (!_audioSourceReeling.isPlaying) { _audioSourceReeling.Play(); } if (_audioSourceReeling.isPlaying) { _audioSourceReeling.pitch = Mathf.Clamp(reelingSpeed * reelSpeedFactor, 1f, 2f); } } UnlockKablag(val: false); } else { animator.SetFloat("Reeling", 0f); ScriptsHandler.Instance.m_PlayerMain.ReelindAddactiveAnim(0f); if (_audioSourceReeling.enabled && _audioSourceReeling.isPlaying) { _audioSourceReeling.Stop(); } } CalculateReelStrenght(); } if (currentRod.fishingLine.ropeTension > reelingDrag && !ScriptsHandler.Instance.m_PlayerMain.preCastNearFlag && !ScriptsHandler.Instance.m_PlayerMain.preCastFarFlag) { float num = Time.deltaTime * (3f - reelingDrag); currentRod.fishingLine.ropeOut += num; animator.SetFloat("LineOut", num * 30f); if (_audioSourceLineOut.enabled) { if (!_audioSourceLineOut.isPlaying) { _audioSourceLineOut.Play(); } if (_audioSourceLineOut.isPlaying) { _audioSourceLineOut.pitch = 2f - num; } } } else { animator.SetFloat("LineOut", 0f); if (_audioSourceLineOut.enabled && _audioSourceLineOut.isPlaying) { _audioSourceLineOut.Stop(); } } if (!(currentRod != null)) { return; } if (currentRod.isTrowing) { if (!_audioSourceLineOutByThrowing.isPlaying && _audioSourceLineOutByThrowing.enabled) { _audioSourceLineOutByThrowing.Play(); } animator.SetBool("LineOutunlock", value: true); } else { animator.SetBool("LineOutunlock", value: false); } } public void Damage() { Singleton.Instance.GetCurrentPlayerData().PlayerSlotsEquip[currentRod.indexOfslot].SetWearRodReel(GameManager.ItemType.Reel, 0); isDamage = true; } public void UnlockKablag(bool val) { if (val) { RebindAnim(); } animator.SetBool("Unlock", val); isKablagOpen = val; } public void RebindAnim() { animator.Rebind(); isKablagOpen = false; } private void CalculateReelStrenght() { currentReelStrength = currentRod.fishingLine.ropeTension * currentRod.fishingLine.lineMaxStrength / maxReelStrength * reelingDrag; currentReelStrength = Mathf.Clamp(currentReelStrength, 0f, 1f); } }