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.
121 lines
3.9 KiB
121 lines
3.9 KiB
3 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using AX.TrackRecord;
|
||
|
using AX.MessageSystem;
|
||
|
/// <summary>
|
||
|
/// 物体微调
|
||
|
/// </summary>
|
||
|
public class FineTuningControl : MonoBehaviour
|
||
|
{
|
||
|
float TIMESTAMP = 1.0f;
|
||
|
float timer = 0f;
|
||
|
float THRESHOLD = 0.2f;
|
||
|
float lastFrame_y;
|
||
|
float currentFrame_y;
|
||
|
|
||
|
void Start()
|
||
|
{
|
||
|
timer = TIMESTAMP;
|
||
|
lastFrame_y = transform.localEulerAngles.y;
|
||
|
MessageDispatcher.AddListener("A", A);
|
||
|
MessageDispatcher.AddListener("D", D);
|
||
|
}
|
||
|
private void ProcessRecordFineTuning()
|
||
|
{
|
||
|
if (RecordManager.Instance.IsRecording)
|
||
|
{
|
||
|
if (ExamInfoHelpClass.applicationMode == ExamInfoHelpClass.ApplicationMode.PATHFINDING)
|
||
|
{
|
||
|
if (GetComponent<UnityEngine.AI.NavMeshAgent>())
|
||
|
{
|
||
|
if (GetComponent<UnityEngine.AI.NavMeshAgent>().velocity.magnitude > 0)
|
||
|
{
|
||
|
lastFrame_y = transform.localEulerAngles.y;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
public bool DonotRecordFlag = false;
|
||
|
void Update() {
|
||
|
ProcessRecordFineTuning();
|
||
|
|
||
|
if (timer > 0)
|
||
|
{
|
||
|
timer -= Time.deltaTime;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
currentFrame_y = transform.localEulerAngles.y;
|
||
|
if (Mathf.Abs(currentFrame_y - lastFrame_y) > THRESHOLD)
|
||
|
{
|
||
|
if (RecordManager.Instance.IsRecording)
|
||
|
{
|
||
|
//if (ExamInfoHelpClass.applicationMode== ExamInfoHelpClass.ApplicationMode.PATHFINDING &&
|
||
|
// GetComponent<NavMeshAgent>().velocity.magnitude > 0)//寻路过程中不记录旋转
|
||
|
//{
|
||
|
// lastFrame_y = currentFrame_y;
|
||
|
// timer = TIMESTAMP;
|
||
|
// return;
|
||
|
//}
|
||
|
if (!DonotRecordFlag)
|
||
|
{
|
||
|
MessageDispatcher.SendMessage("RecordFineTuningEvent", (object)this.name);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
lastFrame_y = currentFrame_y;
|
||
|
timer = TIMESTAMP;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
lastFrame_y = currentFrame_y;
|
||
|
timer = TIMESTAMP;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
void A(IMessage message)
|
||
|
{
|
||
|
if ((string)message.Data == this.gameObject.name)
|
||
|
{
|
||
|
if (gameObject.GetComponent<LineamentEvent>().ControlJuBi )
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
if ((gameObject.name.Contains("shangyuan") || gameObject.name.Contains("zhiqingren")
|
||
|
|| gameObject.name.Contains("weixianpin") || gameObject.name.Contains("zwd"))
|
||
|
&& ExamInfoHelpClass.loadSceneMode== ExamInfoHelpClass.LoadSceneMode.ExamineMode)
|
||
|
{
|
||
|
//考核模式下灾情不能控制
|
||
|
return;
|
||
|
}
|
||
|
this.gameObject.transform.Rotate(0, -25 * Time.deltaTime, 0, Space.World);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void D(IMessage message)
|
||
|
{
|
||
|
if ((string)message.Data == this.gameObject.name)
|
||
|
{
|
||
|
if (gameObject.GetComponent<LineamentEvent>().ControlJuBi )
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
if ((gameObject.name.Contains("shangyuan") || gameObject.name.Contains("zhiqingren")
|
||
|
|| gameObject.name.Contains("weixianpin") || gameObject.name.Contains("zwd"))
|
||
|
&& ExamInfoHelpClass.loadSceneMode == ExamInfoHelpClass.LoadSceneMode.ExamineMode)
|
||
|
{
|
||
|
//考核模式下灾情不能控制
|
||
|
return;
|
||
|
}
|
||
|
this.gameObject.transform.Rotate(0, 25 * Time.deltaTime, 0, Space.World);
|
||
|
}
|
||
|
}
|
||
|
void OnDestroy()
|
||
|
{
|
||
|
MessageDispatcher.RemoveListener("A", A);
|
||
|
MessageDispatcher.RemoveListener("D", D);
|
||
|
}
|
||
|
}
|