You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
289 lines
11 KiB
C#
289 lines
11 KiB
C#
|
3 years ago
|
//using System.Collections;
|
||
|
|
//using System.Collections.Generic;
|
||
|
|
//using UnityEngine;
|
||
|
|
//using SiegeSong;
|
||
|
|
|
||
|
|
//namespace SiegeSong
|
||
|
|
//{
|
||
|
|
// public class CameraManager : MonoBehaviour
|
||
|
|
// {
|
||
|
|
// public RuntimeManager RuntimeManager;
|
||
|
|
|
||
|
|
// public Motor Motor;
|
||
|
|
|
||
|
|
// public GameObject ActiveCamera;
|
||
|
|
|
||
|
|
// public bool FirstPersonActive;
|
||
|
|
|
||
|
|
// public Transform CameraTarget;
|
||
|
|
|
||
|
|
// public Transform MenuMount;
|
||
|
|
|
||
|
|
// public Transform ActiveMount;
|
||
|
|
|
||
|
|
// public Transform FirstPersonMount;
|
||
|
|
// public Transform LeftMount;
|
||
|
|
// public Transform RightMount;
|
||
|
|
// public Transform CenterMount;
|
||
|
|
// public List<Transform> AutoMounts;
|
||
|
|
// public List<Transform> StationMounts;
|
||
|
|
|
||
|
|
// public GameObject[] NonPlayerCameras;
|
||
|
|
|
||
|
|
// public float CameraX;
|
||
|
|
// public float CameraY;
|
||
|
|
|
||
|
|
// private int activeCameraIndex;
|
||
|
|
|
||
|
|
// public float speedX = 200.0f;
|
||
|
|
// public float speedY = 100.0f;
|
||
|
|
|
||
|
|
// public float minX = -90.0f;
|
||
|
|
// public float maxX = 90.0f;
|
||
|
|
|
||
|
|
// public float minY = -80.0f;
|
||
|
|
// public float maxY = 90.0f;
|
||
|
|
// private float zoomStep = 0.1f;
|
||
|
|
|
||
|
|
// public float firstPersonMinY = -80.0f;
|
||
|
|
// public float firstPersonMaxY = 90.0f;
|
||
|
|
|
||
|
|
// private float zoomSpeed = 0.1f;
|
||
|
|
// private float zoom = 2.0f;
|
||
|
|
// private float requestedZoom = 2.0f;
|
||
|
|
// private float minZoom = -0.2f;
|
||
|
|
// private float maxZoom = 0.5f;
|
||
|
|
// private bool canZoomToRequested = true;
|
||
|
|
// private bool zooming;
|
||
|
|
// private bool zoomCollision;
|
||
|
|
|
||
|
|
// public bool lerping;
|
||
|
|
// public Vector3 lerpStartPosition;
|
||
|
|
// public Vector3 lerpTargetPosition;
|
||
|
|
// public float lerpStartTime;
|
||
|
|
// public float lerpDistance;
|
||
|
|
// public float lerpSpeed = 3.5f;
|
||
|
|
// public float lerpStopDistanceThreshold = 0.01f;
|
||
|
|
|
||
|
|
|
||
|
|
// private float rotationSpeedBrakeSpeed = 2.0f;
|
||
|
|
// private float rotationSpeedStopThreshold = 0.1f;
|
||
|
|
|
||
|
|
|
||
|
|
// //public CameraMode ActiveMode;
|
||
|
|
|
||
|
|
// void Start()
|
||
|
|
// {
|
||
|
|
// ActiveMount = MenuMount;
|
||
|
|
// }
|
||
|
|
|
||
|
|
// void Update()
|
||
|
|
// {
|
||
|
|
// //ActiveCamera.transform.position = ActiveMount.position;
|
||
|
|
|
||
|
|
// if (Motor != null && Motor.UsingStation)
|
||
|
|
// {
|
||
|
|
// CameraX = Motor.TargetStation.CameraX;
|
||
|
|
// CameraY = Motor.TargetStation.CameraY;
|
||
|
|
// }
|
||
|
|
|
||
|
|
// if (lerping)
|
||
|
|
// {
|
||
|
|
// ActiveCamera.transform.position = Vector3.Lerp(lerpStartPosition, lerpTargetPosition, ((Time.time - lerpStartTime) * lerpSpeed) / lerpDistance);
|
||
|
|
// if (Vector3.Distance(ActiveCamera.transform.position, lerpTargetPosition) < lerpStopDistanceThreshold)
|
||
|
|
// lerping = false;
|
||
|
|
// }
|
||
|
|
// //else if (lerpTargetPosition != null)
|
||
|
|
// //{
|
||
|
|
// // ActiveCamera.transform.position = lerpTargetPosition;
|
||
|
|
// //}
|
||
|
|
|
||
|
|
// //if (!zoomCollision)
|
||
|
|
// //{
|
||
|
|
// // for (var i = 0; i < ActiveCamera.transform.childCount; i++)
|
||
|
|
// // {
|
||
|
|
// // var child = ActiveCamera.transform.GetChild(i);
|
||
|
|
// // if (child.gameObject.CompareTag("MainCamera") && !FirstPersonActive)
|
||
|
|
// // {
|
||
|
|
// // child.position = new Vector3(child.position.x, child.position.y, child.position.z + zoom);
|
||
|
|
// // zoom = 0;
|
||
|
|
// // }
|
||
|
|
// // }
|
||
|
|
// //}
|
||
|
|
// }
|
||
|
|
|
||
|
|
// public void SwitchActiveCamera(Camera targetCamera)
|
||
|
|
// {
|
||
|
|
|
||
|
|
// }
|
||
|
|
|
||
|
|
// public void ZoomIn()
|
||
|
|
// {
|
||
|
|
// if (!FirstPersonActive)
|
||
|
|
// {
|
||
|
|
// if (zoom - zoomStep > minZoom)
|
||
|
|
// {
|
||
|
|
// zoom -= zoomStep;
|
||
|
|
// }
|
||
|
|
// else
|
||
|
|
// {
|
||
|
|
// zoom = minZoom;
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
|
||
|
|
// public void ZoomOut(bool request = true)
|
||
|
|
// {
|
||
|
|
// if (!FirstPersonActive)
|
||
|
|
// {
|
||
|
|
// zoom += zoomStep;
|
||
|
|
// }
|
||
|
|
// if (!FirstPersonActive)
|
||
|
|
// {
|
||
|
|
// if (zoom + zoomStep < maxZoom)
|
||
|
|
// {
|
||
|
|
// zoom += zoomStep;
|
||
|
|
// }
|
||
|
|
// else
|
||
|
|
// {
|
||
|
|
// zoom = maxZoom;
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
|
||
|
|
// public void ResetCameraPosition()
|
||
|
|
// {
|
||
|
|
// //ActiveCamera.transform.position = ActiveMount.transform.position;
|
||
|
|
// }
|
||
|
|
|
||
|
|
// public void RealignCamera(bool rotateBody = false)
|
||
|
|
// {
|
||
|
|
// if (!rotateBody)
|
||
|
|
// {
|
||
|
|
// if (CameraX < rotationSpeedStopThreshold && CameraX > -rotationSpeedStopThreshold)
|
||
|
|
// CameraX = 0;
|
||
|
|
// else
|
||
|
|
// CameraX = CameraX / rotationSpeedBrakeSpeed;
|
||
|
|
// }
|
||
|
|
// else
|
||
|
|
// {
|
||
|
|
// Motor.RotateToDirection(ActiveMount.eulerAngles);
|
||
|
|
// //Motor.RotateToDirection(ActiveCamera.transform.eulerAngles);
|
||
|
|
|
||
|
|
// ActiveMount.RotateAround(CameraTarget.position, Vector3.up, -CameraX);
|
||
|
|
// ActiveCamera.transform.rotation.SetLookRotation(CameraTarget.position);
|
||
|
|
// ActiveCamera.transform.rotation = Quaternion.Euler(-ActiveCamera.transform.rotation.x, ActiveCamera.transform.rotation.y, ActiveCamera.transform.rotation.z);
|
||
|
|
// //ActiveCamera.transform.RotateAround(CameraTarget.position, Vector3.up, -CameraX);
|
||
|
|
|
||
|
|
// CameraX = 0;
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
|
||
|
|
// public void RotateHorizontal(float amount)
|
||
|
|
// {
|
||
|
|
// var degreesToRotate = amount * speedX * Time.deltaTime;
|
||
|
|
// if (degreesToRotate > 0 && !(CameraX + degreesToRotate > maxX)
|
||
|
|
// || (degreesToRotate < 0 && !(CameraX + degreesToRotate < minX)))
|
||
|
|
// {
|
||
|
|
// if (!FirstPersonActive)
|
||
|
|
// ActiveCamera.transform.RotateAround(CameraTarget.position, ActiveCamera.transform.TransformDirection(Vector3.up), amount * speedX * Time.deltaTime);
|
||
|
|
// //else
|
||
|
|
// //{
|
||
|
|
// // ActiveCamera.transform.Rotate(ActiveCamera.transform.TransformDirection(Vector3.up), amount * speedX * Time.deltaTime);
|
||
|
|
// //}
|
||
|
|
// //var currentActiveCameraRotation = ActiveCamera.transform.rotation;
|
||
|
|
// var directionToTarget = ActiveCamera.transform.eulerAngles.DirectionTo(CameraTarget.position);
|
||
|
|
// ActiveCamera.transform.eulerAngles = directionToTarget;
|
||
|
|
// //ActiveCamera.transform.eulerAngles = new Vector3(currentActiveCameraRotation.x, currentActiveCameraRotation.y, 0);
|
||
|
|
// CameraX += degreesToRotate;
|
||
|
|
// }
|
||
|
|
// else
|
||
|
|
// {
|
||
|
|
// if (FirstPersonActive)
|
||
|
|
// {
|
||
|
|
// //Motor.RotateToDirection(ActiveCamera.transform.rotation.eulerAngles);
|
||
|
|
// //RealignCamera();
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
|
||
|
|
// public void RotateVertical(float amount)
|
||
|
|
// {
|
||
|
|
// var degreesToRotate = amount * speedY * Time.deltaTime;
|
||
|
|
// if (degreesToRotate > 0 && !(CameraY + degreesToRotate > (FirstPersonActive ? firstPersonMaxY : maxY))
|
||
|
|
// || (degreesToRotate < 0 && !(CameraY + degreesToRotate < (FirstPersonActive ? firstPersonMinY : minY))))
|
||
|
|
// {
|
||
|
|
// if (!FirstPersonActive)
|
||
|
|
// {
|
||
|
|
// ActiveCamera.transform.RotateAround(CameraTarget.position, ActiveCamera.transform.TransformDirection(Vector3.right), amount * speedY * Time.deltaTime);
|
||
|
|
// //var currentActiveCameraRotation = ActiveCamera.transform.rotation;
|
||
|
|
// var directionToTarget = ActiveCamera.transform.eulerAngles.DirectionTo(CameraTarget.position);
|
||
|
|
// ActiveCamera.transform.eulerAngles = directionToTarget;
|
||
|
|
// //ActiveCamera.transform.eulerAngles = new Vector3(currentActiveCameraRotation.x, currentActiveCameraRotation.y, 0);
|
||
|
|
// }
|
||
|
|
// //else
|
||
|
|
// // ActiveCamera.transform.Rotate(Vector3.right, amount * speedY * Time.deltaTime);
|
||
|
|
// CameraY += degreesToRotate;
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
|
||
|
|
// public void SwitchCamera()
|
||
|
|
// {
|
||
|
|
// CameraX = 0;
|
||
|
|
// CameraY = 0;
|
||
|
|
// if (FirstPersonActive)
|
||
|
|
// {
|
||
|
|
// ActiveCamera.transform.Rotate(-Vector3.right, -CameraY);
|
||
|
|
// FirstPersonActive = false;
|
||
|
|
// }
|
||
|
|
// else
|
||
|
|
// ActiveCamera.transform.RotateAround(CameraTarget.position, ActiveCamera.transform.TransformDirection(-Vector3.right), -CameraY);
|
||
|
|
|
||
|
|
// if (activeCameraIndex - 3 == AutoMounts.Count + StationMounts.Count)
|
||
|
|
// activeCameraIndex = 0;
|
||
|
|
// else
|
||
|
|
// activeCameraIndex++;
|
||
|
|
// lerping = true;
|
||
|
|
// lerpStartTime = Time.time;
|
||
|
|
// lerpStartPosition = ActiveCamera.transform.position;
|
||
|
|
// switch (activeCameraIndex)
|
||
|
|
// {
|
||
|
|
// case 0:
|
||
|
|
// FirstPersonActive = true;
|
||
|
|
// lerpTargetPosition = FirstPersonMount.position;
|
||
|
|
// ActiveMount = FirstPersonMount;
|
||
|
|
// break;
|
||
|
|
// case 1:
|
||
|
|
// lerpTargetPosition = RightMount.position;
|
||
|
|
// ActiveMount = RightMount;
|
||
|
|
// break;
|
||
|
|
// case 2:
|
||
|
|
// lerpTargetPosition = CenterMount.position;
|
||
|
|
// ActiveMount = CenterMount;
|
||
|
|
// break;
|
||
|
|
// case 3:
|
||
|
|
// lerpTargetPosition = LeftMount.position;
|
||
|
|
// ActiveMount = LeftMount;
|
||
|
|
// break;
|
||
|
|
// default:
|
||
|
|
// case 4:
|
||
|
|
// if (activeCameraIndex - 3 > AutoMounts.Count)
|
||
|
|
// {
|
||
|
|
// lerpTargetPosition = StationMounts[activeCameraIndex - 3 - AutoMounts.Count].position;
|
||
|
|
// ActiveMount = StationMounts[activeCameraIndex - 3 - AutoMounts.Count];
|
||
|
|
// }
|
||
|
|
// else
|
||
|
|
// {
|
||
|
|
// lerpTargetPosition = StationMounts[activeCameraIndex - 3].position;
|
||
|
|
// ActiveMount = StationMounts[activeCameraIndex - 3];
|
||
|
|
// }
|
||
|
|
// break;
|
||
|
|
|
||
|
|
// }
|
||
|
|
// lerpDistance = Vector3.Distance(ActiveCamera.transform.position, lerpTargetPosition);
|
||
|
|
// ActiveCamera.transform.SetParent(ActiveMount);
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
//}
|
||
|
|
|