96 lines
2.4 KiB
C#
96 lines
2.4 KiB
C#
using BitStrap;
|
|
using UnityEngine;
|
|
|
|
public class MyFreeCamera : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private float speed = 1f;
|
|
|
|
[SerializeField]
|
|
private float shiftSpeed = 3f;
|
|
|
|
[SerializeField]
|
|
private float ctrlSpeed = 0.3f;
|
|
|
|
[SerializeField]
|
|
private float mouseSensitivity = 2f;
|
|
|
|
private Camera localCamera;
|
|
|
|
public bool needMouseBtn = true;
|
|
|
|
public bool fakeboatCamera;
|
|
|
|
[ReadOnly]
|
|
public Transform target;
|
|
|
|
private void Awake()
|
|
{
|
|
localCamera = GetComponent<Camera>();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
float num = speed;
|
|
if (Input.GetKey(KeyCode.LeftShift))
|
|
{
|
|
num = shiftSpeed;
|
|
}
|
|
else if (Input.GetKey(KeyCode.LeftControl))
|
|
{
|
|
num = ctrlSpeed;
|
|
}
|
|
if (!fakeboatCamera)
|
|
{
|
|
if (Input.GetKey(KeyCode.W))
|
|
{
|
|
base.transform.position += base.transform.forward * num * Time.deltaTime;
|
|
}
|
|
if (Input.GetKey(KeyCode.S))
|
|
{
|
|
base.transform.position -= base.transform.forward * num * Time.deltaTime;
|
|
}
|
|
if (Input.GetKey(KeyCode.A))
|
|
{
|
|
base.transform.position -= base.transform.right * num * Time.deltaTime;
|
|
}
|
|
if (Input.GetKey(KeyCode.D))
|
|
{
|
|
base.transform.position += base.transform.right * num * Time.deltaTime;
|
|
}
|
|
if (Input.GetKey(KeyCode.Q))
|
|
{
|
|
base.transform.position -= base.transform.up * num * Time.deltaTime;
|
|
}
|
|
if (Input.GetKey(KeyCode.E))
|
|
{
|
|
base.transform.position += base.transform.up * num * Time.deltaTime;
|
|
}
|
|
}
|
|
if ((!GameController.Instance || !Cursor.visible) && (Input.GetMouseButton(1) || !needMouseBtn))
|
|
{
|
|
base.transform.localEulerAngles += new Vector3((0f - Input.GetAxisRaw("Mouse Y")) * mouseSensitivity, 0f, 0f);
|
|
base.transform.localEulerAngles += new Vector3(0f, Input.GetAxisRaw("Mouse X") * mouseSensitivity, 0f);
|
|
}
|
|
}
|
|
|
|
public void AttachToTarget(Transform newTarget)
|
|
{
|
|
if ((bool)newTarget)
|
|
{
|
|
base.transform.parent = newTarget;
|
|
base.transform.localPosition = new Vector3(0f, 1.3f, -0.3f);
|
|
base.transform.localEulerAngles = new Vector3(89f, -90f, 0f);
|
|
needMouseBtn = true;
|
|
GameController.Instance.fishingPlayer.waterCamera.enabled = false;
|
|
GameController.Instance.fishingPlayer.underwaterWaterCamera.enabled = false;
|
|
GameController.Instance.fishingPlayer.depthOfField.enabled = false;
|
|
GameController.Instance.fishingPlayer.ufpsCamera.GetComponent<AmplifyMotionEffect>().enabled = false;
|
|
}
|
|
else
|
|
{
|
|
base.transform.parent = GameController.Instance.fishingPlayer.transform;
|
|
}
|
|
}
|
|
}
|