首次提交
This commit is contained in:
3
Assets/Scripts/ThirdParty/FirstPersonController.meta
vendored
Normal file
3
Assets/Scripts/ThirdParty/FirstPersonController.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19ffa462a8ae4066a12d946a8b80cab0
|
||||
timeCreated: 1748446110
|
||||
326
Assets/Scripts/ThirdParty/FirstPersonController/FirstPersonController.cs
vendored
Normal file
326
Assets/Scripts/ThirdParty/FirstPersonController/FirstPersonController.cs
vendored
Normal file
@@ -0,0 +1,326 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[RequireComponent(typeof(CharacterController))]
|
||||
[RequireComponent(typeof(AudioSource))]
|
||||
public class FirstPersonController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private bool m_IsWalking;
|
||||
|
||||
[SerializeField] public float m_WalkSpeed;
|
||||
|
||||
[SerializeField] public float m_RunSpeed;
|
||||
|
||||
[SerializeField] [Range(0f, 1f)] private float m_RunstepLenghten;
|
||||
|
||||
[SerializeField] private float m_JumpSpeed;
|
||||
|
||||
[SerializeField] private float m_StickToGroundForce;
|
||||
|
||||
[SerializeField] private float m_GravityMultiplier;
|
||||
|
||||
[SerializeField] public MouseLook m_MouseLook;
|
||||
|
||||
[SerializeField] private bool m_UseFovKick;
|
||||
|
||||
[SerializeField] private FOVKick m_FovKick = new FOVKick();
|
||||
|
||||
[SerializeField] private bool m_UseHeadBob;
|
||||
|
||||
[SerializeField] private CurveControlledBob m_HeadBob = new CurveControlledBob();
|
||||
|
||||
[SerializeField] private LerpControlledBob m_JumpBob = new LerpControlledBob();
|
||||
|
||||
[SerializeField] private float m_StepInterval;
|
||||
|
||||
[SerializeField] private AudioClip[] m_FootstepSounds;
|
||||
|
||||
[SerializeField] private AudioClip[] m_FootstepSoundsBridge;
|
||||
|
||||
[SerializeField] private AudioClip[] m_FootstepSoundsStone;
|
||||
|
||||
[SerializeField] private AudioClip m_JumpSound;
|
||||
|
||||
[SerializeField] private AudioClip m_LandSound;
|
||||
|
||||
private Camera m_Camera;
|
||||
|
||||
private bool m_Jump;
|
||||
|
||||
public bool frezzeRotation;
|
||||
|
||||
public bool frezzePosition;
|
||||
|
||||
public bool rotateMouseInFixedUpdate = true;
|
||||
|
||||
public Vector2 m_Input;
|
||||
|
||||
public Vector3 m_MoveDir = Vector3.zero;
|
||||
|
||||
public CharacterController m_CharacterController;
|
||||
|
||||
private CollisionFlags m_CollisionFlags;
|
||||
|
||||
private bool m_PreviouslyGrounded;
|
||||
|
||||
private Vector3 m_OriginalCameraPosition;
|
||||
|
||||
private float m_StepCycle;
|
||||
|
||||
private float m_NextStep;
|
||||
|
||||
private bool m_Jumping;
|
||||
|
||||
private AudioSource m_AudioSource;
|
||||
|
||||
private string groundTypeTag = "";
|
||||
|
||||
public float horizontal;
|
||||
|
||||
public float vertical;
|
||||
|
||||
public bool isJumping;
|
||||
|
||||
public bool isRuning;
|
||||
|
||||
public bool notMove;
|
||||
|
||||
public bool isWater;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
m_CharacterController = GetComponent<CharacterController>();
|
||||
m_Camera = Camera.main;
|
||||
m_OriginalCameraPosition = m_Camera.transform.localPosition;
|
||||
m_FovKick.Setup(m_Camera);
|
||||
m_HeadBob.Setup(m_Camera, m_StepInterval);
|
||||
m_StepCycle = 0f;
|
||||
m_NextStep = m_StepCycle / 2f;
|
||||
m_Jumping = false;
|
||||
m_AudioSource = GetComponent<AudioSource>();
|
||||
m_MouseLook.Init(transform, m_Camera.transform);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!frezzeRotation && !rotateMouseInFixedUpdate)
|
||||
{
|
||||
RotateView();
|
||||
}
|
||||
|
||||
if (!m_Jump)
|
||||
{
|
||||
m_Jump = isJumping;
|
||||
}
|
||||
|
||||
if (!m_PreviouslyGrounded && m_CharacterController.isGrounded)
|
||||
{
|
||||
StartCoroutine(m_JumpBob.DoBobCycle());
|
||||
PlayLandingSound();
|
||||
m_MoveDir.y = 0f;
|
||||
m_Jumping = false;
|
||||
}
|
||||
|
||||
if (!m_CharacterController.isGrounded && !m_Jumping && m_PreviouslyGrounded)
|
||||
{
|
||||
m_MoveDir.y = 0f;
|
||||
}
|
||||
|
||||
m_PreviouslyGrounded = m_CharacterController.isGrounded;
|
||||
}
|
||||
|
||||
private void PlayLandingSound()
|
||||
{
|
||||
m_AudioSource.clip = m_LandSound;
|
||||
m_AudioSource.Play();
|
||||
m_NextStep = m_StepCycle + 0.5f;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (!frezzeRotation && rotateMouseInFixedUpdate)
|
||||
{
|
||||
RotateView();
|
||||
}
|
||||
|
||||
if (frezzePosition)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GetInput(out var speed);
|
||||
|
||||
Vector3 vector = transform.forward * m_Input.y + transform.right * m_Input.x;
|
||||
Physics.SphereCast(transform.position, m_CharacterController.radius, Vector3.down, out var hitInfo,
|
||||
m_CharacterController.height / 2f, -1, QueryTriggerInteraction.Ignore);
|
||||
vector = Vector3.ProjectOnPlane(vector, hitInfo.normal).normalized;
|
||||
m_MoveDir.x = vector.x * speed;
|
||||
m_MoveDir.z = vector.z * speed;
|
||||
if (m_CharacterController.isGrounded)
|
||||
{
|
||||
m_MoveDir.y = 0f - m_StickToGroundForce;
|
||||
if (m_Jump && !isWater)
|
||||
{
|
||||
if ((bool)transform.parent && transform.parent.gameObject.layer == LayerMask.NameToLayer("Boat"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_MoveDir.y = m_JumpSpeed;
|
||||
PlayJumpSound();
|
||||
m_Jump = false;
|
||||
m_Jumping = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MoveDir += Physics.gravity * m_GravityMultiplier * Time.fixedDeltaTime;
|
||||
}
|
||||
|
||||
if (!notMove)
|
||||
{
|
||||
m_CollisionFlags = m_CharacterController.Move(m_MoveDir * Time.fixedDeltaTime);
|
||||
}
|
||||
|
||||
ProgressStepCycle(speed);
|
||||
UpdateCameraPosition(speed);
|
||||
m_MouseLook.UpdateCursorLock();
|
||||
}
|
||||
|
||||
private void PlayJumpSound()
|
||||
{
|
||||
m_AudioSource.clip = m_JumpSound;
|
||||
m_AudioSource.Play();
|
||||
}
|
||||
|
||||
private void ProgressStepCycle(float speed)
|
||||
{
|
||||
if (m_CharacterController.velocity.sqrMagnitude > 0f && (m_Input.x != 0f || m_Input.y != 0f))
|
||||
{
|
||||
m_StepCycle +=
|
||||
(m_CharacterController.velocity.magnitude + speed * (m_IsWalking ? 1f : m_RunstepLenghten)) *
|
||||
Time.fixedDeltaTime;
|
||||
}
|
||||
|
||||
if (m_StepCycle > m_NextStep)
|
||||
{
|
||||
m_NextStep = m_StepCycle + m_StepInterval;
|
||||
PlayFootStepAudio();
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayFootStepAudio()
|
||||
{
|
||||
if (!m_CharacterController.isGrounded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (groundTypeTag == "Bridge" || groundTypeTag == "Boat")
|
||||
{
|
||||
if (m_FootstepSoundsBridge.Length != 0)
|
||||
{
|
||||
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")
|
||||
{
|
||||
if (m_FootstepSoundsStone.Length != 0)
|
||||
{
|
||||
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 if (m_FootstepSounds.Length != 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateCameraPosition(float speed)
|
||||
{
|
||||
if (m_UseHeadBob)
|
||||
{
|
||||
Vector3 localPosition;
|
||||
if (m_CharacterController.velocity.magnitude > 0f && m_CharacterController.isGrounded)
|
||||
{
|
||||
m_Camera.transform.localPosition = m_HeadBob.DoHeadBob(m_CharacterController.velocity.magnitude +
|
||||
speed *
|
||||
(m_IsWalking ? 1f : m_RunstepLenghten));
|
||||
localPosition = m_Camera.transform.localPosition;
|
||||
localPosition.y = m_Camera.transform.localPosition.y - m_JumpBob.Offset();
|
||||
}
|
||||
else
|
||||
{
|
||||
localPosition = m_Camera.transform.localPosition;
|
||||
localPosition.y = m_OriginalCameraPosition.y - m_JumpBob.Offset();
|
||||
}
|
||||
|
||||
m_Camera.transform.localPosition = localPosition;
|
||||
}
|
||||
}
|
||||
|
||||
private void GetInput(out float speed)
|
||||
{
|
||||
bool isWalking = m_IsWalking;
|
||||
m_IsWalking = !isRuning;
|
||||
speed = (m_IsWalking ? m_WalkSpeed : m_RunSpeed);
|
||||
m_Input = new Vector2(horizontal, vertical);
|
||||
if (m_Input.sqrMagnitude > 1f)
|
||||
{
|
||||
m_Input.Normalize();
|
||||
}
|
||||
|
||||
if (m_IsWalking != isWalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0f)
|
||||
{
|
||||
StopAllCoroutines();
|
||||
StartCoroutine((!m_IsWalking) ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
|
||||
}
|
||||
}
|
||||
|
||||
public void RotateView()
|
||||
{
|
||||
m_MouseLook.LookRotation(transform, m_Camera.transform);
|
||||
}
|
||||
|
||||
private void OnControllerColliderHit(ControllerColliderHit hit)
|
||||
{
|
||||
Rigidbody attachedRigidbody = hit.collider.attachedRigidbody;
|
||||
groundTypeTag = hit.collider.tag;
|
||||
|
||||
if (m_CollisionFlags != CollisionFlags.Below && !(attachedRigidbody == null))
|
||||
{
|
||||
_ = attachedRigidbody.isKinematic;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerStay(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Water"))
|
||||
{
|
||||
isWater = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Water"))
|
||||
{
|
||||
isWater = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/ThirdParty/FirstPersonController/FirstPersonController.cs.meta
vendored
Normal file
3
Assets/Scripts/ThirdParty/FirstPersonController/FirstPersonController.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f1324aa5e564035ab9a361499a66c27
|
||||
timeCreated: 1748446121
|
||||
133
Assets/Scripts/ThirdParty/FirstPersonController/MouseLook.cs
vendored
Normal file
133
Assets/Scripts/ThirdParty/FirstPersonController/MouseLook.cs
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public class MouseLook
|
||||
{
|
||||
public float XSensitivity = 2f;
|
||||
|
||||
public float YSensitivity = 2f;
|
||||
|
||||
public bool clampVerticalRotation = true;
|
||||
|
||||
public float MinimumX = -90f;
|
||||
|
||||
public float MaximumX = 90f;
|
||||
|
||||
public bool smooth;
|
||||
|
||||
public float smoothTime = 5f;
|
||||
|
||||
public bool lockCursor = true;
|
||||
|
||||
public float RotYvalue;
|
||||
|
||||
public bool invertMouseY;
|
||||
|
||||
public bool invertMouseX;
|
||||
|
||||
public int ControllerHandMode;
|
||||
|
||||
private Quaternion m_CharacterTargetRot;
|
||||
|
||||
private Quaternion m_CameraTargetRot;
|
||||
|
||||
private bool m_cursorIsLocked = true;
|
||||
|
||||
// private Player player;
|
||||
|
||||
public void Init(Transform character, Transform camera)
|
||||
{
|
||||
m_CharacterTargetRot = character.localRotation;
|
||||
m_CameraTargetRot = camera.localRotation;
|
||||
// player = ReInput.players.GetPlayer(0);
|
||||
}
|
||||
|
||||
public void LookRotation(Transform character, Transform camera)
|
||||
{
|
||||
// if (!SRDebug.Instance.IsDebugPanelVisible && !SRDebug.Instance.IsDebugPanelVisible)
|
||||
{
|
||||
// var lookInput = InputManager.GetLookInput();
|
||||
var lookInput = Vector2.zero;
|
||||
|
||||
float num = Mathf.Clamp(lookInput.y * YSensitivity * 5f * Time.deltaTime, -10f, 10f);
|
||||
float num2 =
|
||||
Mathf.Clamp(lookInput.x * XSensitivity * 5f * Time.deltaTime, -10f, 10f);
|
||||
|
||||
if (invertMouseY)
|
||||
{
|
||||
num *= -1f;
|
||||
}
|
||||
|
||||
if (invertMouseX)
|
||||
{
|
||||
num2 *= -1f;
|
||||
}
|
||||
|
||||
RotYvalue = num2;
|
||||
m_CharacterTargetRot *= Quaternion.Euler(0f, num2, 0f);
|
||||
m_CameraTargetRot *= Quaternion.Euler(0f - num, 0f, 0f);
|
||||
if (clampVerticalRotation)
|
||||
{
|
||||
m_CameraTargetRot = ClampRotationAroundXAxis(m_CameraTargetRot);
|
||||
}
|
||||
|
||||
if (smooth)
|
||||
{
|
||||
character.localRotation = Quaternion.Slerp(character.localRotation, m_CharacterTargetRot,
|
||||
smoothTime * Time.deltaTime);
|
||||
camera.localRotation = Quaternion.Slerp(camera.localRotation, m_CameraTargetRot,
|
||||
smoothTime * Time.deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
character.localRotation = m_CharacterTargetRot;
|
||||
camera.localRotation = m_CameraTargetRot;
|
||||
}
|
||||
|
||||
UpdateCursorLock();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCursorLock(bool value)
|
||||
{
|
||||
lockCursor = value;
|
||||
if (!lockCursor)
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
Cursor.visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
Cursor.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateCursorLock()
|
||||
{
|
||||
if (lockCursor)
|
||||
{
|
||||
InternalLockUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
private void InternalLockUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
private Quaternion ClampRotationAroundXAxis(Quaternion q)
|
||||
{
|
||||
q.x /= q.w;
|
||||
q.y /= q.w;
|
||||
q.z /= q.w;
|
||||
q.w = 1f;
|
||||
float value = 114.59156f * Mathf.Atan(q.x);
|
||||
value = Mathf.Clamp(value, MinimumX, MaximumX);
|
||||
q.x = Mathf.Tan((float)Math.PI / 360f * value);
|
||||
return q;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/ThirdParty/FirstPersonController/MouseLook.cs.meta
vendored
Normal file
3
Assets/Scripts/ThirdParty/FirstPersonController/MouseLook.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d0cbae98ed8408e90ca0cb0e05b6d1d
|
||||
timeCreated: 1748446245
|
||||
3
Assets/Scripts/ThirdParty/FirstPersonController/Utility.meta
vendored
Normal file
3
Assets/Scripts/ThirdParty/FirstPersonController/Utility.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d919912beb546df866a283a379c7e96
|
||||
timeCreated: 1748446174
|
||||
54
Assets/Scripts/ThirdParty/FirstPersonController/Utility/CurveControlledBob.cs
vendored
Normal file
54
Assets/Scripts/ThirdParty/FirstPersonController/Utility/CurveControlledBob.cs
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public class CurveControlledBob
|
||||
{
|
||||
public float HorizontalBobRange = 0.33f;
|
||||
|
||||
public float VerticalBobRange = 0.33f;
|
||||
|
||||
public AnimationCurve Bobcurve = new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(0.5f, 1f),
|
||||
new Keyframe(1f, 0f), new Keyframe(1.5f, -1f), new Keyframe(2f, 0f));
|
||||
|
||||
public float VerticaltoHorizontalRatio = 1f;
|
||||
|
||||
private float m_CyclePositionX;
|
||||
|
||||
private float m_CyclePositionY;
|
||||
|
||||
private float m_BobBaseInterval;
|
||||
|
||||
private Vector3 m_OriginalCameraPosition;
|
||||
|
||||
private float m_Time;
|
||||
|
||||
public void Setup(Camera camera, float bobBaseInterval)
|
||||
{
|
||||
m_BobBaseInterval = bobBaseInterval;
|
||||
m_OriginalCameraPosition = camera.transform.localPosition;
|
||||
m_Time = Bobcurve[Bobcurve.length - 1].time;
|
||||
}
|
||||
|
||||
public Vector3 DoHeadBob(float speed)
|
||||
{
|
||||
float x = m_OriginalCameraPosition.x + Bobcurve.Evaluate(m_CyclePositionX) * HorizontalBobRange;
|
||||
float y = m_OriginalCameraPosition.y + Bobcurve.Evaluate(m_CyclePositionY) * VerticalBobRange;
|
||||
m_CyclePositionX += speed * Time.deltaTime / m_BobBaseInterval;
|
||||
m_CyclePositionY += speed * Time.deltaTime / m_BobBaseInterval * VerticaltoHorizontalRatio;
|
||||
if (m_CyclePositionX > m_Time)
|
||||
{
|
||||
m_CyclePositionX -= m_Time;
|
||||
}
|
||||
|
||||
if (m_CyclePositionY > m_Time)
|
||||
{
|
||||
m_CyclePositionY -= m_Time;
|
||||
}
|
||||
|
||||
return new Vector3(x, y, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/ThirdParty/FirstPersonController/Utility/CurveControlledBob.cs.meta
vendored
Normal file
3
Assets/Scripts/ThirdParty/FirstPersonController/Utility/CurveControlledBob.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 491f525f09d84899a13bf70f08f7a713
|
||||
timeCreated: 1748446274
|
||||
72
Assets/Scripts/ThirdParty/FirstPersonController/Utility/FOVKick.cs
vendored
Normal file
72
Assets/Scripts/ThirdParty/FirstPersonController/Utility/FOVKick.cs
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public class FOVKick
|
||||
{
|
||||
public Camera Camera;
|
||||
|
||||
[HideInInspector] public float originalFov;
|
||||
|
||||
public float FOVIncrease = 3f;
|
||||
|
||||
public float TimeToIncrease = 1f;
|
||||
|
||||
public float TimeToDecrease = 1f;
|
||||
|
||||
public AnimationCurve IncreaseCurve;
|
||||
|
||||
public void Setup(Camera camera)
|
||||
{
|
||||
CheckStatus(camera);
|
||||
Camera = camera;
|
||||
originalFov = camera.fieldOfView;
|
||||
}
|
||||
|
||||
private void CheckStatus(Camera camera)
|
||||
{
|
||||
if (camera == null)
|
||||
{
|
||||
throw new Exception("FOVKick camera is null, please supply the camera to the constructor");
|
||||
}
|
||||
|
||||
if (IncreaseCurve == null)
|
||||
{
|
||||
throw new Exception(
|
||||
"FOVKick Increase curve is null, please define the curve for the field of view kicks");
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeCamera(Camera camera)
|
||||
{
|
||||
Camera = camera;
|
||||
}
|
||||
|
||||
public IEnumerator FOVKickUp()
|
||||
{
|
||||
float t = Mathf.Abs((Camera.fieldOfView - originalFov) / FOVIncrease);
|
||||
while (t < TimeToIncrease)
|
||||
{
|
||||
Camera.fieldOfView = originalFov + IncreaseCurve.Evaluate(t / TimeToIncrease) * FOVIncrease;
|
||||
t += Time.deltaTime;
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator FOVKickDown()
|
||||
{
|
||||
float t = Mathf.Abs((Camera.fieldOfView - originalFov) / FOVIncrease);
|
||||
while (t > 0f)
|
||||
{
|
||||
Camera.fieldOfView = originalFov + IncreaseCurve.Evaluate(t / TimeToDecrease) * FOVIncrease;
|
||||
t -= Time.deltaTime;
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
|
||||
Camera.fieldOfView = originalFov;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/ThirdParty/FirstPersonController/Utility/FOVKick.cs.meta
vendored
Normal file
3
Assets/Scripts/ThirdParty/FirstPersonController/Utility/FOVKick.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb6289c553a943a98adf26c14b1eaf2b
|
||||
timeCreated: 1748446181
|
||||
40
Assets/Scripts/ThirdParty/FirstPersonController/Utility/LerpControlledBob.cs
vendored
Normal file
40
Assets/Scripts/ThirdParty/FirstPersonController/Utility/LerpControlledBob.cs
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
[Serializable]
|
||||
public class LerpControlledBob
|
||||
{
|
||||
public float BobDuration;
|
||||
|
||||
public float BobAmount;
|
||||
|
||||
private float m_Offset;
|
||||
|
||||
public float Offset()
|
||||
{
|
||||
return m_Offset;
|
||||
}
|
||||
|
||||
public IEnumerator DoBobCycle()
|
||||
{
|
||||
float t2 = 0f;
|
||||
while (t2 < BobDuration)
|
||||
{
|
||||
m_Offset = Mathf.Lerp(0f, BobAmount, t2 / BobDuration);
|
||||
t2 += Time.deltaTime;
|
||||
yield return new WaitForFixedUpdate();
|
||||
}
|
||||
t2 = 0f;
|
||||
while (t2 < BobDuration)
|
||||
{
|
||||
m_Offset = Mathf.Lerp(BobAmount, 0f, t2 / BobDuration);
|
||||
t2 += Time.deltaTime;
|
||||
yield return new WaitForFixedUpdate();
|
||||
}
|
||||
m_Offset = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/ThirdParty/FirstPersonController/Utility/LerpControlledBob.cs.meta
vendored
Normal file
3
Assets/Scripts/ThirdParty/FirstPersonController/Utility/LerpControlledBob.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ff17b813690432a9da59c9ab3ceccbb
|
||||
timeCreated: 1748446293
|
||||
8
Assets/Scripts/ThirdParty/Rope.meta
vendored
Normal file
8
Assets/Scripts/ThirdParty/Rope.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77bf606826b396b4892cee2a10698bdc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/ThirdParty/Rope/Examples.meta
vendored
Normal file
8
Assets/Scripts/ThirdParty/Rope/Examples.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 274ad94c8d1c74add9a9cc85a946ad59
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/ThirdParty/Rope/Examples/00_Main.meta
vendored
Normal file
8
Assets/Scripts/ThirdParty/Rope/Examples/00_Main.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 386748bc44dcf2c4cb5f81bbd7a1dbbe
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
6723
Assets/Scripts/ThirdParty/Rope/Examples/00_Main/Main.unity
vendored
Normal file
6723
Assets/Scripts/ThirdParty/Rope/Examples/00_Main/Main.unity
vendored
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Scripts/ThirdParty/Rope/Examples/00_Main/Main.unity.meta
vendored
Normal file
7
Assets/Scripts/ThirdParty/Rope/Examples/00_Main/Main.unity.meta
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c7f7f1f33c7e2e41a67b885755052ee
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/ThirdParty/Steamworks.NET.meta
vendored
Normal file
8
Assets/Scripts/ThirdParty/Steamworks.NET.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62ddefd95a62cbc4ea1a2aabc009a378
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
182
Assets/Scripts/ThirdParty/Steamworks.NET/SteamManager.cs
vendored
Normal file
182
Assets/Scripts/ThirdParty/Steamworks.NET/SteamManager.cs
vendored
Normal file
@@ -0,0 +1,182 @@
|
||||
// The SteamManager is designed to work with Steamworks.NET
|
||||
// This file is released into the public domain.
|
||||
// Where that dedication is not recognized you are granted a perpetual,
|
||||
// irrevocable license to copy and modify this file as you see fit.
|
||||
//
|
||||
// Version: 1.0.13
|
||||
|
||||
#if !(UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_STANDALONE_OSX || STEAMWORKS_WIN || STEAMWORKS_LIN_OSX)
|
||||
#define DISABLESTEAMWORKS
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
#if !DISABLESTEAMWORKS
|
||||
using System.Collections;
|
||||
using Steamworks;
|
||||
#endif
|
||||
|
||||
//
|
||||
// The SteamManager provides a base implementation of Steamworks.NET on which you can build upon.
|
||||
// It handles the basics of starting up and shutting down the SteamAPI for use.
|
||||
//
|
||||
[DisallowMultipleComponent]
|
||||
public class SteamManager : MonoBehaviour {
|
||||
#if !DISABLESTEAMWORKS
|
||||
protected static bool s_EverInitialized = false;
|
||||
|
||||
protected static SteamManager s_instance;
|
||||
protected static SteamManager Instance {
|
||||
get {
|
||||
if (s_instance == null) {
|
||||
return new GameObject("SteamManager").AddComponent<SteamManager>();
|
||||
}
|
||||
else {
|
||||
return s_instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected bool m_bInitialized = false;
|
||||
public static bool Initialized {
|
||||
get {
|
||||
return Instance.m_bInitialized;
|
||||
}
|
||||
}
|
||||
|
||||
protected SteamAPIWarningMessageHook_t m_SteamAPIWarningMessageHook;
|
||||
|
||||
[AOT.MonoPInvokeCallback(typeof(SteamAPIWarningMessageHook_t))]
|
||||
protected static void SteamAPIDebugTextHook(int nSeverity, System.Text.StringBuilder pchDebugText) {
|
||||
Debug.LogWarning(pchDebugText);
|
||||
}
|
||||
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
// In case of disabled Domain Reload, reset static members before entering Play Mode.
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
private static void InitOnPlayMode()
|
||||
{
|
||||
s_EverInitialized = false;
|
||||
s_instance = null;
|
||||
}
|
||||
#endif
|
||||
|
||||
protected virtual void Awake() {
|
||||
// Only one instance of SteamManager at a time!
|
||||
if (s_instance != null) {
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
s_instance = this;
|
||||
|
||||
if(s_EverInitialized) {
|
||||
// This is almost always an error.
|
||||
// The most common case where this happens is when SteamManager gets destroyed because of Application.Quit(),
|
||||
// and then some Steamworks code in some other OnDestroy gets called afterwards, creating a new SteamManager.
|
||||
// You should never call Steamworks functions in OnDestroy, always prefer OnDisable if possible.
|
||||
throw new System.Exception("Tried to Initialize the SteamAPI twice in one session!");
|
||||
}
|
||||
|
||||
// We want our SteamManager Instance to persist across scenes.
|
||||
DontDestroyOnLoad(gameObject);
|
||||
|
||||
if (!Packsize.Test()) {
|
||||
Debug.LogError("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform.", this);
|
||||
}
|
||||
|
||||
if (!DllCheck.Test()) {
|
||||
Debug.LogError("[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version.", this);
|
||||
}
|
||||
|
||||
try {
|
||||
// If Steam is not running or the game wasn't started through Steam, SteamAPI_RestartAppIfNecessary starts the
|
||||
// Steam client and also launches this game again if the User owns it. This can act as a rudimentary form of DRM.
|
||||
// Note that this will run which ever version you have installed in steam. Which may not be the precise executable
|
||||
// we were currently running.
|
||||
|
||||
// Once you get a Steam AppID assigned by Valve, you need to replace AppId_t.Invalid with it and
|
||||
// remove steam_appid.txt from the game depot. eg: "(AppId_t)480" or "new AppId_t(480)".
|
||||
// See the Valve documentation for more information: https://partner.steamgames.com/doc/sdk/api#initialization_and_shutdown
|
||||
if (SteamAPI.RestartAppIfNecessary(AppId_t.Invalid)) {
|
||||
Debug.Log("[Steamworks.NET] Shutting down because RestartAppIfNecessary returned true. Steam will restart the application.");
|
||||
|
||||
Application.Quit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (System.DllNotFoundException e) { // We catch this exception here, as it will be the first occurrence of it.
|
||||
Debug.LogError("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib. It's likely not in the correct location. Refer to the README for more details.\n" + e, this);
|
||||
|
||||
Application.Quit();
|
||||
return;
|
||||
}
|
||||
|
||||
// Initializes the Steamworks API.
|
||||
// If this returns false then this indicates one of the following conditions:
|
||||
// [*] The Steam client isn't running. A running Steam client is required to provide implementations of the various Steamworks interfaces.
|
||||
// [*] The Steam client couldn't determine the App ID of game. If you're running your application from the executable or debugger directly then you must have a [code-inline]steam_appid.txt[/code-inline] in your game directory next to the executable, with your app ID in it and nothing else. Steam will look for this file in the current working directory. If you are running your executable from a different directory you may need to relocate the [code-inline]steam_appid.txt[/code-inline] file.
|
||||
// [*] Your application is not running under the same OS user context as the Steam client, such as a different user or administration access level.
|
||||
// [*] Ensure that you own a license for the App ID on the currently active Steam account. Your game must show up in your Steam library.
|
||||
// [*] Your App ID is not completely set up, i.e. in Release State: Unavailable, or it's missing default packages.
|
||||
// Valve's documentation for this is located here:
|
||||
// https://partner.steamgames.com/doc/sdk/api#initialization_and_shutdown
|
||||
m_bInitialized = SteamAPI.Init();
|
||||
if (!m_bInitialized) {
|
||||
Debug.LogError("[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.", this);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
s_EverInitialized = true;
|
||||
}
|
||||
|
||||
// This should only ever get called on first load and after an Assembly reload, You should never Disable the Steamworks Manager yourself.
|
||||
protected virtual void OnEnable() {
|
||||
if (s_instance == null) {
|
||||
s_instance = this;
|
||||
}
|
||||
|
||||
if (!m_bInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_SteamAPIWarningMessageHook == null) {
|
||||
// Set up our callback to receive warning messages from Steam.
|
||||
// You must launch with "-debug_steamapi" in the launch args to receive warnings.
|
||||
m_SteamAPIWarningMessageHook = new SteamAPIWarningMessageHook_t(SteamAPIDebugTextHook);
|
||||
SteamClient.SetWarningMessageHook(m_SteamAPIWarningMessageHook);
|
||||
}
|
||||
}
|
||||
|
||||
// OnApplicationQuit gets called too early to shutdown the SteamAPI.
|
||||
// Because the SteamManager should be persistent and never disabled or destroyed we can shutdown the SteamAPI here.
|
||||
// Thus it is not recommended to perform any Steamworks work in other OnDestroy functions as the order of execution can not be garenteed upon Shutdown. Prefer OnDisable().
|
||||
protected virtual void OnDestroy() {
|
||||
if (s_instance != this) {
|
||||
return;
|
||||
}
|
||||
|
||||
s_instance = null;
|
||||
|
||||
if (!m_bInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
SteamAPI.Shutdown();
|
||||
}
|
||||
|
||||
protected virtual void Update() {
|
||||
if (!m_bInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Run Steam client callbacks
|
||||
SteamAPI.RunCallbacks();
|
||||
}
|
||||
#else
|
||||
public static bool Initialized {
|
||||
get {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif // !DISABLESTEAMWORKS
|
||||
}
|
||||
8
Assets/Scripts/ThirdParty/Steamworks.NET/SteamManager.cs.meta
vendored
Normal file
8
Assets/Scripts/ThirdParty/Steamworks.NET/SteamManager.cs.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef4bffeda13d7a748973ff9204401c07
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
Reference in New Issue
Block a user