131 lines
4.9 KiB
C#
131 lines
4.9 KiB
C#
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Invector
|
|
{
|
|
public enum TPCameraMode
|
|
{
|
|
FreeDirectional,
|
|
FixedAngle,
|
|
FixedPoint,
|
|
FirstPerson
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class vThirdPersonCameraState
|
|
{
|
|
public string Name;
|
|
public float forward;
|
|
public float right;
|
|
public float defaultDistance;
|
|
public float maxDistance;
|
|
public float minDistance;
|
|
public float height;
|
|
public float smooth = 10f;
|
|
public float smoothDamp = 0f;
|
|
public float xMouseSensitivity;
|
|
public float yMouseSensitivity;
|
|
public float yMinLimit;
|
|
public float yMaxLimit;
|
|
public float xMinLimit;
|
|
public float xMaxLimit;
|
|
|
|
public Vector3 rotationOffSet;
|
|
public float cullingHeight;
|
|
public float cullingMinDist;
|
|
public float fov;
|
|
public bool useZoom;
|
|
public Vector2 fixedAngle;
|
|
public List<LookPoint> lookPoints;
|
|
public TPCameraMode cameraMode;
|
|
|
|
public vThirdPersonCameraState(string name)
|
|
{
|
|
Name = name;
|
|
forward = -1f;
|
|
right = 0f;
|
|
defaultDistance = 1.5f;
|
|
maxDistance = 3f;
|
|
minDistance = 0.5f;
|
|
height = 0f;
|
|
smooth = 10f;
|
|
smoothDamp = 0f;
|
|
xMouseSensitivity = 3f;
|
|
yMouseSensitivity = 3f;
|
|
yMinLimit = -40f;
|
|
yMaxLimit = 80f;
|
|
xMinLimit = -360f;
|
|
xMaxLimit = 360f;
|
|
cullingHeight = 0.2f;
|
|
cullingMinDist = 0.1f;
|
|
fov = 60f;
|
|
useZoom = false;
|
|
forward = 60;
|
|
fixedAngle = Vector2.zero;
|
|
cameraMode = TPCameraMode.FreeDirectional;
|
|
}
|
|
|
|
public void CopyState(vThirdPersonCameraState state)
|
|
{
|
|
this.Name = state.Name;
|
|
this.forward = state.forward;
|
|
this.right = state.right;
|
|
this.defaultDistance = state.defaultDistance;
|
|
this.maxDistance = state.maxDistance;
|
|
this.minDistance = state.minDistance;
|
|
this.height = state.height;
|
|
this.smooth = state.smooth;
|
|
this.smoothDamp = state.smoothDamp;
|
|
this.xMouseSensitivity = state.xMouseSensitivity;
|
|
this.yMouseSensitivity = state.yMouseSensitivity;
|
|
this.yMinLimit = state.yMinLimit;
|
|
this.yMaxLimit = state.yMaxLimit;
|
|
this.xMinLimit = state.xMinLimit;
|
|
this.xMaxLimit = state.xMaxLimit;
|
|
this.rotationOffSet = state.rotationOffSet;
|
|
this.cullingHeight = state.cullingHeight;
|
|
this.cullingMinDist = state.cullingMinDist;
|
|
this.fov = state.fov;
|
|
this.useZoom = state.useZoom;
|
|
this.fixedAngle = state.fixedAngle;
|
|
this.lookPoints = state.lookPoints;
|
|
this.cameraMode = state.cameraMode;
|
|
}
|
|
|
|
public void Slerp(vThirdPersonCameraState state, float t)
|
|
{
|
|
this.Name = state.Name;
|
|
this.forward = Mathf.Lerp(this.forward, state.forward, t);
|
|
this.right = Mathf.Lerp(this.right, state.right, t);
|
|
this.defaultDistance = Mathf.Lerp(this.defaultDistance, state.defaultDistance, t);
|
|
this.maxDistance = Mathf.Lerp(this.maxDistance, state.maxDistance, t);
|
|
this.minDistance = Mathf.Lerp(this.minDistance, state.minDistance, t);
|
|
this.height = Mathf.Lerp(this.height, state.height, t);
|
|
this.smooth = Mathf.Lerp(this.smooth, state.smooth, t);
|
|
this.smoothDamp = Mathf.Lerp(this.smoothDamp, state.smoothDamp, t);
|
|
this.xMouseSensitivity = Mathf.Lerp(this.xMouseSensitivity, state.xMouseSensitivity, t);
|
|
this.yMouseSensitivity = Mathf.Lerp(this.yMouseSensitivity, state.yMouseSensitivity, t);
|
|
this.yMinLimit = Mathf.Lerp(this.yMinLimit, state.yMinLimit, t);
|
|
this.yMaxLimit = Mathf.Lerp(this.yMaxLimit, state.yMaxLimit, t);
|
|
this.xMinLimit = Mathf.Lerp(this.xMinLimit, state.xMinLimit, t);
|
|
this.xMaxLimit = Mathf.Lerp(this.xMaxLimit, state.xMaxLimit, t);
|
|
this.rotationOffSet = Vector3.Lerp(this.rotationOffSet, state.rotationOffSet, t);
|
|
this.cullingHeight = Mathf.Lerp(this.cullingHeight, state.cullingHeight, t);
|
|
this.cullingMinDist = Mathf.Lerp(this.cullingMinDist, state.cullingMinDist, t);
|
|
this.fov = Mathf.Lerp(this.fov, state.fov, t);
|
|
this.useZoom = state.useZoom;
|
|
this.fixedAngle = Vector2.Lerp(this.fixedAngle, state.fixedAngle, t);
|
|
this.lookPoints = state.lookPoints;
|
|
this.cameraMode = state.cameraMode;
|
|
}
|
|
}
|
|
|
|
[System.Serializable]
|
|
public class LookPoint
|
|
{
|
|
public string pointName;
|
|
public Vector3 positionPoint;
|
|
public Vector3 eulerAngle;
|
|
public bool freeRotation;
|
|
}
|
|
} |