1453 lines
40 KiB
C#
1453 lines
40 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Lean.Pool;
|
|
using UFS2.ScriptableObjects;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
public class FFish : MonoBehaviour
|
|
{
|
|
[Serializable]
|
|
public class FishHookEvent : UnityEvent<Transform>
|
|
{
|
|
}
|
|
|
|
[SerializeField]
|
|
private FishData data;
|
|
|
|
public GameManager.FishSpecies fishSpecies;
|
|
|
|
public float fishWeight = 0.2f;
|
|
|
|
public float fishStrenght = 1f;
|
|
|
|
public float fishStamina = 1f;
|
|
|
|
private float attackAgresive = 2.5f;
|
|
|
|
public SkinnedMeshRenderer m_Renderer;
|
|
|
|
public Transform leftHandHandlerFishView;
|
|
|
|
public Transform rightHandHandlerFishView;
|
|
|
|
[HideInInspector]
|
|
public bool isFishView;
|
|
|
|
[HideInInspector]
|
|
public FRod currentRod;
|
|
|
|
public Transform baitContainer;
|
|
|
|
public SpringJoint joiner;
|
|
|
|
public Transform jointAnchor;
|
|
|
|
[HideInInspector]
|
|
private Rigidbody currentJoinObject;
|
|
|
|
private Collider colider;
|
|
|
|
public float waterDrag = 3f;
|
|
|
|
public bool isInWater;
|
|
|
|
private bool isTake;
|
|
|
|
private float takeTimer;
|
|
|
|
private float dropTimer = 2f;
|
|
|
|
private float takeDelay;
|
|
|
|
private float angularVelocityY;
|
|
|
|
public float objectDisplacement;
|
|
|
|
private Animator animator;
|
|
|
|
[HideInInspector]
|
|
public Rigidbody rigidbody;
|
|
|
|
private float waterHeightPosition;
|
|
|
|
private float normalDrag;
|
|
|
|
[SerializeField]
|
|
private float speed;
|
|
|
|
[SerializeField]
|
|
private float timeMove;
|
|
|
|
private float timeCatch;
|
|
|
|
private float timeToTake;
|
|
|
|
[HideInInspector]
|
|
public Vector3 TargetPoint;
|
|
|
|
[HideInInspector]
|
|
public FFishSystem fFishSystem;
|
|
|
|
public Transform currentSearchBaitLure;
|
|
|
|
[HideInInspector]
|
|
public FLure currentSearchLure;
|
|
|
|
private FHook currentSearchHook;
|
|
|
|
[HideInInspector]
|
|
public Rigidbody currentBaitLure;
|
|
|
|
private Vector3 startPosition;
|
|
|
|
public ParticleSystem bubbleParticle;
|
|
|
|
public bool isGetFish;
|
|
|
|
[HideInInspector]
|
|
public float getFishCounter;
|
|
|
|
private float jumpDelay = 5f;
|
|
|
|
private bool isFeeding;
|
|
|
|
private float timeFeeding = 30f;
|
|
|
|
[HideInInspector]
|
|
public FishFeedingZone currentFeedingZone;
|
|
|
|
[HideInInspector]
|
|
public int feedingZoneMoveState;
|
|
|
|
private TextMesh currentDebugText;
|
|
|
|
[HideInInspector]
|
|
public float TimerToDisable;
|
|
|
|
[HideInInspector]
|
|
public List<Material> orginalMaterials;
|
|
|
|
public float fightingTime;
|
|
|
|
private bool fishingReel;
|
|
|
|
private float pullingTime;
|
|
|
|
private float pullUpStaminaDrop = 2f;
|
|
|
|
private float normalStaminaDrop = 0.5f;
|
|
|
|
public FishHookEvent OnFishHookUnityEvent;
|
|
|
|
private float exhaustedMod = 1f;
|
|
|
|
private bool isExhausted;
|
|
|
|
private float lastTimeCreateSplash;
|
|
|
|
private float currentSmoothiess = -1f;
|
|
|
|
private bool switchEagle;
|
|
|
|
private Vector3 nextTargetPosition = Vector3.zero;
|
|
|
|
private Vector3 lastValidPosition = Vector3.zero;
|
|
|
|
private bool forceToLastValidPosition;
|
|
|
|
private Transform _PlayerTransform;
|
|
|
|
private float checkUnhookTimer = 1f;
|
|
|
|
private float randomSpeed;
|
|
|
|
private float _StaminaBoostLastTime = -1f;
|
|
|
|
private int _MaxStaminaBoosts = 3;
|
|
|
|
private float _LastDistanceToRod = -1f;
|
|
|
|
private float exhaustedMoveTime = -1f;
|
|
|
|
private Vector3[] randomMoveList = new Vector3[3]
|
|
{
|
|
Vector3.up,
|
|
Vector3.down,
|
|
Vector3.zero
|
|
};
|
|
|
|
private bool isShowWaterFX = true;
|
|
|
|
private GameObject firstPoint;
|
|
|
|
public float FishStamina => fishStamina / fishWeight;
|
|
|
|
public static event Action<FFish> OnInwaterEnter;
|
|
|
|
public static event Action<FFish> OnInwaterExit;
|
|
|
|
public static event Action<FFish> OnDestroyed;
|
|
|
|
public static event Action<FFish> OnDisabled;
|
|
|
|
public static event Action<FFish> OnFishHook;
|
|
|
|
public static event Action<Transform> OnFishHookUnityEventGlobal;
|
|
|
|
private void StaminaMoveTowards(float mod = 1f)
|
|
{
|
|
FReel currentReel = currentRod.currentReel;
|
|
float num = ((fishWeight > 150f) ? 1.5f : 1f);
|
|
float num2 = currentReel.reelingDrag * currentReel.maxReelStrength;
|
|
fishStamina -= num2 * num * mod * 0.016f * Time.deltaTime * FishDebugger.ForceMod;
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
colider = GetComponent<Collider>();
|
|
animator = GetComponent<Animator>();
|
|
rigidbody = GetComponent<Rigidbody>();
|
|
joiner = GetComponent<SpringJoint>();
|
|
normalDrag = 1f;
|
|
startPosition = base.transform.position;
|
|
waterHeightPosition = 0f;
|
|
orginalMaterials = new List<Material>();
|
|
orginalMaterials.AddRange(m_Renderer.sharedMaterials);
|
|
base.transform.SetAsFirstSibling();
|
|
RandomNewDstPointFreeMove();
|
|
if (base.transform.position.y < 0f && !fFishSystem.isNewSpawnerSystem)
|
|
{
|
|
StartCoroutine(SetDisable());
|
|
}
|
|
fightingTime = 0f;
|
|
fishStamina = fishWeight;
|
|
}
|
|
|
|
private IEnumerator SetDisable()
|
|
{
|
|
yield return null;
|
|
base.gameObject.SetActive(value: false);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (isFishView)
|
|
{
|
|
rigidbody.isKinematic = true;
|
|
animator.SetFloat("speed", 0f);
|
|
animator.SetBool("fishView", value: true);
|
|
if ((bool)currentDebugText)
|
|
{
|
|
UnityEngine.Object.Destroy(currentDebugText);
|
|
}
|
|
return;
|
|
}
|
|
if ((bool)currentRod && (bool)currentRod.currentPlayer && (bool)currentRod.currentPlayer.currentChwytak)
|
|
{
|
|
if (rigidbody.constraints != RigidbodyConstraints.FreezeRotationZ)
|
|
{
|
|
rigidbody.constraints = RigidbodyConstraints.FreezeRotationZ;
|
|
rigidbody.rotation = Quaternion.identity;
|
|
}
|
|
}
|
|
else if (rigidbody.constraints != RigidbodyConstraints.None)
|
|
{
|
|
rigidbody.constraints = RigidbodyConstraints.None;
|
|
}
|
|
if (fishStamina <= 0f)
|
|
{
|
|
if (!isExhausted)
|
|
{
|
|
isExhausted = true;
|
|
}
|
|
if (base.transform.position.y < 0f)
|
|
{
|
|
TryExhaustedMove(UnityEngine.Random.Range(1f, 2f));
|
|
animator.SetFloat("speed", rigidbody.velocity.magnitude * 0.5f);
|
|
animator.SetFloat("AngularVelocityY", rigidbody.angularVelocity.magnitude);
|
|
if (colider != null)
|
|
{
|
|
float num = colider.bounds.size.magnitude * 0.25f;
|
|
if (base.transform.position.y < 0f - num)
|
|
{
|
|
animator.SetBool("jump", value: false);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
float current = animator.GetFloat("speed");
|
|
current = Mathf.MoveTowards(current, 3f, Time.deltaTime);
|
|
animator.SetFloat("speed", current);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
FreeMoveNew();
|
|
}
|
|
FightingRealistic();
|
|
ShowWaterFX();
|
|
jumpDelay = Mathf.MoveTowards(jumpDelay, 0f, Time.deltaTime);
|
|
TimerToDisable = Mathf.MoveTowards(TimerToDisable, 0f, Time.deltaTime);
|
|
fishStamina = Mathf.Clamp(fishStamina, 0f, float.PositiveInfinity);
|
|
UnJoinFishHandler();
|
|
}
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
CheckIsWater();
|
|
SplashUpdate();
|
|
if (m_Renderer.enabled)
|
|
{
|
|
if (base.transform.position.y < 0.2f)
|
|
{
|
|
SetMaterialSmootness(0.1f);
|
|
}
|
|
else
|
|
{
|
|
SetMaterialSmootness(0.8f);
|
|
}
|
|
}
|
|
if (isFishView)
|
|
{
|
|
return;
|
|
}
|
|
if (!isGetFish)
|
|
{
|
|
if (animator.runtimeAnimatorController != null)
|
|
{
|
|
float num = ((fishStamina == 0f) ? 0.15f : speed);
|
|
if (isInWater)
|
|
{
|
|
animator.SetFloat("speed", num * 0.25f);
|
|
animator.SetFloat("AngularVelocityY", angularVelocityY);
|
|
}
|
|
else
|
|
{
|
|
animator.SetFloat("speed", 0.1f);
|
|
animator.SetFloat("AngularVelocityY", 0f);
|
|
}
|
|
}
|
|
}
|
|
else if (animator.runtimeAnimatorController != null)
|
|
{
|
|
animator.SetFloat("speed", 0.1f);
|
|
animator.SetFloat("AngularVelocityY", 0f);
|
|
}
|
|
}
|
|
|
|
private void UnJoinFishHandler()
|
|
{
|
|
if ((bool)currentRod && isTake && !currentRod.currentFish)
|
|
{
|
|
takeTimer += Time.deltaTime;
|
|
if (takeTimer > dropTimer)
|
|
{
|
|
UnJoinFish();
|
|
takeTimer = 0f;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void PlaySoundFight()
|
|
{
|
|
UnityEngine.Random.Range(0, FScriptsHandler.Instance.fishBubbleSound.Length - 1);
|
|
}
|
|
|
|
private void SetMaterialSmootness(float value)
|
|
{
|
|
if (currentSmoothiess != value)
|
|
{
|
|
Material[] materials = m_Renderer.materials;
|
|
for (int i = 0; i < materials.Length; i++)
|
|
{
|
|
materials[i].SetFloat("_GlossMapScale", value);
|
|
}
|
|
currentSmoothiess = value;
|
|
}
|
|
}
|
|
|
|
private void SetNewFeedingZoneDst()
|
|
{
|
|
if (fFishSystem == null)
|
|
{
|
|
fFishSystem = UnityEngine.Object.FindObjectOfType<FFishSystem>();
|
|
}
|
|
if (!(currentFeedingZone == null))
|
|
{
|
|
currentFeedingZone = currentFeedingZone.fFishSystem.GetNewTargetFeedingZone(this);
|
|
}
|
|
}
|
|
|
|
private void SetAngularAnim(Vector3 targetPosition)
|
|
{
|
|
float num = Vector3.Angle(targetPosition - base.transform.position, base.transform.forward);
|
|
if (angularVelocityY == 0f && ((num > -80f && num < 80f && speed > 0.8f) || rigidbody.angularVelocity.sqrMagnitude > 1f))
|
|
{
|
|
if (rigidbody.angularVelocity.sqrMagnitude > 1f)
|
|
{
|
|
angularVelocityY = rigidbody.angularVelocity.sqrMagnitude;
|
|
}
|
|
else
|
|
{
|
|
angularVelocityY = num;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
angularVelocityY = 0f;
|
|
}
|
|
}
|
|
|
|
private Vector3 RandomSphereMovePoint()
|
|
{
|
|
return base.transform.position + UnityEngine.Random.onUnitSphere * UnityEngine.Random.Range(2f, 20f);
|
|
}
|
|
|
|
private void SearchingBait()
|
|
{
|
|
if (((bool)TutorialManager.Instance && TutorialManager.Instance.acctualLessonIndex < 4) || takeDelay > 0f)
|
|
{
|
|
return;
|
|
}
|
|
for (int i = 0; i < fFishSystem.inwaterObjects.Count; i++)
|
|
{
|
|
if (!(fFishSystem.inwaterObjects[i].tag == "BaitLure") || fFishSystem.inwaterObjects[i].isFreeze)
|
|
{
|
|
continue;
|
|
}
|
|
if (Vector3.Distance(fFishSystem.inwaterObjects[i].transform.position, FScriptsHandler.Instance.m_PlayerMain.transform.position) < 7f)
|
|
{
|
|
break;
|
|
}
|
|
float distanceToFish = Vector3.Distance(base.transform.position, fFishSystem.inwaterObjects[i].transform.position);
|
|
if (!TutorialManager.Instance)
|
|
{
|
|
float num = Vector3.Angle(fFishSystem.inwaterObjects[i].transform.position - base.transform.position, base.transform.forward);
|
|
if (num < -90f || num > 90f)
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
if (!Singleton<SaveDataManager>.Instance.HasCurrentPlayerSkill(GameManager.Skills.attractive_player_10p))
|
|
{
|
|
Singleton<SaveDataManager>.Instance.HasCurrentPlayerSkill(GameManager.Skills.attractive_player_5p);
|
|
}
|
|
if (fFishSystem.inwaterObjects[i].TryGetComponent<FHook>(out var component))
|
|
{
|
|
if (component.isLookingDisable)
|
|
{
|
|
currentSearchBaitLure = null;
|
|
continue;
|
|
}
|
|
if (!component.currentRod)
|
|
{
|
|
currentSearchBaitLure = null;
|
|
continue;
|
|
}
|
|
if (!component.currentRod.currentBait)
|
|
{
|
|
currentSearchBaitLure = null;
|
|
continue;
|
|
}
|
|
if (component.currentRod.fishingLine.currentLineHandler.PhisicsLineOut < 2f)
|
|
{
|
|
currentSearchBaitLure = null;
|
|
continue;
|
|
}
|
|
List<GameManager.AcceptFishBait> list = new List<GameManager.AcceptFishBait>();
|
|
for (int j = 0; j < GameManager.Instance.gameFish.Length; j++)
|
|
{
|
|
if (GameManager.Instance.gameFish[j].speciesName != fishSpecies || GameManager.Instance.gameFish[j].acceptFishBaits.Count == 0)
|
|
{
|
|
continue;
|
|
}
|
|
for (int k = 0; k < GameManager.Instance.gameFish[j].acceptFishBaits.Count; k++)
|
|
{
|
|
if (GameManager.Instance.gameFish[j].acceptFishBaits[k].baitId == GameManager.Instance.GetIndexByItemId(GameManager.ItemType.Bait, component.currentRod.currentBait.gameID))
|
|
{
|
|
if (!list.Contains(GameManager.Instance.gameFish[j].acceptFishBaits[k]))
|
|
{
|
|
Debug.Log("Bait fit - Added to take: " + GameManager.Instance.gameFish[j]);
|
|
list.Add(GameManager.Instance.gameFish[j].acceptFishBaits[k]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("Bait dosnt match - Continue: " + GameManager.Instance.gameFish[j]);
|
|
}
|
|
}
|
|
}
|
|
if (list.Count == 0)
|
|
{
|
|
Debug.Log("fish: " + fishSpecies.ToString() + " " + fishWeight + "kg. Fish not accept bait");
|
|
currentSearchBaitLure = null;
|
|
break;
|
|
}
|
|
float num2 = UnityEngine.Random.Range(0f, 1f);
|
|
if (num2 < list[0].min || num2 > list[0].max)
|
|
{
|
|
Debug.Log("fish: " + fishSpecies.ToString() + " " + fishWeight + "kg. lure has low efficiency");
|
|
currentSearchBaitLure = null;
|
|
break;
|
|
}
|
|
if (component.rigidbody.velocity.magnitude > 0.2f)
|
|
{
|
|
currentSearchBaitLure = null;
|
|
continue;
|
|
}
|
|
Vector2 zero = Vector2.zero;
|
|
zero = GameManager.Instance.gameHooks[GameManager.Instance._playerData.GetGameItemIndexByItemId(GameManager.ItemType.Hook, component.gameID)].GetFishAcceptWeightBySize();
|
|
Vector2 vector = zero;
|
|
Debug.Log("hookFishSizeAccept: " + vector.ToString());
|
|
if (fishWeight < zero.x || fishWeight > zero.y)
|
|
{
|
|
string[] obj = new string[6]
|
|
{
|
|
"Nie prawidlowy rozmiar haczyka: ",
|
|
fishSpecies.ToString(),
|
|
" ",
|
|
fishWeight.ToString(),
|
|
"kg. hook range:",
|
|
null
|
|
};
|
|
vector = zero;
|
|
obj[5] = vector.ToString();
|
|
Debug.Log(string.Concat(obj));
|
|
component.hookNotAcceptFishCounter++;
|
|
currentSearchBaitLure = null;
|
|
continue;
|
|
}
|
|
if (Vector3.Distance(component.currentRod.transform.position, base.transform.position) < 8f && fishWeight > 2f)
|
|
{
|
|
currentSearchBaitLure = null;
|
|
continue;
|
|
}
|
|
if (!component.currentRod.currentBait.CheckBaitEfficacy(distanceToFish))
|
|
{
|
|
currentSearchBaitLure = null;
|
|
continue;
|
|
}
|
|
currentSearchHook = component;
|
|
base.transform.LookAt(component.transform.position);
|
|
}
|
|
if (fFishSystem.inwaterObjects[i].TryGetComponent<FLure>(out var component2))
|
|
{
|
|
if (component2.isLookingDisable)
|
|
{
|
|
currentSearchBaitLure = null;
|
|
continue;
|
|
}
|
|
if (!component2.currentRod)
|
|
{
|
|
currentSearchBaitLure = null;
|
|
continue;
|
|
}
|
|
if (!component2.currentRod.currentLure)
|
|
{
|
|
currentSearchBaitLure = null;
|
|
continue;
|
|
}
|
|
if (component2.currentRod.fishingLine.currentLineHandler.PhisicsLineOut < 2f)
|
|
{
|
|
currentSearchBaitLure = null;
|
|
continue;
|
|
}
|
|
if (!currentFeedingZone.fishTakeTesting)
|
|
{
|
|
List<GameManager.AcceptFishBait> list2 = new List<GameManager.AcceptFishBait>();
|
|
for (int l = 0; l < GameManager.Instance.gameFish.Length; l++)
|
|
{
|
|
if (GameManager.Instance.gameFish[l].speciesName != fishSpecies || GameManager.Instance.gameFish[l].acceptFishLures.Count == 0)
|
|
{
|
|
continue;
|
|
}
|
|
for (int m = 0; m < GameManager.Instance.gameFish[l].acceptFishLures.Count; m++)
|
|
{
|
|
if (GameManager.Instance.gameFish[l].acceptFishLures[m].baitId == GameManager.Instance.GetIndexByItemId(GameManager.ItemType.Bait, component2.currentRod.currentLure.gameID))
|
|
{
|
|
if (!list2.Contains(GameManager.Instance.gameFish[l].acceptFishLures[m]))
|
|
{
|
|
Debug.Log("Bait fit - Added to take");
|
|
list2.Add(GameManager.Instance.gameFish[l].acceptFishLures[m]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("Bait dosnt match - Continue");
|
|
}
|
|
}
|
|
}
|
|
if (list2.Count == 0)
|
|
{
|
|
Debug.Log("fish: " + fishSpecies.ToString() + " " + fishWeight + "kg. Fish not accept bait");
|
|
currentSearchBaitLure = null;
|
|
break;
|
|
}
|
|
float num3 = UnityEngine.Random.Range(0f, 1f);
|
|
if (num3 < list2[0].min || num3 > list2[0].max)
|
|
{
|
|
Debug.Log("fish: " + fishSpecies.ToString() + " " + fishWeight + "kg. lure has low efficiency");
|
|
currentSearchBaitLure = null;
|
|
break;
|
|
}
|
|
if (!component2.CheckBaitEfficacy(distanceToFish))
|
|
{
|
|
Debug.Log("Lure efficacy low");
|
|
currentSearchBaitLure = null;
|
|
continue;
|
|
}
|
|
}
|
|
Debug.Log("Search lure success");
|
|
currentSearchLure = component2;
|
|
base.transform.LookAt(component2.transform.position);
|
|
}
|
|
currentSearchBaitLure = fFishSystem.inwaterObjects[i].transform;
|
|
takeDelay = UnityEngine.Random.Range(2f, 5f);
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void GetFish()
|
|
{
|
|
if (animator.runtimeAnimatorController != null)
|
|
{
|
|
animator.SetBool("jump", value: false);
|
|
animator.SetFloat("AngularVelocityY", 0f);
|
|
}
|
|
isGetFish = true;
|
|
speed = 0f;
|
|
rigidbody.mass = 3f;
|
|
rigidbody.useGravity = true;
|
|
rigidbody.drag = normalDrag;
|
|
rigidbody.angularDrag = normalDrag * 0.2f;
|
|
GetComponent<Collider>().enabled = false;
|
|
ReJoinInOutWater();
|
|
}
|
|
|
|
private bool CheckUnnhookFish()
|
|
{
|
|
if ((bool)TutorialManager.Instance)
|
|
{
|
|
return false;
|
|
}
|
|
if (isGetFish)
|
|
{
|
|
return false;
|
|
}
|
|
if (Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().GameMode == GameManager.PlayerData.CPlayer.GameMode.Normal)
|
|
{
|
|
return false;
|
|
}
|
|
timeCatch += Time.deltaTime;
|
|
checkUnhookTimer = Mathf.MoveTowards(checkUnhookTimer, 0f, Time.deltaTime);
|
|
if (checkUnhookTimer > 0f)
|
|
{
|
|
return false;
|
|
}
|
|
checkUnhookTimer = 30f;
|
|
float num = timeCatch * 0.02f;
|
|
if (Vector3.Distance(base.transform.position, currentRod.transform.position) < 10f)
|
|
{
|
|
return false;
|
|
}
|
|
Vector2 vector = Vector2.zero;
|
|
if ((bool)currentRod.currentHook)
|
|
{
|
|
vector = GameManager.Instance.gameHooks[GameManager.Instance._playerData.GetGameItemIndexByItemId(GameManager.ItemType.Hook, currentRod.currentHook.gameID)].GetFishAcceptWeightBySize();
|
|
}
|
|
if ((bool)currentRod.currentLure)
|
|
{
|
|
vector = GameManager.Instance.gameBaits[GameManager.Instance._playerData.GetGameItemIndexByItemId(GameManager.ItemType.Bait, currentRod.currentLure.gameID)].weightFishAccept;
|
|
}
|
|
float num2 = 0f;
|
|
if (fishWeight < vector.x)
|
|
{
|
|
num2 = vector.x - fishWeight;
|
|
}
|
|
else if (fishWeight > vector.y)
|
|
{
|
|
num2 = fishWeight - vector.y;
|
|
}
|
|
num += num2 * 5f;
|
|
if ((bool)currentRod.currentHook && GameManager.Instance.gameHooks[GameManager.Instance._playerData.GetGameItemIndexByItemId(GameManager.ItemType.Hook, currentRod.currentHook.gameID)].zadzior != GameManager.GameHooks.Zadzior.None && num > 30f && num2 < 1f)
|
|
{
|
|
num -= 30f;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private void TryAddBoostStamina()
|
|
{
|
|
if (isGetFish || fishStamina > 0f || _MaxStaminaBoosts <= 0)
|
|
{
|
|
return;
|
|
}
|
|
float num = Vector3.Distance(base.transform.position, currentRod.transform.position);
|
|
float num2 = 5f;
|
|
if (!(num < num2))
|
|
{
|
|
_LastDistanceToRod = ((_LastDistanceToRod == -1f) ? num : _LastDistanceToRod);
|
|
_StaminaBoostLastTime = ((_StaminaBoostLastTime == -1f) ? (UnityEngine.Random.Range(7f, 15f) + Time.time) : _StaminaBoostLastTime);
|
|
if (Time.time >= _StaminaBoostLastTime && num < _LastDistanceToRod)
|
|
{
|
|
float num3 = ((_MaxStaminaBoosts > 0) ? (fishWeight * (float)_MaxStaminaBoosts * 0.1f) : (fishWeight * 0.01f));
|
|
fishStamina += num3;
|
|
_MaxStaminaBoosts--;
|
|
_StaminaBoostLastTime = -1f;
|
|
_LastDistanceToRod *= 0.5f;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void TryExhaustedMove(float force)
|
|
{
|
|
_ = base.transform.position;
|
|
rigidbody.isKinematic = false;
|
|
rigidbody.angularDrag = 0.55f;
|
|
rigidbody.drag = 1f;
|
|
rigidbody.mass = Mathf.Clamp(fishWeight, 1f, 40f);
|
|
if (exhaustedMoveTime == -1f)
|
|
{
|
|
exhaustedMoveTime = UnityEngine.Random.Range(1f, 3f) + Time.time;
|
|
}
|
|
if (Time.time > exhaustedMoveTime)
|
|
{
|
|
Vector3 vector = randomMoveList[UnityEngine.Random.Range(0, randomMoveList.Length)];
|
|
Vector3 vector2 = -base.transform.forward + vector;
|
|
rigidbody.AddForce(vector2 * force * exhaustedMod, ForceMode.Impulse);
|
|
rigidbody.AddTorque(base.transform.up * force * exhaustedMod, ForceMode.Impulse);
|
|
exhaustedMod = Mathf.Clamp(exhaustedMod - 0.1f, 0.01f, 1f);
|
|
exhaustedMoveTime = -1f;
|
|
}
|
|
if (!(colider == null) && !isGetFish)
|
|
{
|
|
float num = Mathf.Clamp(colider.bounds.size.magnitude * 1.5f, 0f, colider.bounds.size.magnitude * 2.5f);
|
|
if (base.transform.position.y > num)
|
|
{
|
|
rigidbody.velocity *= 0.65f;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void FreeMoveNew()
|
|
{
|
|
if (isGetFish)
|
|
{
|
|
return;
|
|
}
|
|
_PlayerTransform = (_PlayerTransform ? _PlayerTransform : UnityEngine.Object.FindObjectOfType<FScriptsHandler>().m_PlayerMain.transform);
|
|
takeDelay = Mathf.MoveTowards(takeDelay, 0f, Time.deltaTime);
|
|
timeMove = Mathf.MoveTowards(timeMove, 0f, Time.deltaTime);
|
|
if ((bool)currentSearchBaitLure)
|
|
{
|
|
if ((bool)currentSearchHook && currentSearchHook.isLookingDisable)
|
|
{
|
|
currentSearchBaitLure = null;
|
|
}
|
|
if ((bool)currentSearchLure && currentSearchLure.isLookingDisable)
|
|
{
|
|
currentSearchBaitLure = null;
|
|
}
|
|
}
|
|
if (!isInWater)
|
|
{
|
|
return;
|
|
}
|
|
rigidbody.isKinematic = false;
|
|
rigidbody.mass = fishWeight * 10f;
|
|
rigidbody.angularDrag = 3f;
|
|
rigidbody.useGravity = false;
|
|
float num = 0f - Mathf.Clamp01(fishWeight) * 0.5f;
|
|
if (forceToLastValidPosition && lastValidPosition != Vector3.zero)
|
|
{
|
|
Quaternion b = Quaternion.LookRotation(lastValidPosition - base.transform.position);
|
|
float num2 = Vector3.Distance(base.transform.position, lastValidPosition);
|
|
rigidbody.rotation = Quaternion.Slerp(rigidbody.rotation, b, Time.deltaTime * (5f + speed));
|
|
if (!joiner || !(currentRod.currentReel.reelingDrag > 0.99f))
|
|
{
|
|
rigidbody.transform.Translate(Vector3.forward * Time.deltaTime * speed);
|
|
speed = Mathf.MoveTowards(speed, Mathf.Clamp01(num2) * 0.25f + 0.1f, Time.deltaTime);
|
|
SetAngularAnim(lastValidPosition);
|
|
if (num2 < 0.2f || timeMove == 0f)
|
|
{
|
|
forceToLastValidPosition = false;
|
|
}
|
|
else if ((bool)joiner && (num2 < 0.2f || timeMove == 0f))
|
|
{
|
|
forceToLastValidPosition = false;
|
|
}
|
|
if (fishingReel)
|
|
{
|
|
Vector3 position = _PlayerTransform.position;
|
|
Quaternion b2 = Quaternion.LookRotation(position - base.transform.position);
|
|
float value = Vector3.Distance(base.transform.position, position);
|
|
rigidbody.rotation = Quaternion.Slerp(rigidbody.rotation, b2, Time.deltaTime * (5f + speed));
|
|
rigidbody.transform.Translate(Vector3.forward * Time.deltaTime * speed);
|
|
speed = Mathf.MoveTowards(speed, Mathf.Clamp01(value) * 0.25f + 0.1f, Time.deltaTime);
|
|
SetAngularAnim(position);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
if (Vector3.Distance(base.transform.position, nextTargetPosition) < 0.25f || timeMove == 0f || nextTargetPosition == Vector3.zero)
|
|
{
|
|
Vector3 zero = Vector3.zero;
|
|
if ((bool)currentSearchBaitLure)
|
|
{
|
|
if (currentSearchBaitLure.transform.position.y > 0.15f)
|
|
{
|
|
currentSearchBaitLure = null;
|
|
return;
|
|
}
|
|
zero = currentSearchBaitLure.position;
|
|
if (Vector3.Distance(base.transform.position, currentSearchBaitLure.transform.position) < 1.5f)
|
|
{
|
|
colider.enabled = false;
|
|
if (Vector3.Distance(base.transform.position, currentSearchBaitLure.transform.position) < 0.3f)
|
|
{
|
|
Take(currentSearchBaitLure);
|
|
colider.enabled = true;
|
|
Debug.Log("Take");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
colider.enabled = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
zero = RandomSphereMovePoint();
|
|
SearchingBait();
|
|
}
|
|
Quaternion b3 = Quaternion.Euler(0f, rigidbody.transform.localEulerAngles.y, 0f);
|
|
rigidbody.rotation = Quaternion.Slerp(rigidbody.rotation, b3, Time.deltaTime * speed);
|
|
speed = Mathf.MoveTowards(speed, 0.05f, Time.deltaTime * 0.5f);
|
|
rigidbody.transform.Translate(Vector3.forward * Time.deltaTime * speed);
|
|
if ((zero.y >= num || !ProbeDeepToTerenBottom(zero)) && !currentSearchBaitLure)
|
|
{
|
|
zero = lastValidPosition;
|
|
return;
|
|
}
|
|
if (ProbeDeepWaterToTerrain(base.transform.position) > 0.3f && base.transform.position.y < 0f)
|
|
{
|
|
lastValidPosition = base.transform.position;
|
|
}
|
|
if ((bool)firstPoint)
|
|
{
|
|
firstPoint.transform.position = lastValidPosition;
|
|
}
|
|
nextTargetPosition = zero;
|
|
if (!joiner)
|
|
{
|
|
timeMove = UnityEngine.Random.Range(8f, 15f);
|
|
}
|
|
else
|
|
{
|
|
timeMove = UnityEngine.Random.Range(5f, 15f);
|
|
}
|
|
return;
|
|
}
|
|
Quaternion b4 = Quaternion.LookRotation(nextTargetPosition - base.transform.position);
|
|
rigidbody.rotation = Quaternion.Slerp(rigidbody.rotation, b4, Time.deltaTime * (5f * speed));
|
|
Quaternion b5 = Quaternion.Euler(0f, rigidbody.transform.localEulerAngles.y, 0f);
|
|
rigidbody.rotation = Quaternion.Slerp(rigidbody.rotation, b5, Time.deltaTime * (1f + speed * 0.5f));
|
|
if ((bool)currentSearchBaitLure)
|
|
{
|
|
if ((bool)currentSearchLure)
|
|
{
|
|
speed = Mathf.MoveTowards(speed, attackAgresive, Time.deltaTime);
|
|
}
|
|
speed = Mathf.Clamp(speed, 3f, 6f);
|
|
}
|
|
else if ((bool)joiner)
|
|
{
|
|
float num3 = Mathf.Clamp01(1f - Mathf.Clamp01(Mathf.Abs(base.transform.position.y))) * Mathf.Clamp(fishStrenght, 0.3f, 1f);
|
|
float num4 = Mathf.Clamp(fishWeight * 0.2f * fishStrenght, 0.3f, 1.5f);
|
|
speed = Mathf.MoveTowards(speed, (num4 + num3 + timeMove * 8f) * Mathf.Clamp(fishStamina, 0.5f, 1f), Time.deltaTime);
|
|
speed = Mathf.Clamp(speed, 0.1f, 2f);
|
|
}
|
|
else
|
|
{
|
|
speed = Mathf.MoveTowards(speed, 1.5f / timeMove, Time.deltaTime);
|
|
speed = Mathf.Clamp(speed, 0.1f, 2f);
|
|
}
|
|
SetAngularAnim(nextTargetPosition);
|
|
if (!animator.GetBool("jump"))
|
|
{
|
|
rigidbody.transform.Translate(Vector3.forward * Time.deltaTime * speed);
|
|
}
|
|
if ((bool)joiner)
|
|
{
|
|
float num5 = Vector3.SignedAngle(base.transform.forward, Vector3.up, Vector3.forward);
|
|
float y = base.transform.position.y;
|
|
if (num5 > -60f && num5 < 60f && y > 0f - colider.bounds.size.y)
|
|
{
|
|
AddJump();
|
|
}
|
|
else if (animator.runtimeAnimatorController != null)
|
|
{
|
|
animator.SetBool("jump", value: false);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void FightingRealistic()
|
|
{
|
|
if (joiner == null || isGetFish || !isTake)
|
|
{
|
|
return;
|
|
}
|
|
if ((bool)currentBaitLure)
|
|
{
|
|
currentBaitLure.transform.localPosition = Vector3.zero;
|
|
}
|
|
if ((bool)colider)
|
|
{
|
|
float num = colider.bounds.size.magnitude * 0.5f + 3f;
|
|
if (Vector3.Distance(base.transform.position, currentRod.transform.position) < num && InputManager.isPullUpRod)
|
|
{
|
|
rigidbody.mass = Mathf.Clamp(fishWeight, 1f, 15f);
|
|
getFishCounter = Mathf.MoveTowards(getFishCounter, 1f, Time.deltaTime * 0.75f);
|
|
}
|
|
else if (currentRod.fishingLine.linelenghtDiferent > 0f && Vector3.Distance(base.transform.position, currentRod.transform.position) < 5f)
|
|
{
|
|
getFishCounter = 0f;
|
|
}
|
|
else
|
|
{
|
|
getFishCounter = 0f;
|
|
}
|
|
}
|
|
if (CheckUnnhookFish() && getFishCounter == 0f)
|
|
{
|
|
return;
|
|
}
|
|
TryAddBoostStamina();
|
|
float num2 = Mathf.Clamp(fishStamina, 0.1f, 1f);
|
|
fightingTime += Time.deltaTime;
|
|
fishStrenght = fishWeight * 0.5f * num2 - currentRod.currentReel.maxReelStrength;
|
|
fishStrenght = Mathf.Clamp01(fishStrenght);
|
|
float num3 = fishWeight * num2 - currentRod.currentReel.maxReelStrength;
|
|
float num4 = 0f;
|
|
if ((bool)currentRod.currentPlayer)
|
|
{
|
|
if (InputManager.isPullUpRod)
|
|
{
|
|
pullingTime += Time.deltaTime;
|
|
if (currentRod.currentPlayer.handPullUp < 1f)
|
|
{
|
|
if (currentRod.currentReel.reelingDrag > 0f)
|
|
{
|
|
if (currentRod.currentReel.reelingDrag < 1f)
|
|
{
|
|
fishingReel = true;
|
|
}
|
|
int num5 = 2;
|
|
if (pullingTime < (float)num5)
|
|
{
|
|
float num6 = currentRod.currentPlayer.handPullUp * currentRod.fishingLine.currentLineStrenght * 0.25f / fishWeight;
|
|
num3 -= num6;
|
|
fishStrenght -= num6;
|
|
num4 = 0.5f;
|
|
}
|
|
}
|
|
}
|
|
else if (currentRod.currentReel.reelingDrag > 0f)
|
|
{
|
|
fishingReel = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (pullingTime != 0f)
|
|
{
|
|
pullingTime = 0f;
|
|
}
|
|
fishingReel = false;
|
|
}
|
|
float reelingSpeed = currentRod.currentReel.reelingSpeed;
|
|
StaminaMoveTowards(reelingSpeed + num4);
|
|
}
|
|
if ((bool)currentRod.currentPlayer && currentRod.currentPlayer.firstPersonController.m_CharacterController.velocity != Vector3.zero && currentRod.currentPlayer.transform.parent.name == "_GAMEPLAY_V2")
|
|
{
|
|
joiner.maxDistance = Vector3.Distance(jointAnchor.transform.position, currentJoinObject.transform.position);
|
|
}
|
|
num3 = Mathf.Clamp(num3, -1f, 1f);
|
|
Debug.Log($">>> Drag FISH debug: {num3}");
|
|
if (num3 > 0f)
|
|
{
|
|
joiner.maxDistance = Mathf.MoveTowards(joiner.maxDistance, Vector3.Distance(jointAnchor.transform.position, currentJoinObject.transform.position), Time.deltaTime * num3);
|
|
}
|
|
else if (currentRod.fishingLine.currentLineHandler.lineType == FLineHandler.LineType.OneSegment)
|
|
{
|
|
joiner.maxDistance = Mathf.MoveTowards(joiner.maxDistance, currentRod.fishingLine.currentLineHandler.PhisicsLineOut, Time.deltaTime * Mathf.Abs(num3) * 10f);
|
|
}
|
|
else
|
|
{
|
|
joiner.maxDistance = Mathf.MoveTowards(joiner.maxDistance, currentRod.fishingLine.currentLineHandler.PhisicsLineOut + currentRod.fishingLine.currentLineHandler.LineConnector_2.maxDistance + 0.5f, Time.deltaTime * Mathf.Abs(num3) * 10f);
|
|
}
|
|
joiner.maxDistance = Mathf.Clamp(joiner.maxDistance, 0.6f, float.PositiveInfinity);
|
|
}
|
|
|
|
private void AddJump()
|
|
{
|
|
if (!(jumpDelay > 0f))
|
|
{
|
|
Debug.Log("Jump start");
|
|
rigidbody.AddForce((Vector3.up + base.transform.forward) * UnityEngine.Random.Range(0.05f, 0.1f) * rigidbody.mass, ForceMode.Acceleration);
|
|
rigidbody.AddTorque(Vector3.up * UnityEngine.Random.Range(0.5f, 1f) * rigidbody.mass, ForceMode.Acceleration);
|
|
BuildSplashJump(new Vector3(base.transform.position.x, waterHeightPosition, base.transform.position.z));
|
|
if (animator.runtimeAnimatorController != null)
|
|
{
|
|
animator.SetBool("jump", value: true);
|
|
}
|
|
jumpDelay = UnityEngine.Random.Range(5, 15);
|
|
}
|
|
}
|
|
|
|
public void OnEnableFormFishSystem()
|
|
{
|
|
_ = (bool)currentFeedingZone;
|
|
}
|
|
|
|
public void RandomNewDstPointFreeMove()
|
|
{
|
|
if (joiner != null)
|
|
{
|
|
return;
|
|
}
|
|
if (!currentFeedingZone)
|
|
{
|
|
SetNewFeedingZoneDst();
|
|
return;
|
|
}
|
|
if (Vector3.Distance(base.transform.position, currentFeedingZone.transform.position) < currentFeedingZone.rangeZone)
|
|
{
|
|
SetNewFeedingZoneDst();
|
|
}
|
|
float num = ProbeDeepWaterToTerrain(currentFeedingZone.transform.position);
|
|
if ((bool)currentFeedingZone)
|
|
{
|
|
TargetPoint = new Vector3(currentFeedingZone.transform.position.x + UnityEngine.Random.Range(0f - currentFeedingZone.rangeZone, currentFeedingZone.rangeZone), UnityEngine.Random.Range(0f - num, 0f), currentFeedingZone.transform.position.z + UnityEngine.Random.Range(0f - currentFeedingZone.rangeZone, currentFeedingZone.rangeZone));
|
|
return;
|
|
}
|
|
TargetPoint = base.transform.position + UnityEngine.Random.onUnitSphere * 5f;
|
|
TargetPoint = new Vector3(TargetPoint.x, UnityEngine.Random.Range(0f - num, 0f), TargetPoint.z);
|
|
}
|
|
|
|
public void JoinFish(Rigidbody joinObject)
|
|
{
|
|
currentJoinObject = joinObject;
|
|
TargetPoint = base.transform.position;
|
|
Debug.Log("ON FISH HOOK!!!!!!!!!!!!");
|
|
if (GetComponent<SpringJoint>() == null)
|
|
{
|
|
joiner = base.transform.gameObject.AddComponent<SpringJoint>();
|
|
}
|
|
joiner.anchor = jointAnchor.localPosition;
|
|
joiner.autoConfigureConnectedAnchor = false;
|
|
joiner.connectedAnchor = Vector3.zero;
|
|
joiner.spring = 1500f;
|
|
joiner.maxDistance = Vector3.Distance(jointAnchor.transform.position, currentJoinObject.transform.position);
|
|
joiner.connectedBody = currentJoinObject;
|
|
timeCatch = 0f;
|
|
ShowWaterBubbleFX();
|
|
if ((bool)FScriptsHandler.Instance.m_PlayerMain.underWaterCamera)
|
|
{
|
|
FFish.OnFishHookUnityEventGlobal?.Invoke(base.transform);
|
|
FFish.OnFishHook?.Invoke(this);
|
|
OnFishHookUnityEvent?.Invoke(base.transform);
|
|
}
|
|
}
|
|
|
|
public void UnJoinFish(bool resetPosition = false)
|
|
{
|
|
if (TryGetComponent<SpringJoint>(out var component))
|
|
{
|
|
UnityEngine.Object.Destroy(component);
|
|
}
|
|
if (TryGetComponent<ConfigurableJoint>(out var component2))
|
|
{
|
|
UnityEngine.Object.Destroy(component2);
|
|
}
|
|
joiner = null;
|
|
isTake = false;
|
|
if ((bool)currentRod)
|
|
{
|
|
currentRod.takeFish = null;
|
|
}
|
|
if ((bool)currentRod)
|
|
{
|
|
currentRod.currentFish = null;
|
|
}
|
|
currentRod = null;
|
|
isGetFish = false;
|
|
currentSearchBaitLure = null;
|
|
currentSearchLure = null;
|
|
currentSearchHook = null;
|
|
fishStamina = fishWeight;
|
|
if ((bool)currentBaitLure)
|
|
{
|
|
currentBaitLure.transform.SetParent(base.transform.parent);
|
|
if (currentBaitLure.TryGetComponent<FHook>(out var component3))
|
|
{
|
|
component3.isLookingDisable = false;
|
|
component3.rigidbody.isKinematic = false;
|
|
}
|
|
if (currentBaitLure.TryGetComponent<FLure>(out var component4))
|
|
{
|
|
component4.isLookingDisable = false;
|
|
component4.rigidbody.isKinematic = false;
|
|
}
|
|
currentBaitLure = null;
|
|
}
|
|
if (resetPosition)
|
|
{
|
|
base.transform.position = startPosition;
|
|
}
|
|
}
|
|
|
|
public void ReJoin(Rigidbody newJoin)
|
|
{
|
|
if (joiner != null)
|
|
{
|
|
UnityEngine.Object.Destroy(joiner);
|
|
}
|
|
joiner = null;
|
|
ConfigurableJoint configurableJoint = base.gameObject.AddComponent<ConfigurableJoint>();
|
|
configurableJoint.anchor = jointAnchor.localPosition;
|
|
configurableJoint.autoConfigureConnectedAnchor = false;
|
|
configurableJoint.connectedAnchor = Vector3.zero;
|
|
configurableJoint.xMotion = ConfigurableJointMotion.Locked;
|
|
configurableJoint.yMotion = ConfigurableJointMotion.Locked;
|
|
configurableJoint.zMotion = ConfigurableJointMotion.Locked;
|
|
configurableJoint.angularXMotion = ConfigurableJointMotion.Free;
|
|
configurableJoint.angularYMotion = ConfigurableJointMotion.Free;
|
|
configurableJoint.angularZMotion = ConfigurableJointMotion.Free;
|
|
newJoin.transform.position = jointAnchor.position;
|
|
configurableJoint.connectedBody = newJoin;
|
|
currentBaitLure.transform.SetParent(base.transform.parent);
|
|
}
|
|
|
|
public void ReJoinChwytak(Rigidbody newJoin)
|
|
{
|
|
if (joiner != null)
|
|
{
|
|
UnityEngine.Object.Destroy(joiner);
|
|
}
|
|
joiner = null;
|
|
ConfigurableJoint configurableJoint = ((!TryGetComponent<ConfigurableJoint>(out configurableJoint)) ? base.gameObject.AddComponent<ConfigurableJoint>() : base.gameObject.GetComponent<ConfigurableJoint>());
|
|
configurableJoint.anchor = jointAnchor.localPosition;
|
|
configurableJoint.autoConfigureConnectedAnchor = false;
|
|
configurableJoint.connectedAnchor = Vector3.zero;
|
|
configurableJoint.xMotion = ConfigurableJointMotion.Locked;
|
|
configurableJoint.yMotion = ConfigurableJointMotion.Locked;
|
|
configurableJoint.zMotion = ConfigurableJointMotion.Locked;
|
|
configurableJoint.angularXMotion = ConfigurableJointMotion.Free;
|
|
configurableJoint.angularYMotion = ConfigurableJointMotion.Free;
|
|
configurableJoint.angularZMotion = ConfigurableJointMotion.Free;
|
|
configurableJoint.connectedBody = newJoin;
|
|
currentBaitLure.transform.SetParent(base.transform.parent);
|
|
}
|
|
|
|
public void Take(Transform takeObject)
|
|
{
|
|
if (isTake)
|
|
{
|
|
return;
|
|
}
|
|
if (takeObject.TryGetComponent<FHook>(out var component))
|
|
{
|
|
if ((bool)component.currentRod && !component.currentRod.currentFish && !component.currentRod.takeFish)
|
|
{
|
|
if (Singleton<SaveDataManager>.Instance.SettingsData.IsControllerVibrationEnabled)
|
|
{
|
|
GameManager.Instance.ControllerVibrate(0.5f, 1);
|
|
}
|
|
Debug.Log("Branie Haczyk!!");
|
|
currentRod = component.currentRod;
|
|
currentRod.takeFish = this;
|
|
currentBaitLure = component.rigidbody;
|
|
JoinFish(currentRod.fishingLine.currentLineHandler.EndLineRigidbody_0);
|
|
currentBaitLure.transform.SetParent(baitContainer);
|
|
currentBaitLure.detectCollisions = false;
|
|
currentBaitLure.isKinematic = true;
|
|
currentBaitLure.transform.position = jointAnchor.position;
|
|
currentBaitLure.transform.localEulerAngles = component.rotationInFishJaw;
|
|
isTake = true;
|
|
isGetFish = false;
|
|
component.isLookingDisable = true;
|
|
currentSearchBaitLure = null;
|
|
currentSearchLure = null;
|
|
currentSearchHook = null;
|
|
component.transform.localPosition = Vector3.zero;
|
|
if ((bool)component.currentRod.currentFeeder)
|
|
{
|
|
dropTimer = UnityEngine.Random.Range(10f, 20f);
|
|
}
|
|
else
|
|
{
|
|
dropTimer = UnityEngine.Random.Range(1f, 10f);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!takeObject.TryGetComponent<FLure>(out var component2))
|
|
{
|
|
return;
|
|
}
|
|
Debug.Log("Branie Lure!!");
|
|
if ((bool)component2.currentRod && !component2.currentRod.currentFish && !component2.currentRod.takeFish)
|
|
{
|
|
if (Singleton<SaveDataManager>.Instance.SettingsData.IsControllerVibrationEnabled)
|
|
{
|
|
GameManager.Instance.ControllerVibrate(0.5f, 1);
|
|
}
|
|
currentRod = component2.currentRod;
|
|
currentRod.takeFish = this;
|
|
currentBaitLure = component2.rigidbody;
|
|
JoinFish(currentRod.fishingLine.currentLineHandler.EndLineRigidbody_0);
|
|
currentBaitLure.isKinematic = true;
|
|
currentBaitLure.detectCollisions = false;
|
|
currentBaitLure.transform.position = jointAnchor.position;
|
|
currentBaitLure.transform.localEulerAngles = component2.rotationInFishJaw;
|
|
currentBaitLure.transform.SetParent(baitContainer);
|
|
isTake = true;
|
|
isGetFish = false;
|
|
component2.isLookingDisable = true;
|
|
currentSearchBaitLure = null;
|
|
currentSearchLure = null;
|
|
currentSearchHook = null;
|
|
dropTimer = UnityEngine.Random.Range(2f, 10f);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ReJoinInOutWater()
|
|
{
|
|
if (currentRod.fishingLine.currentLineHandler.lineType == FLineHandler.LineType.OneSegment)
|
|
{
|
|
ReJoin(currentBaitLure.GetComponent<FLure>().fishJoiner);
|
|
}
|
|
if (currentRod.fishingLine.currentLineHandler.lineType == FLineHandler.LineType.TwoSegment)
|
|
{
|
|
ReJoin(currentBaitLure.GetComponent<FHook>().fishJoiner);
|
|
}
|
|
if (currentRod.fishingLine.currentLineHandler.lineType == FLineHandler.LineType.ThereSegment)
|
|
{
|
|
ReJoin(currentBaitLure.GetComponent<FHook>().fishJoiner);
|
|
}
|
|
currentBaitLure.detectCollisions = true;
|
|
currentBaitLure.isKinematic = false;
|
|
Debug.Log("Out Water rejoin");
|
|
}
|
|
|
|
private float ProbeDeepWaterToTerrain(Vector3 probeObject)
|
|
{
|
|
int mask = LayerMask.GetMask("Terrain");
|
|
float result = 0f;
|
|
if (Physics.Raycast(new Vector3(probeObject.x, 0f, probeObject.z), -Vector3.up, out var hitInfo, float.PositiveInfinity, mask))
|
|
{
|
|
result = hitInfo.distance;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
private bool ProbeDeepToTerenBottom(Vector3 probeObject)
|
|
{
|
|
int mask = LayerMask.GetMask("Terrain");
|
|
if (Physics.Raycast(probeObject, -Vector3.up, out var _, float.PositiveInfinity, mask))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private void ShowWaterFX()
|
|
{
|
|
if (!m_Renderer.isVisible || !isShowWaterFX)
|
|
{
|
|
return;
|
|
}
|
|
if (FScriptsHandler.Instance == null)
|
|
{
|
|
Debug.LogWarning("Warning! Show Water FX can be used beacuse no FScriptHandler on Scene");
|
|
isShowWaterFX = false;
|
|
}
|
|
else if (!(Vector3.Distance(FScriptsHandler.Instance.m_PlayerMain.transform.position, base.transform.position) < 3f))
|
|
{
|
|
float num = waterHeightPosition - base.transform.position.y;
|
|
if (num < 0.1f && num > -1f)
|
|
{
|
|
Mathf.Abs(num);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ShowWaterBubbleFX()
|
|
{
|
|
if (!(bubbleParticle == null))
|
|
{
|
|
if (!bubbleParticle.isEmitting)
|
|
{
|
|
bubbleParticle.Play();
|
|
}
|
|
if (waterHeightPosition - colider.bounds.size.y <= base.transform.position.y && waterHeightPosition + colider.bounds.size.y > base.transform.position.y && !bubbleParticle.isEmitting)
|
|
{
|
|
bubbleParticle.Play();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void BuildSplash(Vector3 contactPosition, float minVelocityMag = 0.5f)
|
|
{
|
|
if ((bool)rigidbody && !(rigidbody.velocity.magnitude < minVelocityMag))
|
|
{
|
|
Vector3 vector = Vector3.one * (0.1f * rigidbody.velocity.magnitude) * base.transform.localScale.x;
|
|
int num = 1;
|
|
if (fishWeight < 0.4f)
|
|
{
|
|
num = 0;
|
|
}
|
|
GameObject obj = LeanPool.Spawn(FScriptsHandler.Instance.waterFishSplash[num]);
|
|
obj.transform.position = new Vector3(contactPosition.x, 0.05f, contactPosition.z);
|
|
vector = Vector3.ClampMagnitude(vector, 1f);
|
|
obj.transform.localScale = vector;
|
|
}
|
|
}
|
|
|
|
private void BuildSplashJump(Vector3 contactPosition)
|
|
{
|
|
Vector3 vector = Vector3.one * (0.1f * Mathf.Abs(rigidbody.velocity.y)) * base.transform.localScale.x;
|
|
int num = 1;
|
|
if (fishWeight < 0.4f)
|
|
{
|
|
num = 0;
|
|
}
|
|
GameObject obj = UnityEngine.Object.Instantiate(FScriptsHandler.Instance.waterFishSplash[num]);
|
|
obj.transform.position = new Vector3(contactPosition.x, 0.2f, contactPosition.z);
|
|
vector = Vector3.ClampMagnitude(vector, 1f);
|
|
obj.transform.localScale = vector;
|
|
}
|
|
|
|
private void SplashUpdate()
|
|
{
|
|
if (!(colider == null) && !isGetFish)
|
|
{
|
|
Vector3 position = base.transform.position;
|
|
position.y = 0.05f;
|
|
float num = colider.bounds.size.magnitude * 0.25f;
|
|
if (base.transform.position.y > 0f - num && lastTimeCreateSplash < Time.time)
|
|
{
|
|
BuildSplash(position, 0.75f);
|
|
lastTimeCreateSplash = Time.time + 1f;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void CheckIsWater()
|
|
{
|
|
if (!colider || !rigidbody)
|
|
{
|
|
return;
|
|
}
|
|
if (base.transform.position.y < 0f)
|
|
{
|
|
if (!isInWater)
|
|
{
|
|
isInWater = true;
|
|
rigidbody.drag = waterDrag;
|
|
rigidbody.useGravity = false;
|
|
FFish.OnInwaterEnter?.Invoke(this);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!isInWater)
|
|
{
|
|
return;
|
|
}
|
|
isInWater = false;
|
|
rigidbody.drag = normalDrag;
|
|
rigidbody.useGravity = true;
|
|
FFish.OnInwaterExit?.Invoke(this);
|
|
if (!joiner)
|
|
{
|
|
timeMove = 0f;
|
|
if ((bool)currentSearchBaitLure)
|
|
{
|
|
currentSearchBaitLure = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider col)
|
|
{
|
|
if (col.transform.tag == "Water")
|
|
{
|
|
BuildSplash(base.transform.position, 0f);
|
|
}
|
|
}
|
|
|
|
private void OnTriggerExit(Collider other)
|
|
{
|
|
if (other.tag == "Water")
|
|
{
|
|
BuildSplash(base.transform.position, 0.1f);
|
|
}
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
if ((bool)fFishSystem && (base.enabled || fFishSystem.isNewSpawnerSystem))
|
|
{
|
|
FFish.OnDestroyed?.Invoke(this);
|
|
}
|
|
}
|
|
|
|
private void OnCollisionEnter(Collision collision)
|
|
{
|
|
forceToLastValidPosition = true;
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
if ((bool)fFishSystem)
|
|
{
|
|
RandomNewDstPointFreeMove();
|
|
}
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
if ((bool)fFishSystem)
|
|
{
|
|
if (base.transform.position.y <= 0f)
|
|
{
|
|
FFish.OnDisabled?.Invoke(this);
|
|
}
|
|
if ((bool)firstPoint)
|
|
{
|
|
UnityEngine.Object.Destroy(firstPoint.gameObject);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void EnableFish()
|
|
{
|
|
base.gameObject.SetActive(value: true);
|
|
lastValidPosition = base.transform.position;
|
|
firstPoint = GameObject.CreatePrimitive(PrimitiveType.Sphere);
|
|
firstPoint.GetComponent<MeshRenderer>().enabled = false;
|
|
UnityEngine.Object.Destroy(firstPoint.GetComponent<Collider>());
|
|
firstPoint.transform.localScale = Vector3.one * 0.17f;
|
|
firstPoint.transform.position = lastValidPosition;
|
|
}
|
|
}
|