You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.7 KiB
87 lines
2.7 KiB
4 years ago
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using AX.MessageSystem;
|
||
|
using System;
|
||
|
using AX.InputSystem;
|
||
|
|
||
|
[RequireComponent(typeof(CameraManager))]
|
||
|
public class CameraRotation : MonoBehaviour
|
||
|
{
|
||
|
private float timeStart;
|
||
|
private float timeEnd;
|
||
|
private CameraManager cameraManager;
|
||
|
// Use this for initialization
|
||
|
void Start()
|
||
|
{
|
||
|
cameraManager = GetComponent<CameraManager>();
|
||
|
MessageDispatcher.AddListener("RecordStatusPause", changed);
|
||
|
}
|
||
|
|
||
|
private void changed(IMessage obj)
|
||
|
{
|
||
|
if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.pause)
|
||
|
{
|
||
|
if (timeStart != 0 && timeEnd == 0)
|
||
|
{
|
||
|
timeEnd = RecordManager.Instance.RecordTimer;
|
||
|
cameraManager.AddRecordCamera(timeStart, timeEnd - timeStart);
|
||
|
timeStart = 0;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
void OnEnable()
|
||
|
{
|
||
|
MessageDispatcher.AddListener("ROTATE_ENTER_COMMAND", RotateEnterExecute);
|
||
|
MessageDispatcher.AddListener("ROTATING_COMMAND", RotatingExecute);
|
||
|
MessageDispatcher.AddListener("ROTATE_EXIT_COMMAND", RotateExitExecute);
|
||
|
}
|
||
|
|
||
|
void OnDisable()
|
||
|
{
|
||
|
MessageDispatcher.RemoveListener("ROTATE_ENTER_COMMAND", RotateEnterExecute);
|
||
|
MessageDispatcher.RemoveListener("ROTATING_COMMAND", RotatingExecute);
|
||
|
MessageDispatcher.RemoveListener("ROTATE_EXIT_COMMAND", RotateExitExecute);
|
||
|
}
|
||
|
|
||
|
void OnDestroy()
|
||
|
{
|
||
|
MessageDispatcher.RemoveListener("ROTATE_ENTER_COMMAND", RotateEnterExecute);
|
||
|
MessageDispatcher.RemoveListener("ROTATING_COMMAND", RotatingExecute);
|
||
|
MessageDispatcher.RemoveListener("ROTATE_EXIT_COMMAND", RotateExitExecute);
|
||
|
}
|
||
|
|
||
|
private void RotateEnterExecute(IMessage obj)
|
||
|
{
|
||
|
var data = (CameraCmdArgs)obj.Data;
|
||
|
cameraManager.UpdateCameraRotationData(data);
|
||
|
timeStart = RecordManager.Instance.RecordTimer;
|
||
|
}
|
||
|
|
||
|
private void RotatingExecute(IMessage obj)
|
||
|
{
|
||
|
var data = (CameraCmdArgs)obj.Data;
|
||
|
cameraManager.UpdateCameraRotationData(data);
|
||
|
}
|
||
|
|
||
|
private void RotateExitExecute(IMessage obj)
|
||
|
{
|
||
|
var data = (CameraCmdArgs)obj.Data;
|
||
|
cameraManager.UpdateCameraRotationData(data);
|
||
|
timeEnd = RecordManager.Instance.RecordTimer;
|
||
|
if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal)
|
||
|
{
|
||
|
cameraManager.AddRecordCamera(timeStart, timeEnd - timeStart);
|
||
|
timeStart = 0;
|
||
|
timeEnd = 0;
|
||
|
}
|
||
|
}
|
||
|
}
|