Files
UltimateFishing2020/Assets/Scripts/Assembly-CSharp/PlayerMain.cs
2026-03-04 10:03:45 +08:00

1109 lines
35 KiB
C#

using System.Collections;
using RootMotion.FinalIK;
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;
using UnityStandardAssets.CrossPlatformInput;
using UnityStandardAssets.Utility;
[RequireComponent(typeof(CharacterController))]
[RequireComponent(typeof(AudioSource))]
public class PlayerMain : MonoBehaviour
{
public enum Sex
{
Male = 0,
Female = 1
}
public enum CameraTypeView
{
FirstPerson = 0,
ThirdPerson = 1,
FishView = 2
}
[SerializeField]
private MouseLook m_MouseLook;
[SerializeField]
private float m_JumpSpeed;
[SerializeField]
private float m_StickToGroundForce;
[SerializeField]
private float m_GravityMultiplier;
[SerializeField]
private AudioClip[] m_FootstepSounds;
[SerializeField]
private AudioClip[] m_FootstepSoundsWater;
[SerializeField]
private AudioClip[] m_FootstepSoundsBridge;
[SerializeField]
private AudioClip[] m_FootstepSoundsStone;
[SerializeField]
private AudioClip m_JumpSound;
[SerializeField]
private AudioClip m_LandSound;
private CharacterController characterController;
[HideInInspector]
public Animator animator;
private AudioSource m_AudioSource;
private Vector3 verticalVelocity;
private bool m_Jump;
[HideInInspector]
public bool m_Jumping;
private Vector3 mainCameraStartPosition;
private float cameraFollowDistance = 2f;
private string groundTypeTag = "";
[HideInInspector]
public Camera currentCameraView;
[HideInInspector]
public GameObject underWaterCamera;
[HideInInspector]
public float m_underWaterlevel;
public GameObject waterFXStepfootPrefab;
public Camera m_Camera;
public Sex sex;
public CameraTypeView m_CameraTypeView;
public Transform ThirdPersonCameraPoint;
public Transform ThirdPersonCameraFishPoint;
private float startCameraFieldOfView = 60f;
private float zoomTargetCameraFieldOfView = 40f;
private bool isZoomCamera;
public GameObject currentRightHandObject;
public Rod currentRod;
public Podbierak podbierak;
public Chwytak chwytak;
public Transform interactiveObjects;
private InteractionControl interactionControl;
[HideInInspector]
public Animator interactiveObjectsAnimator;
public Transform leftHand;
public Transform leftHandFishLinePoint;
public Vector3 leftHandPodbierakDefinePosition;
public Transform rightHandJointPoint;
public HeadFlashlight headFlashlight;
[HideInInspector]
public float RodPullUp;
private bool throwLocked;
[HideInInspector]
public bool isThrowStarted;
[HideInInspector]
public bool preCastNearFlag;
[HideInInspector]
public bool preCastFarFlag;
private float upDownCameraPos = 0.5f;
private float rotRodLeftRight = 0.5f;
private bool throwTargeting;
[HideInInspector]
public bool isThrowStartTargeting;
[HideInInspector]
public bool isThrowStartFar;
private float zoomTime;
private Vector3 lastPositionOnTerrainTemp;
private Vector3 lastPositionTemp;
private void Start()
{
animator = GetComponent<Animator>();
interactiveObjectsAnimator = interactiveObjects.GetComponent<Animator>();
m_AudioSource = GetComponent<AudioSource>();
characterController = GetComponent<CharacterController>();
m_Camera = Camera.main;
currentCameraView = m_Camera;
startCameraFieldOfView = m_Camera.fieldOfView;
mainCameraStartPosition = m_Camera.transform.localPosition;
m_MouseLook.Init(base.transform, m_Camera.transform);
m_Jumping = false;
GameManager.Instance.SetMouseCurrsor(val: false);
InputManager.isHeadFlashLight = false;
SetCameraViewType(CameraTypeView.FirstPerson);
}
private void Update()
{
if (InputManager.isCastReset)
{
ResetCast();
}
AutomaticCharacterController();
UnderWaterCameraControler();
CheckGround();
LeftRightRod();
PlayerFishAndPullUpRod();
ConnectingLineToHand();
CheckAndCatchFish();
CheckGetFishFromWater();
zoomInOutTargetCamera(isZoomCamera);
PlayerThrowRodControl();
if ((bool)headFlashlight)
{
if (!headFlashlight.gameObject.activeSelf && InputManager.isHeadFlashLight)
{
headFlashlight.gameObject.SetActive(value: true);
}
else if (!InputManager.isHeadFlashLight)
{
headFlashlight.gameObject.SetActive(value: false);
}
}
}
private void FixedUpdate()
{
RotateView();
AutoJointRod();
if (!(currentRod != null))
{
return;
}
if (interactiveObjectsAnimator.GetInteger("ThrowRod") == -1 && currentRod.fishingLine.ropeOut == 0f)
{
if (ScriptsHandler.Instance.m_InteractionControl.LeftHandInteractionWithReel)
{
ScriptsHandler.Instance.m_InteractionControl.StopReelInteractionWithLeftHand();
}
}
else if (interactiveObjectsAnimator.GetInteger("ThrowRod") == -1 && currentRod.fishingLine.ropeOut > 0f && !ScriptsHandler.Instance.m_InteractionControl.LeftHandInteractionWithReel)
{
ScriptsHandler.Instance.m_InteractionControl.StartReelInteractionWithLeftHand();
}
if (!(currentRod != null))
{
return;
}
if (currentRod.fishingLine.ropeOut == 0f)
{
if (isThrowStarted || throwTargeting)
{
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerRods[currentRod.rodIndex].status = GameManager.PlayerData.CRods.Status.InUse;
}
else
{
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerRods[currentRod.rodIndex].status = GameManager.PlayerData.CRods.Status.InHand;
}
}
else
{
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerRods[currentRod.rodIndex].status = GameManager.PlayerData.CRods.Status.InUse;
}
}
private void LeftRightRod()
{
if (!(currentRod == null))
{
Vector3 vector = currentRod.fishingLine.currentLineHandler.EndLineRigidbody_1.position - base.transform.position;
float num = Vector3.Distance(currentRod.fishingLine.currentLineHandler.EndLineRigidbody_1.position, base.transform.position);
float num2 = Mathf.Clamp(Vector3.SignedAngle(vector, base.transform.forward, Vector3.up) / 70f, -1f, 1f);
if (num < 5f)
{
num2 = 0f;
}
rotRodLeftRight = Mathf.MoveTowards(rotRodLeftRight, num2, Time.deltaTime);
if (num2 < 0f)
{
interactiveObjectsAnimator.Play("RodLeft", 5, Mathf.Abs(rotRodLeftRight));
}
if (num2 > 0f)
{
interactiveObjectsAnimator.Play("RodRight", 5, Mathf.Abs(rotRodLeftRight));
}
else
{
interactiveObjectsAnimator.Play("RodLeft", 5, Mathf.Abs(rotRodLeftRight));
}
}
}
private void ResetRodPulls()
{
RodPullUp = 0f;
rotRodLeftRight = 0f;
}
private void PlayerFishAndPullUpRod()
{
if (preCastNearFlag || preCastFarFlag || !(currentRod != null))
{
return;
}
if (currentRod.isTrowing)
{
interactiveObjectsAnimator.Play("RodLeft", 5, 0f);
interactiveObjectsAnimator.Play("RodRight", 5, 0f);
interactiveObjectsAnimator.Play("PullUpRod", 3, 0f);
return;
}
float num = 0f;
if (currentRod.fishingLine.ropeOut > 2f)
{
if (InputManager.isPullUpRod)
{
num = currentRod.currentRodStrength;
RodPullUp = Mathf.MoveTowards(RodPullUp, 0.95f, Time.deltaTime * (1.3f - currentRod.currentRodStrength));
throwLocked = true;
}
else
{
upDownCameraPos = 0f - (m_Camera.transform.localRotation.x - 0.3f);
upDownCameraPos = Mathf.Clamp01(upDownCameraPos * 1.3f);
upDownCameraPos = Mathf.Clamp(upDownCameraPos, 0f, 0.95f);
RodPullUp = Mathf.MoveTowards(RodPullUp, upDownCameraPos, Time.deltaTime * 1.3f);
}
LeftRightRod();
}
else
{
RodPullUp = Mathf.MoveTowards(RodPullUp, 0f, Time.deltaTime * 2f);
if (RodPullUp == 0f)
{
throwLocked = false;
}
}
if (RodPullUp != 0f)
{
interactiveObjectsAnimator.SetFloat("ShakeRod", num * 2f * RodPullUp);
}
else
{
interactiveObjectsAnimator.SetFloat("ShakeRod", 0f);
}
interactiveObjectsAnimator.Play("PullUpRod", 3, RodPullUp);
}
private void PlayerThrowRodControl()
{
if (!(currentRod != null) || currentRod.isDamage || throwLocked || currentRod.isTrowing || currentRod.fishingLine.ropeOut > 0f || (bool)currentRod.fishingLine.fishObject || (bool)ScriptsHandler.Instance.m_HudManager.fishCatchPanel || GameManager.Instance.addectiveSceneLoaded != "none" || Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerSlotsEquip[currentRod.indexOfslot].status != GameManager.PlayerData.CSlots.Status.Completed)
{
return;
}
float num = 0f;
if (!isThrowStartTargeting && !isThrowStartFar && !isThrowStarted)
{
if (InputManager.isCastTargeting && !throwTargeting)
{
throwTargeting = true;
interactiveObjectsAnimator.SetInteger("ThrowRod", 0);
return;
}
if (InputManager.isCastTargeting && throwTargeting)
{
isThrowStarted = false;
throwTargeting = false;
preCastNearFlag = false;
ScriptsHandler.Instance.m_CanvasManager.StopThrowingBar();
interactiveObjectsAnimator.SetInteger("ThrowRod", -1);
isZoomCamera = false;
currentRod.DestroyThrowtarget();
currentRod.fishingLine.reel.UnlockKablag(val: false);
return;
}
if (throwTargeting)
{
num = 1f - m_Camera.transform.localRotation.x * 2f;
num = Mathf.Clamp(num, 0.2f, 1f);
if (!currentRod.SetThrowTarget(10f, num))
{
isThrowStartTargeting = false;
isZoomCamera = false;
throwTargeting = false;
preCastNearFlag = false;
isThrowStarted = false;
ScriptsHandler.Instance.m_CanvasManager.StopThrowingBar();
interactiveObjectsAnimator.SetInteger("ThrowRod", -1);
currentRod.fishingLine.reel.UnlockKablag(val: false);
GameManager.Instance.ShowMessagePopup(LanguageManager.Instance.GetText("WRONG_ROD_THROW"), ScriptsHandler.Instance.m_Canvas.transform);
return;
}
interactiveObjectsAnimator.ResetTrigger("StopThrowing");
isZoomCamera = true;
preCastNearFlag = true;
if (preCastNearFlag)
{
ScriptsHandler.Instance.m_CanvasManager.ShowHideThrowingBar(visable: true, num);
if (InputManager.isCastFar && throwTargeting)
{
interactiveObjectsAnimator.SetInteger("ThrowRod", 1);
isThrowStartTargeting = true;
throwTargeting = false;
preCastNearFlag = false;
isThrowStarted = true;
currentRod.HideThrowTarget();
ScriptsHandler.Instance.m_CanvasManager.StopThrowingBar();
isZoomCamera = false;
}
}
}
}
if (isThrowStartTargeting || isThrowStartFar || throwTargeting)
{
return;
}
float num2 = 0f;
if (InputManager.isCastFar)
{
interactiveObjectsAnimator.SetInteger("ThrowRod", 2);
preCastFarFlag = true;
ScriptsHandler.Instance.m_CanvasManager.ShowHideThrowingBar(visable: true, 0f);
isThrowStarted = true;
}
else if (preCastFarFlag)
{
num2 = ScriptsHandler.Instance.m_CanvasManager.StopThrowingBar();
currentRod.targetThrowPower = num2;
Debug.Log("currentRod.targetThrowPower: " + currentRod.targetThrowPower);
num = num2;
num = Mathf.Clamp(num, 0.01f, 1f);
if (currentRod.SetThrowTarget(currentRod.throwRange, num, visable: false))
{
interactiveObjectsAnimator.ResetTrigger("StopThrowing");
isThrowStartFar = true;
preCastFarFlag = false;
interactiveObjectsAnimator.SetInteger("ThrowRod", 3);
}
else
{
isThrowStartFar = false;
preCastFarFlag = false;
isThrowStarted = false;
interactiveObjectsAnimator.SetInteger("ThrowRod", -1);
currentRod.HideThrowTarget();
ScriptsHandler.Instance.m_CanvasManager.StopThrowingBar();
GameManager.Instance.ShowMessagePopup(LanguageManager.Instance.GetText("WRONG_ROD_THROW"), ScriptsHandler.Instance.m_Canvas.transform);
}
}
}
public void ResetCast()
{
if (!(currentRod == null) && !(currentRod.fishingLine.fishObject != null) && !throwTargeting && !isThrowStarted && (!currentRod.fishingLine.lure || !currentRod.fishingLine.lure.takeFish) && (!currentRod.fishingLine.hook || !currentRod.fishingLine.hook.takeFish))
{
currentRod.fishingLine.ropeOut = 0f;
SetAnimationToIdleByLineOut(0f);
}
}
private void zoomInOutTargetCamera(bool isIn)
{
if (isIn && m_Camera.fieldOfView == zoomTargetCameraFieldOfView)
{
zoomTime = 0f;
return;
}
if (!isIn && m_Camera.fieldOfView == startCameraFieldOfView)
{
zoomTime = 0f;
return;
}
zoomTime += Time.deltaTime;
if (isIn)
{
m_Camera.fieldOfView = Mathf.Lerp(m_Camera.fieldOfView, zoomTargetCameraFieldOfView, zoomTime);
}
else
{
m_Camera.fieldOfView = Mathf.Lerp(m_Camera.fieldOfView, startCameraFieldOfView, zoomTime);
}
}
public void SetAnimationToIdleByLineOut(float lineOut)
{
if (lineOut == 0f)
{
if (interactiveObjectsAnimator.GetInteger("ThrowRod") != -1)
{
interactiveObjectsAnimator.SetInteger("ThrowRod", -1);
}
interactiveObjectsAnimator.Play("PullUpRod", 3, 0f);
interactiveObjectsAnimator.Play("RodRight", 5, 0f);
interactiveObjectsAnimator.Play("RodLeft", 5, 0f);
currentRod.fishingLine.reel.RebindAnim();
if (ScriptsHandler.Instance.m_InteractionControl.LeftHandInteractionWithReel)
{
ScriptsHandler.Instance.m_InteractionControl.StopReelInteractionWithLeftHand();
}
}
}
public void ReelindAddactiveAnim(float speed)
{
interactiveObjectsAnimator.SetFloat("Reeling", speed);
}
public void CheckGetFishFromWater()
{
if (currentRod == null || currentRod.fishingLine.fishObject == null || ScriptsHandler.Instance.m_InteractionControl.leftHandPoster == InteractionControl.LeftHandPoster.HandFish || ScriptsHandler.Instance.m_InteractionControl.leftHandPoster == InteractionControl.LeftHandPoster.HandChwytak || (podbierak != null && podbierak.isDone) || currentRod.fishingLine.fishObject.stage == FishMovement.Stage.onPodbierak)
{
return;
}
Vector3 position = currentRod.fishingLine.toRodConnector.position;
Vector3 position2 = currentRod.fishingLine.fishObject.transform.position;
if (Vector3.Distance(new Vector3(position.x, 0f, position.z), new Vector3(position2.x, 0f, position2.z)) < 3.5f && currentRod.fishingLine.ropeOut < 3f)
{
currentRod.fishingLine.ropeOut = 0f;
currentRod.fishingLine.fishObject.stage = FishMovement.Stage.getFish;
if (ScriptsHandler.Instance.m_InteractionControl.LeftHandInteractionWithReel)
{
ScriptsHandler.Instance.m_InteractionControl.StopReelInteractionWithLeftHand();
}
currentRod.fishingLine.handFishHandPoint.GetComponent<Rigidbody>().isKinematic = true;
interactiveObjectsAnimator.SetInteger("ThrowRod", -3);
if ((bool)currentRod.fishingLine.lure)
{
currentRod.fishingLine.lure.rigidbody.isKinematic = false;
}
else if ((bool)currentRod.fishingLine.hook)
{
currentRod.fishingLine.hook.rigidbody.isKinematic = false;
}
}
if (!currentRod.fishingLine.handFishHandPoint.GetComponent<Rigidbody>().isKinematic)
{
return;
}
if (currentRod.fishingLine.fishObject.fishStats.current_weight < 1.5f)
{
currentRod.fishingLine.handFishHandPoint.transform.position = Vector3.MoveTowards(currentRod.fishingLine.handFishHandPoint.transform.position, ScriptsHandler.Instance.m_InteractionControl.LeftHandFish.transform.position, Time.deltaTime * 3f);
if (currentRod.fishingLine.handFishHandPoint.transform.position == ScriptsHandler.Instance.m_InteractionControl.LeftHandFish.transform.position)
{
GetFishToHand();
}
return;
}
if (!ScriptsHandler.Instance.m_InteractionControl.LeftHandInteractionWithReel)
{
ScriptsHandler.Instance.m_InteractionControl.leftHandPoster = InteractionControl.LeftHandPoster.HandPodbierak;
}
if (ScriptsHandler.Instance.m_InteractionControl.LeftHandInteractionWithPodbierak)
{
currentRod.fishingLine.handFishHandPoint.transform.position = Vector3.MoveTowards(currentRod.fishingLine.handFishHandPoint.transform.position, podbierak.fishPoint.transform.position, Time.deltaTime * 2f);
if (currentRod.fishingLine.handFishHandPoint.transform.position == podbierak.fishPoint.transform.position && currentRod.fishingLine.fishObject.transform.parent != podbierak.fishPoint.transform)
{
currentRod.fishingLine.fishObject.transform.SetParent(podbierak.fishPoint.transform);
interactiveObjectsAnimator.SetBool("isGetPodbierak", value: true);
podbierak.animator.SetBool("GetPodbierak", value: true);
currentRod.fishingLine.fishObject.stage = FishMovement.Stage.onPodbierak;
currentRod.fishingLine.fishObject.GetComponent<Rigidbody>().isKinematic = true;
currentRod.fishingLine.handFishHandPoint.GetComponent<Rigidbody>().isKinematic = false;
podbierak.fish = currentRod.fishingLine.fishObject.transform;
Debug.Log("Fish in podbierak");
}
}
}
public void DestroyCurrentFish()
{
if (podbierak != null)
{
ScriptsHandler.Instance.m_InteractionControl.StopPodbierakInteractionWithLeftHand();
Object.Destroy(podbierak.gameObject);
}
if ((bool)chwytak)
{
CreateChwytak(destroy: true);
}
if (interactiveObjectsAnimator.GetInteger("ThrowRod") != -1)
{
currentRod.fishingLine.ropeOut = 0f;
interactiveObjectsAnimator.SetInteger("ThrowRod", -1);
}
interactiveObjectsAnimator.SetBool("isFishHand", value: false);
interactiveObjectsAnimator.SetBool("isFish", value: false);
interactiveObjectsAnimator.Play("PullUpRod", 3, 0f);
interactiveObjectsAnimator.Play("RodRight", 5, 0f);
interactiveObjectsAnimator.Play("RodLeft", 5, 0f);
currentRod.fishingLine.handFishHandPoint.GetComponent<Rigidbody>().isKinematic = false;
currentRod.fishingLine.reel.RebindAnim();
ScriptsHandler.Instance.m_InteractionControl.leftHandPoster = InteractionControl.LeftHandPoster.None;
Object.Destroy(currentRod.fishingLine.fishObject.gameObject);
if ((bool)currentRod.fishingLine.lineHookHandHelper)
{
Object.Destroy(currentRod.fishingLine.lineHookHandHelper.gameObject);
currentRod.fishingLine.lineHookHandHelper = null;
}
currentRod.fishingLine.fishObject = null;
}
public void ResetPodbierakFishing()
{
ScriptsHandler.Instance.m_InteractionControl.leftHandPoster = InteractionControl.LeftHandPoster.None;
interactiveObjectsAnimator.SetBool("isFishHand", value: false);
interactiveObjectsAnimator.SetBool("isFish", value: false);
interactiveObjectsAnimator.Play("PullUpRod", 3, 0f);
interactiveObjectsAnimator.Play("RodRight", 5, 0f);
interactiveObjectsAnimator.Play("RodLeft", 5, 0f);
currentRod.fishingLine.handFishHandPoint.GetComponent<Rigidbody>().isKinematic = false;
currentRod.fishingLine.reel.RebindAnim();
currentRod.fishingLine.ropeOut = 0f;
}
public void CutLine()
{
Debug.Log("Cut line");
if (currentRod.fishingLine.fishObject != null)
{
if (currentRod.fishingLine.fishObject.stage == FishMovement.Stage.getFish || currentRod.fishingLine.fishObject.stage == FishMovement.Stage.onPodbierak)
{
return;
}
currentRod.fishingLine.fishObject.unHook();
currentRod.fishingLine.fishObject = null;
interactiveObjectsAnimator.SetBool("isFish", value: false);
currentRod.fishingLine.ropeOut = 0f;
}
if (InputManager.isUnderwaterCamera)
{
DestroyUnderwaterCamera();
}
ScriptsHandler.Instance.m_InventoryManager.CutItems();
StartCoroutine(DoneCutLineAndMessageBox());
}
public void RodDamage()
{
CutFish();
StartCoroutine(DoneDamageRodAndMessageBox());
}
public void CutFish()
{
if (currentRod.fishingLine.fishObject != null && currentRod.fishingLine.fishObject.stage != FishMovement.Stage.getFish && currentRod.fishingLine.fishObject.stage != FishMovement.Stage.onPodbierak)
{
currentRod.fishingLine.fishObject.unHook();
currentRod.fishingLine.fishObject = null;
interactiveObjectsAnimator.SetBool("isFish", value: false);
currentRod.fishingLine.ropeOut = 0f;
if (InputManager.isUnderwaterCamera)
{
DestroyUnderwaterCamera();
}
GameManager.Instance.ShowMessagePopup(LanguageManager.Instance.GetText("CUT_FISH"), ScriptsHandler.Instance.m_Canvas.transform);
}
}
private IEnumerator DoneCutLineAndMessageBox()
{
SetAnimationToIdleByLineOut(0f);
yield return new WaitForSeconds(1f);
ScriptsHandler.Instance.m_InventoryManager.HideRod();
yield return new WaitForSeconds(1f);
GameManager.Instance.CreateMessageBox("CUT_LINE", ScriptsHandler.Instance.m_Canvas.transform, 2);
}
private IEnumerator DoneDamageRodAndMessageBox()
{
SetAnimationToIdleByLineOut(0f);
yield return new WaitForSeconds(1f);
ScriptsHandler.Instance.m_InventoryManager.HideRod();
yield return new WaitForSeconds(1f);
GameManager.Instance.CreateMessageBox("ROD_DAMAGE_QUESTION", ScriptsHandler.Instance.m_Canvas.transform, 2);
}
public void GetFishToHand()
{
if (ScriptsHandler.Instance.m_InteractionControl.leftHandPoster != InteractionControl.LeftHandPoster.HandFish)
{
FishMovement fishObject = currentRod.fishingLine.fishObject;
ScriptsHandler.Instance.m_InteractionControl.leftHandPoster = InteractionControl.LeftHandPoster.HandFish;
interactiveObjectsAnimator.SetBool("isFishHand", value: true);
fishObject.GetComponent<FishStats>().fishAnimator.SetBool("outhook", value: true);
fishObject.GetComponent<FishStats>().fishAnimator.SetFloat("speed", 0f);
fishObject.GetComponent<FishStats>().fishAnimator.SetBool("jump", value: false);
currentRod.fishingLine.ropeOut = 1.5f;
currentRod.fishingLine.AddLineHelperHand();
}
}
public void GetFishToChwytak()
{
if (ScriptsHandler.Instance.m_InteractionControl.leftHandPoster != InteractionControl.LeftHandPoster.HandChwytak)
{
if (podbierak != null)
{
currentRod.fishingLine.fishObject.transform.SetParent(null);
ScriptsHandler.Instance.m_InteractionControl.StopPodbierakInteractionWithLeftHand();
Object.Destroy(podbierak.gameObject);
ResetPodbierakFishing();
}
FishMovement fishObject = currentRod.fishingLine.fishObject;
ScriptsHandler.Instance.m_InteractionControl.leftHandPoster = InteractionControl.LeftHandPoster.HandChwytak;
interactiveObjectsAnimator.SetBool("isFishHand", value: false);
fishObject.GetComponent<FishStats>().fishAnimator.SetBool("outhook", value: true);
fishObject.GetComponent<FishStats>().fishAnimator.SetFloat("speed", 0f);
fishObject.GetComponent<FishStats>().fishAnimator.SetBool("jump", value: false);
}
}
public void CreatePodbierak(bool destroy = false)
{
if (podbierak == null)
{
GameObject gameObject = Object.Instantiate(ScriptsHandler.Instance.PodbierakPrefab, leftHand.transform.position, Quaternion.identity);
podbierak = gameObject.GetComponent<Podbierak>();
gameObject.transform.SetParent(leftHand);
gameObject.transform.localPosition = Vector3.zero;
gameObject.transform.localEulerAngles = Vector3.zero;
interactiveObjectsAnimator.SetBool("isPutPodbierak", value: true);
}
else if (destroy)
{
ScriptsHandler.Instance.m_InteractionControl.StopPodbierakInteractionWithLeftHand();
Object.Destroy(podbierak.gameObject);
}
}
public void CreateChwytak(bool destroy = false)
{
if (chwytak == null)
{
GameObject gameObject = Object.Instantiate(ScriptsHandler.Instance.ChwytakPrefab, leftHand.transform.position, Quaternion.identity);
chwytak = gameObject.GetComponent<Chwytak>();
chwytak.Setup(currentRod.fishingLine.fishObject.transform, leftHand);
interactiveObjectsAnimator.SetBool("isFishChwytak", value: true);
}
else if (destroy)
{
ScriptsHandler.Instance.m_InteractionControl.StopChwytakInteractionWithLeftHand();
interactiveObjectsAnimator.SetBool("isFishChwytak", value: false);
Object.Destroy(chwytak.gameObject);
}
}
private void ConnectingLineToHand()
{
if (interactiveObjectsAnimator.GetBool("isFishHand"))
{
currentRod.fishingLine.handFishHandPoint.position = leftHandFishLinePoint.position;
currentRod.fishingLine.handFishHandPoint.transform.localEulerAngles = Vector3.zero;
}
}
private void CheckAndCatchFish()
{
if (currentRod == null || !InputManager.isCatch)
{
return;
}
Hook hook = currentRod.fishingLine.hook;
Lure lure = currentRod.fishingLine.lure;
FishMovement fishMovement = null;
if (hook != null)
{
if (hook.takeFish != null)
{
fishMovement = hook.takeFish.GetComponent<FishMovement>();
}
}
else if (lure != null && lure.takeFish != null)
{
fishMovement = lure.takeFish.GetComponent<FishMovement>();
}
if ((bool)fishMovement && fishMovement.stage == FishMovement.Stage.freeMove && currentRod.fishingLine.fishObject == null)
{
interactiveObjectsAnimator.SetTrigger("isTake");
fishMovement.SetIsCatch();
currentRod.fishingLine.fishObject = fishMovement;
interactiveObjectsAnimator.SetBool("isFish", value: true);
}
}
private void SetCameraViewTypeByInput()
{
if (InputManager.isCameraChange)
{
if (m_CameraTypeView == CameraTypeView.FishView)
{
SetCameraViewType(CameraTypeView.FirstPerson);
}
else if ((bool)ScriptsHandler.Instance.m_HudManager.fishCatchPanel && m_CameraTypeView == CameraTypeView.FirstPerson)
{
SetCameraViewType(CameraTypeView.FishView);
}
}
}
public void SetCameraViewType(CameraTypeView cameraTypeView)
{
m_CameraTypeView = cameraTypeView;
upDownCameraPos = 0f;
m_Camera.transform.localRotation = Quaternion.identity;
switch (cameraTypeView)
{
case CameraTypeView.FirstPerson:
m_Camera.GetComponent<SmoothFollow>().enabled = false;
m_Camera.transform.localPosition = mainCameraStartPosition;
break;
case CameraTypeView.ThirdPerson:
m_Camera.GetComponent<SmoothFollow>().enabled = true;
m_Camera.GetComponent<SmoothFollow>().target = ThirdPersonCameraPoint;
m_Camera.GetComponent<SmoothFollow>().target.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
m_Camera.GetComponent<SmoothFollow>().viewMode = SmoothFollow.ViewMode.ThirdPerson;
break;
case CameraTypeView.FishView:
m_Camera.GetComponent<SmoothFollow>().enabled = true;
m_Camera.GetComponent<SmoothFollow>().target = ThirdPersonCameraFishPoint;
m_Camera.GetComponent<SmoothFollow>().viewMode = SmoothFollow.ViewMode.FishView;
break;
}
}
private void AutoJointRod()
{
if (rightHandJointPoint == null)
{
return;
}
if (currentRightHandObject != null)
{
if (!(currentRod != null) && currentRightHandObject.GetComponent<FixedJoint>().connectedBody == null)
{
rightHandJointPoint.gameObject.SetActive(value: true);
currentRightHandObject.transform.SetParent(base.transform);
currentRightHandObject.transform.position = rightHandJointPoint.position;
currentRightHandObject.transform.rotation = rightHandJointPoint.rotation;
currentRightHandObject.GetComponent<FixedJoint>().connectedBody = rightHandJointPoint.GetComponent<Rigidbody>();
rightHandJointPoint.parent.transform.GetComponent<HandPoser>().poseRoot = currentRightHandObject.GetComponent<Rod>().rHandPoser;
rightHandJointPoint.parent.transform.GetComponent<HandPoser>().weight = 1f;
currentRightHandObject.GetComponent<Rigidbody>().isKinematic = false;
currentRod = currentRightHandObject.GetComponent<Rod>();
ScriptsHandler.Instance.m_InventoryManager.SetIndexSlotOfRod(currentRod.indexOfslot);
if (currentRod.fishingLine.ropeOut > 0f)
{
ScriptsHandler.Instance.m_InteractionControl.StartReelInteractionWithLeftHand();
interactiveObjectsAnimator.SetInteger("ThrowRod", -2);
}
}
}
else if (!(currentRod == null))
{
if ((bool)rightHandJointPoint.parent.transform.GetComponent<HandPoser>().poseRoot)
{
rightHandJointPoint.parent.transform.GetComponent<HandPoser>().poseRoot = null;
}
if (ScriptsHandler.Instance.m_InteractionControl.LeftHandInteractionWithReel)
{
ScriptsHandler.Instance.m_InteractionControl.StopReelInteractionWithLeftHand();
}
rightHandJointPoint.gameObject.SetActive(value: false);
currentRod = null;
ScriptsHandler.Instance.m_InventoryManager.SetIndexSlotOfRod(-1);
interactiveObjectsAnimator.SetInteger("ThrowRod", -1);
}
}
private void CheckGround()
{
m_underWaterlevel = base.transform.position.y - ScriptsHandler.Instance.WaterObject.position.y;
if (m_underWaterlevel > 0f)
{
m_underWaterlevel = 0f;
}
}
private void AutomaticCharacterController()
{
if ((bool)underWaterCamera)
{
return;
}
if ((bool)ScriptsHandler.Instance.m_HudManager.fishCatchPanel)
{
animator.SetFloat("PlayerWalk", 0f);
animator.SetFloat("PlayerStrafe", 0f);
}
else
{
if (m_CameraTypeView == CameraTypeView.FishView)
{
return;
}
bool flag = false;
bool flag2 = false;
bool flag3 = false;
float num = 1f;
float num2 = CrossPlatformInputManager.GetAxis("Horizontal");
float num3 = CrossPlatformInputManager.GetAxis("Vertical");
if (isThrowStarted)
{
num2 = 0f;
num3 = 0f;
}
if (characterController.isGrounded)
{
verticalVelocity.y = 0f - m_StickToGroundForce;
if (!flag3)
{
lastPositionOnTerrainTemp = base.transform.position;
}
}
else
{
verticalVelocity = Physics.gravity * m_GravityMultiplier * Time.fixedDeltaTime;
characterController.Move(verticalVelocity * Time.fixedDeltaTime);
}
flag3 = ((base.transform.position.y <= ScriptsHandler.Instance.WaterObject.position.y) ? true : false);
if (base.transform.position.y <= ScriptsHandler.Instance.WaterObject.position.y - 1f)
{
characterController.enabled = false;
if (CrossPlatformInputManager.GetButtonDown("Jump"))
{
base.transform.position = lastPositionOnTerrainTemp;
}
else
{
base.transform.position = Vector3.MoveTowards(base.transform.position, lastPositionTemp, Time.deltaTime * 0.01f);
}
flag2 = true;
num3 = 0f;
num2 = 0f;
}
else
{
flag2 = false;
lastPositionTemp = base.transform.position;
characterController.enabled = true;
}
animator.SetFloat("PlayerWalk", num3);
animator.SetFloat("PlayerStrafe", num2);
AnimatorClipInfo[] currentAnimatorClipInfo = animator.GetCurrentAnimatorClipInfo(0);
num = ((!InputManager.isRunning || (bool)currentRod) ? 1f : 2f);
if (CrossPlatformInputManager.GetButtonDown("Jump") && !flag3)
{
animator.SetTrigger("Jump");
}
animator.SetFloat("WalkSpeed", num);
if ((currentAnimatorClipInfo[0].clip.name == "WalkFwdCrossRightLoop" || currentAnimatorClipInfo[0].clip.name == "RunFwdLoop") && num2 > 0f)
{
characterController.Move((base.transform.forward + base.transform.right) * Time.deltaTime * num * 1.5f);
flag = true;
}
if (m_Jumping && num2 > 0f)
{
characterController.Move(base.transform.forward * Time.deltaTime * num);
flag = false;
}
if ((currentAnimatorClipInfo[0].clip.name == "WalkFwdCrossLeftLoop" || currentAnimatorClipInfo[0].clip.name == "RunFwdLoop") && num2 < 0f)
{
characterController.Move((base.transform.forward - base.transform.right) * Time.deltaTime * num * 1.5f);
flag = true;
}
if (currentAnimatorClipInfo[0].clip.name == "WalkBwdCrossRightLoop" && num2 > 0f)
{
characterController.Move((-base.transform.forward + base.transform.right) * Time.deltaTime);
flag = true;
}
if (currentAnimatorClipInfo[0].clip.name == "WalkBwdCrossLeftLoop" && num2 < 0f)
{
characterController.Move((-base.transform.forward - base.transform.right) * Time.deltaTime);
flag = true;
}
if ((num3 == 0f && num2 == 0f) || flag || flag2)
{
if (m_Jumping)
{
animator.applyRootMotion = true;
}
else
{
animator.applyRootMotion = false;
}
}
else
{
animator.applyRootMotion = true;
}
}
}
public void SpawnPlayer(Transform newPosition)
{
Debug.Log("Spawn to: " + newPosition.position.ToString());
base.transform.position = newPosition.position;
lastPositionTemp = newPosition.position;
lastPositionOnTerrainTemp = newPosition.position;
base.transform.localEulerAngles = newPosition.localEulerAngles;
}
public void SetMouseCursor(bool visable)
{
m_MouseLook.SetCursorLock(visable);
m_MouseLook.UpdateCursorLock();
}
private void RotateView()
{
if (!underWaterCamera)
{
if ((bool)ScriptsHandler.Instance.m_HudManager.fishCatchPanel)
{
animator.SetFloat("PlayerRotate", 0f);
}
else if (m_CameraTypeView != CameraTypeView.FishView)
{
m_MouseLook.LookRotation(base.transform, m_Camera.transform);
animator.SetFloat("PlayerRotate", m_MouseLook.RotYvalue);
}
}
}
public void setmJump()
{
if (!ScriptsHandler.Instance.m_HudManager.fishCatchPanel)
{
m_Jumping = true;
}
}
public void unsetmJump()
{
m_Jumping = false;
PlayFootStepAudio();
}
public void PlayFootStepAudio()
{
if (m_underWaterlevel == 0f)
{
if (groundTypeTag == "Bridge")
{
int num = Random.Range(1, m_FootstepSoundsBridge.Length);
m_AudioSource.clip = m_FootstepSoundsBridge[num];
m_AudioSource.PlayOneShot(m_AudioSource.clip, 0.3f);
m_FootstepSoundsBridge[num] = m_FootstepSoundsBridge[0];
m_FootstepSoundsBridge[0] = m_AudioSource.clip;
}
else if (groundTypeTag == "Stone")
{
int num2 = Random.Range(1, m_FootstepSoundsStone.Length);
m_AudioSource.clip = m_FootstepSoundsStone[num2];
m_AudioSource.PlayOneShot(m_AudioSource.clip, 0.3f);
m_FootstepSoundsStone[num2] = m_FootstepSoundsStone[0];
m_FootstepSoundsStone[0] = m_AudioSource.clip;
}
else
{
int num3 = Random.Range(1, m_FootstepSounds.Length);
m_AudioSource.clip = m_FootstepSounds[num3];
m_AudioSource.PlayOneShot(m_AudioSource.clip, 0.3f);
m_FootstepSounds[num3] = m_FootstepSounds[0];
m_FootstepSounds[0] = m_AudioSource.clip;
}
}
else
{
int num4 = Random.Range(1, m_FootstepSoundsWater.Length);
m_AudioSource.clip = m_FootstepSoundsWater[num4];
m_AudioSource.PlayOneShot(m_AudioSource.clip, 0.3f);
m_FootstepSoundsWater[num4] = m_FootstepSoundsWater[0];
m_FootstepSoundsWater[0] = m_AudioSource.clip;
Debug.Log("m_underWaterlevel: " + m_underWaterlevel);
PlayStepWaterEffect();
}
}
private void PlayStepWaterEffect()
{
GameObject obj = Object.Instantiate(waterFXStepfootPrefab);
obj.transform.position = new Vector3(base.transform.position.x, ScriptsHandler.Instance.WaterObject.transform.position.y + 0.05f, base.transform.position.z);
obj.transform.localEulerAngles = base.transform.localEulerAngles;
}
private void UnderWaterCameraControler()
{
if (currentRod == null || currentRod.isTrowing || (bool)ScriptsHandler.Instance.m_HudManager.fishCatchPanel || Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().GameMode == GameManager.PlayerData.CPlayer.GameMode.Realistic)
{
return;
}
if (currentRod.fishingLine.ropeOut < 5f)
{
if (underWaterCamera != null)
{
DestroyUnderwaterCamera();
}
}
else if (InputManager.isUnderwaterCamera)
{
if (underWaterCamera == null)
{
underWaterCamera = Object.Instantiate(ScriptsHandler.Instance.underWaterCameraPrefab, ScriptsHandler.Instance.transform);
underWaterCamera.GetComponent<SmoothFollowUnderwater>().target = currentRod.fishingLine.lastPointDisplacement.transform;
Camera camera = (currentCameraView = underWaterCamera.GetComponentInChildren<Camera>());
camera.rect = new Rect(0f, 0f, 1f, 1f);
m_Camera.gameObject.SetActive(value: false);
camera.GetComponentInChildren<AudioListener>().enabled = true;
}
}
else if (underWaterCamera != null)
{
DestroyUnderwaterCamera();
}
}
private void DestroyUnderwaterCamera()
{
m_Camera.gameObject.SetActive(value: true);
currentCameraView = m_Camera;
Object.Destroy(underWaterCamera.gameObject);
InputManager.isUnderwaterCamera = false;
}
private void OnControllerColliderHit(ControllerColliderHit hit)
{
groundTypeTag = hit.transform.tag;
}
}