上海杨浦大连路地铁站单机版电子沙盘
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.
 
 
 
 

84 lines
2.8 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AX.MessageSystem;
using AX.InputSystem;
[RequireComponent(typeof(CameraManager))]
public class CameraHorizontalTransaction : 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("CAMERA_DRAG_ENTER_COMMAND", CameraDragEnterExecute);
MessageDispatcher.AddListener("CAMERA_DRAGING_COMMAND", CameraDragingExecute);
MessageDispatcher.AddListener("CAMERA_DRAG_EXIT_COMMAND", CameraDragExitExecute);
}
void OnDisable()
{
MessageDispatcher.RemoveListener("CAMERA_DRAG_ENTER_COMMAND", CameraDragEnterExecute);
MessageDispatcher.RemoveListener("CAMERA_DRAGING_COMMAND", CameraDragingExecute);
MessageDispatcher.RemoveListener("CAMERA_DRAG_EXIT_COMMAND", CameraDragExitExecute);
}
void OnDestroy()
{
MessageDispatcher.RemoveListener("CAMERA_DRAG_ENTER_COMMAND", CameraDragEnterExecute);
MessageDispatcher.RemoveListener("CAMERA_DRAGING_COMMAND", CameraDragingExecute);
MessageDispatcher.RemoveListener("CAMERA_DRAG_EXIT_COMMAND", CameraDragExitExecute);
}
private void CameraDragEnterExecute(IMessage obj)
{
var data = (CameraCmdArgs)obj.Data;
cameraManager.UpdateDragEnterData(data.mousePosition, data.dragStart);
timeStart = RecordManager.Instance.RecordTimer;
}
private void CameraDragingExecute(IMessage obj)
{
var data = (CameraCmdArgs)obj.Data;
cameraManager.UpdateDragingData(data.mousePosition, data.dragStart);
}
private void CameraDragExitExecute(IMessage obj)
{
var data = (CameraCmdArgs)obj.Data;
cameraManager.UpdateDragExitData(data.mousePosition, data.dragStart);
timeEnd = RecordManager.Instance.RecordTimer;
if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal)
{
cameraManager.AddRecordCamera(timeStart, timeEnd - timeStart);
timeStart = 0;
timeEnd = 0;
}
}
}