626 lines
21 KiB
C#
626 lines
21 KiB
C#
using System.Collections;
|
|
using BitStrap;
|
|
using UnityEngine;
|
|
using uNature.Core.Seekers;
|
|
|
|
public class UnderwaterCamera : MonoBehaviour
|
|
{
|
|
[ReadOnly]
|
|
public bool isTurnedOn;
|
|
|
|
[HideInInspector]
|
|
public Transform cameraParent;
|
|
|
|
[HideInInspector]
|
|
public FishingPlayer fishingPlayer;
|
|
|
|
[HideInInspector]
|
|
public Camera camera;
|
|
|
|
private LayerMask ufpsCameraLayerMask = 0;
|
|
|
|
private LayerMask weaponCameraLayerMask = 0;
|
|
|
|
[Header("Lines")]
|
|
public float underwaterLineScale = 0.0003f;
|
|
|
|
public MeshRenderer lineUnderwater;
|
|
|
|
public MeshRenderer lineUnderwaterFloat;
|
|
|
|
public MeshRenderer lineUnderwaterLeader;
|
|
|
|
public float lineUnderwaterRotateSpeed = 666f;
|
|
|
|
[ReadOnly]
|
|
public Quaternion targetLineRotation = Quaternion.identity;
|
|
|
|
[ReadOnly]
|
|
public Quaternion currentLineRotation = Quaternion.identity;
|
|
|
|
public float lineRotationSpeed = 666f;
|
|
|
|
private float floatRopeRadius = -1f;
|
|
|
|
[HideInInspector]
|
|
public AudioObject underwaterAudioObject;
|
|
|
|
[ReadOnly]
|
|
public bool isChanging;
|
|
|
|
[ReadOnly]
|
|
public bool hasProperHeight;
|
|
|
|
[Header("Camera Properties")]
|
|
public bool updateLookAt = true;
|
|
|
|
public float updateLookAtThreshold = 10f;
|
|
|
|
public float farClipDistance = 100f;
|
|
|
|
public float farClipDistanceOverWater = 1000f;
|
|
|
|
public float DistanceAway;
|
|
|
|
public float underwaterDistanceMultiplier = 2f;
|
|
|
|
public Vector2 DistanceAwayHook = Vector2.one;
|
|
|
|
[ReadOnly]
|
|
public float currentDistanceAway;
|
|
|
|
public float DistanceUp;
|
|
|
|
public float currentDistanceUp;
|
|
|
|
public float DistanceUpCollision = 0.5f;
|
|
|
|
public float camPositionParameter = 0.5f;
|
|
|
|
public Vector2 smoothNormal = new Vector2(99f, 10f);
|
|
|
|
public Vector2 smoothCollision = new Vector2(0f, 999f);
|
|
|
|
public Vector2 smoothFight = new Vector2(10f, 999f);
|
|
|
|
public bool maxSmoothInVR = true;
|
|
|
|
[ReadOnly]
|
|
public float smoothCurrent;
|
|
|
|
[ReadOnly]
|
|
public Vector2 smoothTarget = Vector2.zero;
|
|
|
|
public float lookAtSpeed = 10f;
|
|
|
|
[Space(10f)]
|
|
[ReadOnly]
|
|
public float rotateAround;
|
|
|
|
public float rotateAroundOffset = -35f;
|
|
|
|
[Header("Player to follow")]
|
|
public Transform target;
|
|
|
|
[Header("Layer(s) to include")]
|
|
public LayerMask CamOcclusion;
|
|
|
|
public LayerMask collisionLayers;
|
|
|
|
public float overlapSphereRadius = 1f;
|
|
|
|
public Vector2 ignoreCollisionDistance = Vector2.one;
|
|
|
|
[ReadOnly]
|
|
public Collider[] results = new Collider[0];
|
|
|
|
[ReadOnly]
|
|
public SphereCollider sphereCollider;
|
|
|
|
private RaycastHit hit;
|
|
|
|
private float cameraHeight = 55f;
|
|
|
|
private float cameraPan;
|
|
|
|
private float camRotateSpeed = 180f;
|
|
|
|
private Vector3 camPosition;
|
|
|
|
private Vector3 camMask;
|
|
|
|
private Vector3 followMask;
|
|
|
|
private float sunShaftsIntencity = 1.5f;
|
|
|
|
public float vrStartCameraRotation;
|
|
|
|
public float vrCameraWaterLevel = 0.3f;
|
|
|
|
public float vrCameraGroundLevel = 1f;
|
|
|
|
private RaycastHit vrHit = default(RaycastHit);
|
|
|
|
private void Start()
|
|
{
|
|
cameraParent = base.transform.parent;
|
|
camera = GetComponent<Camera>();
|
|
camera.enabled = false;
|
|
currentDistanceAway = DistanceAway;
|
|
sphereCollider = GetComponent<SphereCollider>();
|
|
underwaterAudioObject = AudioController.Play("Ambient_Underwater_01");
|
|
if ((bool)underwaterAudioObject)
|
|
{
|
|
underwaterAudioObject.Pause();
|
|
}
|
|
currentDistanceUp = DistanceUp;
|
|
GetComponent<AudioListener>().enabled = false;
|
|
base.gameObject.SetActive(false);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (isTurnedOn)
|
|
{
|
|
if (fishingPlayer.currentHands.bait == null || fishingPlayer.currentHands.bait.ropeRigidbody == null)
|
|
{
|
|
Debug.LogError("no bait or bait.rigidbody");
|
|
}
|
|
if (!fishingPlayer.fish && ((!fishingPlayer.gameController.iceLevel && target.position.y > ((!VRManager.IsVROn()) ? 0.3f : 0.1f)) || (fishingPlayer.gameController.iceLevel && !HasProperHeight())))
|
|
{
|
|
StartCoroutine(TurnOn(false, true));
|
|
fishingPlayer.gameController.hudManager.UpdateControls();
|
|
}
|
|
if (fishingPlayer.IsFishOnCurrentRod() && (!fishingPlayer.currentHands.fishingFloat || fishingPlayer.fish.isJerked))
|
|
{
|
|
target = fishingPlayer.fish.transform;
|
|
}
|
|
else
|
|
{
|
|
target = fishingPlayer.currentHands.bait.transform;
|
|
}
|
|
if (cameraParent.position.y < -0.05f)
|
|
{
|
|
camera.farClipPlane = farClipDistance;
|
|
}
|
|
else
|
|
{
|
|
camera.farClipPlane = farClipDistanceOverWater;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (!isTurnedOn || lineUnderwater == null)
|
|
{
|
|
return;
|
|
}
|
|
if (!fishingPlayer.IsFishOnCurrentRod())
|
|
{
|
|
if ((bool)fishingPlayer.junk)
|
|
{
|
|
currentDistanceAway = fishingPlayer.junk.weight * 0.2f;
|
|
}
|
|
else if (!fishingPlayer.fish)
|
|
{
|
|
currentDistanceAway = Mathf.Lerp(DistanceAwayHook.x, DistanceAwayHook.y, (float)fishingPlayer.currentHands.bait.hookSize / 16f);
|
|
if (fishingPlayer.currentHands.isGroundRig)
|
|
{
|
|
currentDistanceAway *= 2f;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
currentDistanceAway = DistanceAway;
|
|
}
|
|
}
|
|
if (VRManager.IsVROn() && !fishingPlayer.IsFishOnCurrentRod())
|
|
{
|
|
currentDistanceAway *= underwaterDistanceMultiplier;
|
|
}
|
|
Vector3 a = target.position - fishingPlayer.transform.position;
|
|
a.y = 0f;
|
|
float num = PosNegAngle(a, Vector3.forward, Vector3.up);
|
|
num = ((!(num < 0f)) ? (360f - num) : (0f - num));
|
|
num += rotateAroundOffset;
|
|
rotateAround = num;
|
|
Vector3 targetFollow = new Vector3(target.position.x, target.position.y, target.position.z);
|
|
Quaternion quaternion = Quaternion.Euler(cameraHeight, rotateAround, cameraPan);
|
|
Vector3 one = Vector3.one;
|
|
Vector3 vector = quaternion * one;
|
|
currentDistanceUp = Mathf.MoveTowards(currentDistanceUp, DistanceUp, Time.deltaTime * ((!fishingPlayer.IsFishOnCurrentRod() || fishingPlayer.fish.isTryingBait) ? 0.05f : 1f));
|
|
camPosition = targetFollow + Vector3.up * currentDistanceUp - vector * currentDistanceAway;
|
|
camMask = targetFollow + Vector3.up * DistanceUpCollision - vector * currentDistanceAway;
|
|
int num2 = Physics.OverlapSphereNonAlloc(target.position, overlapSphereRadius, results, collisionLayers);
|
|
Collider[] array = Physics.OverlapSphere(target.position, overlapSphereRadius, collisionLayers);
|
|
if (fishingPlayer.IsFishOnCurrentRod() && (!fishingPlayer.currentHands.isGroundRig || fishingPlayer.fish.isJerked))
|
|
{
|
|
sphereCollider.enabled = false;
|
|
DistanceUp = 0f;
|
|
smoothTarget = smoothFight;
|
|
}
|
|
else if (array.Length > 0 && Vector3.Distance(cameraParent.position, target.position) < ignoreCollisionDistance.x)
|
|
{
|
|
sphereCollider.enabled = true;
|
|
DistanceUp = ((!fishingPlayer.currentHands.fishingFloat) ? 0.25f : 0.2f);
|
|
smoothTarget = smoothCollision;
|
|
}
|
|
else
|
|
{
|
|
sphereCollider.enabled = true;
|
|
DistanceUp = ((!fishingPlayer.currentHands.fishingFloat) ? 0.25f : 0.2f);
|
|
smoothTarget = smoothNormal;
|
|
occludeRay(ref targetFollow);
|
|
}
|
|
if (VRManager.IsVROn())
|
|
{
|
|
sphereCollider.enabled = false;
|
|
}
|
|
smoothCamMethod();
|
|
Vector3 vectorAngles180Range = Utilities.GetVectorAngles180Range(cameraParent.localEulerAngles);
|
|
if (updateLookAt)
|
|
{
|
|
cameraParent.LookAt(target);
|
|
}
|
|
Vector3 vector2 = Utilities.GetVectorAngles180Range(cameraParent.localEulerAngles);
|
|
if (VRManager.IsVROn())
|
|
{
|
|
vector2 = new Vector3(vector2.x, vector2.y - vrStartCameraRotation, vector2.z);
|
|
}
|
|
float num3 = Vector3.Distance(vectorAngles180Range, vector2);
|
|
if (num3 > 180f || num3 < -180f)
|
|
{
|
|
if (vector2.y >= 0f)
|
|
{
|
|
vector2.y -= 360f;
|
|
}
|
|
else if (vector2.y <= 0f)
|
|
{
|
|
vector2.y += 360f;
|
|
}
|
|
num3 = Vector3.Distance(vectorAngles180Range, vector2);
|
|
Utilities.LogError(string.Concat(string.Empty, num3, " oldRotation: ", vectorAngles180Range, " newRotation: ", vector2), "cyan");
|
|
}
|
|
if (num3 > updateLookAtThreshold)
|
|
{
|
|
cameraParent.localEulerAngles = Vector3.MoveTowards(vectorAngles180Range, vector2, num3 * lookAtSpeed * Time.deltaTime);
|
|
}
|
|
else
|
|
{
|
|
cameraParent.localEulerAngles = vectorAngles180Range;
|
|
}
|
|
if (VRManager.IsVROn())
|
|
{
|
|
cameraParent.localEulerAngles = new Vector3(0f, cameraParent.localEulerAngles.y, 0f);
|
|
}
|
|
currentLineRotation = lineUnderwater.transform.parent.rotation;
|
|
if (!GameController.Instance.iceLevel)
|
|
{
|
|
lineUnderwater.transform.parent.LookAt(fishingPlayer.currentHands.fishingRod.ropeStartPosition);
|
|
}
|
|
else
|
|
{
|
|
lineUnderwater.transform.parent.LookAt(fishingPlayer.currentHands.fakeLineIceTarget.transform);
|
|
}
|
|
if (lineRotationSpeed > -1f)
|
|
{
|
|
targetLineRotation = lineUnderwater.transform.parent.rotation;
|
|
lineUnderwater.transform.parent.rotation = Quaternion.RotateTowards(currentLineRotation, targetLineRotation, lineRotationSpeed);
|
|
}
|
|
lineUnderwaterLeader.enabled = fishingPlayer.currentHands.isFlyRig;
|
|
if (fishingPlayer.currentHands.isFlyRig)
|
|
{
|
|
lineUnderwaterLeader.transform.localScale = new Vector3(lineUnderwaterLeader.transform.localScale.x, fishingPlayer.currentHands.fishingRod.GetThrowObjectDistance() - fishingPlayer.currentHands.lineLeaderLength, lineUnderwaterLeader.transform.localScale.z);
|
|
}
|
|
lineUnderwater.transform.localScale = new Vector3(lineUnderwater.transform.localScale.x, fishingPlayer.currentHands.fishingRod.GetThrowObjectDistance(), lineUnderwater.transform.localScale.z);
|
|
if ((bool)fishingPlayer.currentHands.fishingFloat)
|
|
{
|
|
lineUnderwaterFloat.transform.parent.LookAt(fishingPlayer.currentHands.fishingFloat.ropeBaitRigidbody.transform);
|
|
lineUnderwaterFloat.transform.localScale = new Vector3(lineUnderwaterFloat.transform.localScale.x, Vector3.Distance(lineUnderwaterFloat.transform.position, fishingPlayer.currentHands.fishingFloat.ropeBaitRigidbody.transform.position), lineUnderwaterFloat.transform.localScale.z);
|
|
}
|
|
}
|
|
|
|
public IEnumerator TurnOn(bool turnOn, bool fromReset = false)
|
|
{
|
|
if (isTurnedOn == turnOn || isChanging)
|
|
{
|
|
yield break;
|
|
}
|
|
isChanging = true;
|
|
if (!VRManager.IsVROn())
|
|
{
|
|
fishingPlayer.gameController.hudManager.FadeDark(1f, (!fromReset) ? 0.1f : 0f);
|
|
yield return new WaitForSeconds((!fromReset) ? 0.1f : 0.1f);
|
|
}
|
|
isTurnedOn = turnOn;
|
|
if (turnOn)
|
|
{
|
|
camera.enabled = false;
|
|
base.gameObject.SetActive(true);
|
|
}
|
|
HUDManager.Instance.UpdateControls();
|
|
if (turnOn)
|
|
{
|
|
Utilities.SetLayerRecursively(base.gameObject, LayerMask.NameToLayer("Default"));
|
|
base.gameObject.layer = LayerMask.NameToLayer("Float");
|
|
target = fishingPlayer.currentHands.bait.transform;
|
|
cameraParent.position = target.position;
|
|
cameraParent.LookAt(target);
|
|
smoothTarget = smoothNormal;
|
|
smoothCurrent = smoothTarget.x;
|
|
ufpsCameraLayerMask = fishingPlayer.ufpsCamera.GetComponent<Camera>().cullingMask;
|
|
weaponCameraLayerMask = fishingPlayer.ufpsWeaponCamera.GetComponent<Camera>().cullingMask;
|
|
camera.cullingMask = ufpsCameraLayerMask;
|
|
if (VRManager.IsVROn())
|
|
{
|
|
camera.cullingMask = Utilities.RemoveFromLayerMask(camera.cullingMask, "Weapon");
|
|
vrStartCameraRotation = fishingPlayer.ufpsCamera.transform.localEulerAngles.y;
|
|
if (vrStartCameraRotation > 180f)
|
|
{
|
|
vrStartCameraRotation -= 360f;
|
|
}
|
|
else if (vrStartCameraRotation < -180f)
|
|
{
|
|
vrStartCameraRotation += 360f;
|
|
}
|
|
}
|
|
fishingPlayer.ufpsCamera.GetComponent<Camera>().cullingMask = 0;
|
|
fishingPlayer.ufpsWeaponCamera.GetComponent<Camera>().cullingMask = 0;
|
|
fishingPlayer.ufpsCamera.GetComponent<Camera>().clearFlags = CameraClearFlags.Depth;
|
|
fishingPlayer.depthOfField.enabled = false;
|
|
fishingPlayer.beautify.enabled = false;
|
|
MeshRenderer meshRenderer = lineUnderwater;
|
|
Material lineMaterialOpaque = fishingPlayer.currentHands.fishingLine.lineMaterialOpaque;
|
|
lineUnderwaterFloat.material = lineMaterialOpaque;
|
|
meshRenderer.material = lineMaterialOpaque;
|
|
lineUnderwater.transform.localScale = new Vector3(underwaterLineScale, 1f, underwaterLineScale);
|
|
if (fishingPlayer.currentHands.isFlyRig)
|
|
{
|
|
lineUnderwater.transform.localScale *= 9f;
|
|
}
|
|
lineUnderwaterFloat.transform.localScale = new Vector3(underwaterLineScale * 0.9f, 1f, underwaterLineScale * 0.9f);
|
|
lineUnderwaterLeader.transform.localScale = new Vector3(underwaterLineScale, 1f, underwaterLineScale);
|
|
if ((bool)fishingPlayer.currentHands.fishingFloat)
|
|
{
|
|
lineUnderwater.transform.parent.parent = fishingPlayer.currentHands.fishingFloat.ropeBaitRigidbody.transform;
|
|
}
|
|
else
|
|
{
|
|
lineUnderwater.transform.parent.parent = target;
|
|
}
|
|
lineUnderwaterFloat.transform.parent.parent = target;
|
|
lineUnderwaterFloat.gameObject.SetActive(fishingPlayer.currentHands.fishingFloat);
|
|
lineUnderwater.transform.parent.localPosition = Vector3.zero;
|
|
lineUnderwaterFloat.transform.parent.localPosition = Vector3.zero;
|
|
if (fishingPlayer.currentHands.isFlyRig)
|
|
{
|
|
lineUnderwater.transform.localPosition = lineUnderwaterLeader.transform.localPosition + Vector3.forward * fishingPlayer.currentHands.lineLeaderLength;
|
|
}
|
|
else
|
|
{
|
|
lineUnderwater.transform.localPosition = Vector3.zero;
|
|
}
|
|
if ((bool)underwaterAudioObject)
|
|
{
|
|
underwaterAudioObject.Unpause(0.3f);
|
|
}
|
|
if ((bool)fishingPlayer.currentHands.fishingFloat)
|
|
{
|
|
}
|
|
if ((bool)fishingPlayer.sunShafts)
|
|
{
|
|
sunShaftsIntencity = fishingPlayer.sunShafts.sunShaftIntensity;
|
|
fishingPlayer.sunShafts.sunShaftIntensity = 0f;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
fishingPlayer.ufpsCamera.GetComponent<Camera>().cullingMask = ufpsCameraLayerMask.value;
|
|
fishingPlayer.ufpsWeaponCamera.GetComponent<Camera>().cullingMask = weaponCameraLayerMask.value;
|
|
camera.cullingMask = 0;
|
|
fishingPlayer.ufpsCamera.GetComponent<Camera>().clearFlags = CameraClearFlags.Skybox;
|
|
if (!VRManager.IsVROn())
|
|
{
|
|
fishingPlayer.depthOfField.enabled = true;
|
|
fishingPlayer.beautify.enabled = true;
|
|
}
|
|
lineUnderwater.transform.parent.parent = base.transform;
|
|
lineUnderwaterFloat.transform.parent.parent = base.transform;
|
|
if ((bool)underwaterAudioObject)
|
|
{
|
|
underwaterAudioObject.Pause(0.3f);
|
|
}
|
|
if ((bool)fishingPlayer.currentHands.fishingFloat)
|
|
{
|
|
}
|
|
if ((bool)fishingPlayer.sunShafts)
|
|
{
|
|
fishingPlayer.sunShafts.sunShaftIntensity = sunShaftsIntencity;
|
|
}
|
|
}
|
|
GameController.Instance.ShowIceBottom(turnOn);
|
|
fishingPlayer.maskCamera.transform.parent = ((!turnOn) ? fishingPlayer.ufpsCamera.transform : base.transform);
|
|
fishingPlayer.maskCamera.transform.localPosition = Vector3.zero;
|
|
fishingPlayer.maskCamera.transform.localEulerAngles = Vector3.zero;
|
|
fishingPlayer.maskCamera.ChangeCamera((!turnOn) ? fishingPlayer.ufpsCamera.GetComponent<Camera>() : camera);
|
|
if (GameController.Instance.iceLevel)
|
|
{
|
|
fishingPlayer.currentHands.currentRope.gameObject.layer = LayerMask.NameToLayer((!turnOn) ? "Default" : "Weapon");
|
|
fishingPlayer.currentHands.fakeIceLine.gameObject.layer = LayerMask.NameToLayer((!turnOn) ? "Default" : "Weapon");
|
|
}
|
|
GameController.Instance.CheckBehaviorDistanceQuick();
|
|
fishingPlayer.currentHands.UpdateFloatWeightPosition(turnOn);
|
|
if ((bool)fishingPlayer.currentHands.feeder)
|
|
{
|
|
fishingPlayer.currentHands.feeder.UpdateFeederPosition(turnOn);
|
|
}
|
|
sphereCollider.enabled = true;
|
|
if (!VRManager.IsVROn())
|
|
{
|
|
yield return new WaitForSeconds(0.3f);
|
|
}
|
|
fishingPlayer.GetComponent<AudioListener>().enabled = !turnOn;
|
|
GetComponent<AudioListener>().enabled = turnOn;
|
|
if (!GameController.Instance.iceLevel)
|
|
{
|
|
}
|
|
fishingPlayer.baitIndicatorCamera.transform.parent = ((!turnOn) ? fishingPlayer.ufpsCamera.transform : fishingPlayer.underwaterCamera.transform);
|
|
fishingPlayer.baitIndicatorCamera.transform.localPosition = Vector3.zero;
|
|
fishingPlayer.baitIndicatorCamera.transform.localEulerAngles = Vector3.zero;
|
|
fishingPlayer.baitIndicator.underwaterBackground.enabled = turnOn;
|
|
fishingPlayer.ufpsCamera.GetComponent<Camera>().enabled = !turnOn;
|
|
camera.enabled = turnOn;
|
|
if (fishingPlayer.unSeeker.enabled)
|
|
{
|
|
fishingPlayer.unSeeker.isGrassReceiver = !turnOn;
|
|
}
|
|
if (camera.GetComponent<UNSeeker>().enabled)
|
|
{
|
|
camera.GetComponent<UNSeeker>().isGrassReceiver = turnOn;
|
|
}
|
|
fishingPlayer.currentWaterDropPro = ((!turnOn) ? fishingPlayer.waterDropPro : fishingPlayer.waterDropProUnderwater);
|
|
fishingPlayer.waterDropProUnderwater.enabled = false;
|
|
fishingPlayer.RefreshInputSettings();
|
|
fishingPlayer.rain.gameObject.layer = LayerMask.NameToLayer((!turnOn) ? "Weapon" : "TransparentFX");
|
|
fishingPlayer.snow.gameObject.layer = LayerMask.NameToLayer((!turnOn) ? "Default" : "TransparentFX");
|
|
AudioController.SetCategoryVolume("Overwater", (!turnOn) ? 1f : 0f);
|
|
AudioController.SetCategoryVolume("Underwater", (!turnOn) ? 0f : 1f);
|
|
GameController.Instance.waterParameters.SetReflectionColor(turnOn);
|
|
GameController.Instance.waterParameters.SetCausticIntensity(turnOn);
|
|
GameController.Instance.UpdateTerrainTile();
|
|
if (VRManager.IsVROn() && (bool)GlobalSettings.Instance)
|
|
{
|
|
GlobalSettings.Instance.renderSettings.RefreshAntialiasing();
|
|
}
|
|
if (turnOn)
|
|
{
|
|
cameraParent.LookAt(target);
|
|
}
|
|
if (!VRManager.IsVROn())
|
|
{
|
|
fishingPlayer.gameController.hudManager.FadeDark(0f, 0.1f);
|
|
yield return new WaitForSeconds(0.1f);
|
|
}
|
|
fishingPlayer.waterSimulationSpace.transform.parent = ((!turnOn) ? fishingPlayer.transform : base.transform);
|
|
fishingPlayer.waterSimulationSpace.transform.localPosition = Vector3.zero;
|
|
fishingPlayer.waterSimulationSpace.transform.localScale = ((!turnOn) ? new Vector3(4f, 1f, 4f) : new Vector3(1f, 1f, 1f));
|
|
fishingPlayer.waterSimulationSpace.Refresh();
|
|
isChanging = false;
|
|
cameraParent.parent = ((!turnOn) ? fishingPlayer.transform : GameController.Instance.transform);
|
|
GameController.Instance.weatherLevelManager.UpdateWaterProfiles();
|
|
if (!turnOn)
|
|
{
|
|
base.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void SetDistanceAway(float distance, float duration)
|
|
{
|
|
Debug.Log("UnderwaterCamera SetDistanceAway: " + distance);
|
|
if (!base.gameObject.activeSelf || duration == 0f)
|
|
{
|
|
currentDistanceAway = distance;
|
|
if (VRManager.IsVROn())
|
|
{
|
|
currentDistanceAway *= underwaterDistanceMultiplier;
|
|
}
|
|
return;
|
|
}
|
|
LeanTween.value(currentDistanceAway, distance, duration).setEaseInOutQuad().setOnUpdate(delegate(float val)
|
|
{
|
|
currentDistanceAway = val;
|
|
if (VRManager.IsVROn())
|
|
{
|
|
currentDistanceAway *= underwaterDistanceMultiplier;
|
|
}
|
|
});
|
|
}
|
|
|
|
public bool HasProperHeight()
|
|
{
|
|
return hasProperHeight;
|
|
}
|
|
|
|
public void UpdateProperHeight()
|
|
{
|
|
if (!fishingPlayer || !fishingPlayer.currentHands)
|
|
{
|
|
hasProperHeight = false;
|
|
return;
|
|
}
|
|
bool flag = false;
|
|
flag = ((!fishingPlayer.gameController.iceLevel) ? (fishingPlayer.currentHands.bait.transform.position.y < 0.1f) : (!(fishingPlayer.drillingController.currentHole == null) && fishingPlayer.currentHands.bait.transform.position.y < ((!VRManager.IsVROn()) ? (-0.2f) : (-0.8f))));
|
|
if (flag != hasProperHeight)
|
|
{
|
|
hasProperHeight = flag;
|
|
fishingPlayer.gameController.hudManager.UpdateControls();
|
|
}
|
|
}
|
|
|
|
private void smoothCamMethod()
|
|
{
|
|
float num = ((!GameController.Instance.iceLevel) ? (-0.2f) : (GameController.Instance.iceBottom.transform.position.y - 0.1f));
|
|
if (fishingPlayer.IsFishOnCurrentRod() && !GameController.Instance.iceLevel)
|
|
{
|
|
num = -0.4f;
|
|
}
|
|
if (camPosition.y > num && (!fishingPlayer.currentHands.fishingFloat || (fishingPlayer.IsFishOnCurrentRod() && fishingPlayer.fish.isJerked)))
|
|
{
|
|
DistanceUp = ((!fishingPlayer.fish || fishingPlayer.fish.isTryingBait) ? 0.35f : 0.65f);
|
|
}
|
|
smoothCurrent = Mathf.MoveTowards(smoothCurrent, smoothTarget.x, Time.deltaTime * smoothTarget.y);
|
|
cameraParent.position = Vector3.Lerp(cameraParent.position, camPosition, Time.deltaTime * smoothCurrent);
|
|
if (maxSmoothInVR && VRManager.IsVROn())
|
|
{
|
|
cameraParent.position = camPosition;
|
|
}
|
|
if (GameController.Instance.iceLevel && cameraParent.position.y > GameController.Instance.iceBottom.transform.position.y - sphereCollider.radius)
|
|
{
|
|
cameraParent.position = new Vector3(cameraParent.position.x, GameController.Instance.iceBottom.transform.position.y - sphereCollider.radius, cameraParent.position.z);
|
|
}
|
|
else if ((bool)fishingPlayer.fish && fishingPlayer.fish.isJumping && cameraParent.position.y > 0f)
|
|
{
|
|
cameraParent.position = new Vector3(cameraParent.position.x, 0f, cameraParent.position.z);
|
|
}
|
|
else if (!GameController.Instance.iceLevel && !(cameraParent.position.y > -0.2f))
|
|
{
|
|
}
|
|
if (VRManager.IsVROn())
|
|
{
|
|
float value = target.position.y - camera.transform.localPosition.y;
|
|
if (target.position.y > 0f - vrCameraWaterLevel)
|
|
{
|
|
value = 0f - target.position.y - vrCameraWaterLevel - camera.transform.localPosition.y;
|
|
}
|
|
else if (Physics.Raycast(new Vector3(camera.transform.position.x, 0f, camera.transform.position.z), -Vector3.up, out vrHit, 100f, LayerMask.GetMask("Terrain", "Default")) && target.position.y - vrHit.point.y < vrCameraGroundLevel)
|
|
{
|
|
value = vrHit.point.y + vrCameraGroundLevel - camera.transform.localPosition.y;
|
|
}
|
|
value = Mathf.Clamp(value, -9999f, 0f - vrCameraWaterLevel - camera.transform.localPosition.y);
|
|
cameraParent.position = new Vector3(cameraParent.position.x, value, cameraParent.position.z);
|
|
}
|
|
else
|
|
{
|
|
camera.transform.localPosition = Vector3.zero;
|
|
camera.transform.localEulerAngles = Vector3.zero;
|
|
}
|
|
}
|
|
|
|
private void occludeRay(ref Vector3 targetFollow)
|
|
{
|
|
RaycastHit hitInfo = default(RaycastHit);
|
|
if (Physics.Linecast(targetFollow, camMask, out hitInfo, CamOcclusion))
|
|
{
|
|
camPosition = new Vector3(hitInfo.point.x + hitInfo.normal.x * camPositionParameter, hitInfo.point.y + hitInfo.normal.y * camPositionParameter, hitInfo.point.z + hitInfo.normal.z * camPositionParameter);
|
|
}
|
|
}
|
|
|
|
public static float PosNegAngle(Vector3 a1, Vector3 a2, Vector3 normal)
|
|
{
|
|
float num = Vector3.Angle(a1, a2);
|
|
float num2 = Mathf.Sign(Vector3.Dot(normal, Vector3.Cross(a1, a2)));
|
|
return num * num2;
|
|
}
|
|
}
|