123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- using System;
- using UnityEngine;
- internal class WfCameraMoveSupport : MonoBehaviour
- {
- public CameraMain camera
- {
- get
- {
- return GameMain.Instance.MainCamera;
- }
- }
- public Vector3 targetPosition
- {
- get
- {
- return this.camera.GetTargetPos();
- }
- set
- {
- this.camera.SetTargetPos(value, true);
- }
- }
- public float distance
- {
- get
- {
- return this.camera.GetDistance();
- }
- set
- {
- this.camera.SetDistance(value, true);
- }
- }
- public Vector2 aroundAngle
- {
- get
- {
- return this.camera.GetAroundAngle();
- }
- set
- {
- this.camera.SetAroundAngle(value, true);
- }
- }
- public Vector3 savePosition { get; private set; }
- public float saveDistance { get; private set; }
- public Vector2 saveAngle { get; private set; }
- public void SaveCameraPosition()
- {
- this.savePosition = GameMain.Instance.MainCamera.GetTargetPos();
- this.saveDistance = GameMain.Instance.MainCamera.GetDistance();
- this.saveAngle = GameMain.Instance.MainCamera.GetAroundAngle();
- }
- public void SaveCameraPosition(Vector3 targetPosition, float distance, Vector2 aroundAngle)
- {
- this.savePosition = targetPosition;
- this.saveDistance = distance;
- this.saveAngle = aroundAngle;
- }
- public void StartCameraPosition(Vector3 position, float distance, Vector2 aroundAngle)
- {
- Vector2 aroundAngle2 = GameMain.Instance.MainCamera.GetAroundAngle();
- Vector2 vector = new Vector2(this.RoundDegree(aroundAngle2.x), this.RoundDegree(aroundAngle2.y));
- aroundAngle = new Vector2(this.RoundDegree(aroundAngle.x), this.RoundDegree(aroundAngle.y));
- if (Mathf.Abs(aroundAngle.y - 360f - vector.y) < Mathf.Abs(aroundAngle.y - vector.y))
- {
- aroundAngle.y -= 360f;
- }
- else if (Mathf.Abs(aroundAngle.y + 360f - vector.y) < Mathf.Abs(aroundAngle.y - vector.y))
- {
- aroundAngle.y += 360f;
- }
- iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
- {
- "easetype",
- iTween.EaseType.easeOutCubic,
- "from",
- this.targetPosition,
- "to",
- position,
- "time",
- this.moveTime,
- "onupdate",
- "UpdateCameraTargetPosition"
- }));
- iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
- {
- "easetype",
- iTween.EaseType.easeOutCubic,
- "from",
- this.distance,
- "to",
- distance,
- "time",
- this.moveTime,
- "onUpdate",
- "UpdateCameraDistance"
- }));
- iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
- {
- "easetype",
- iTween.EaseType.easeOutCubic,
- "from",
- vector,
- "to",
- aroundAngle,
- "time",
- this.moveTime,
- "onUpdate",
- "UpdateCameraAngle"
- }));
- }
- public void ResetCamera()
- {
- this.StartCameraPosition(this.savePosition, this.saveDistance, this.saveAngle);
- }
- private void UpdateCameraTargetPosition(Vector3 targetPos)
- {
- this.targetPosition = targetPos;
- }
- private void UpdateCameraDistance(float distance)
- {
- this.distance = distance;
- }
- private void UpdateCameraAngle(Vector2 angle)
- {
- this.aroundAngle = angle;
- }
- private float RoundDegree(float degres)
- {
- if (0f > degres || degres > 360f)
- {
- degres -= Mathf.Floor(degres / 360f) * 360f;
- return (!Mathf.Approximately(360f, degres)) ? degres : 0f;
- }
- return Mathf.Abs(degres);
- }
- public float moveTime = 0.5f;
- }
|