using UnityEngine; using System.Collections; using AX.TrackRecord; using AX.MessageSystem; /// /// 物体微调 /// 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()) { if (GetComponent().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().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().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().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); } }