148 lines
4.4 KiB
C#
148 lines
4.4 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using DG.Tweening;
|
|
using System.Collections;
|
|
using Yarn.Unity;
|
|
|
|
namespace AibisDream.FixSystem
|
|
{
|
|
public class OscilloscopeSystem : MonoBehaviour
|
|
{
|
|
#region 旧的组件索引
|
|
|
|
private TMP_Text _state; // 显示状态的TextMeshPro组件
|
|
private TMP_Text _screenText; // 显示消息的TextMeshPro组件
|
|
private SpriteButton _deepinButton;
|
|
|
|
#endregion
|
|
|
|
private void Awake()
|
|
{
|
|
FixSystemCenter.SystemDic.Register(this);
|
|
InitComponentRefs();
|
|
}
|
|
|
|
private void InitComponentRefs()
|
|
{
|
|
_screenText = transform.Find("Screen Text").GetComponent<TMP_Text>();
|
|
_state = transform.Find("Screen State Text").GetComponent<TMP_Text>();
|
|
_deepinButton = new SpriteButton(transform.Find("Deepin Button").gameObject, false);
|
|
MessageBoxSetNull();
|
|
|
|
_deepinButton.OnButtonDown += HandleDeepInButtonClick;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
_deepinButton.CheckButtonClick();
|
|
}
|
|
|
|
#region 旧显示屏接口
|
|
|
|
public void MessageBoxSetError()
|
|
{
|
|
_state.text = "错误";
|
|
_state.color = Color.red; // 红色
|
|
}
|
|
|
|
private void HandleDeepInButtonClick()
|
|
{
|
|
FixSystemCenter.SystemDic.Get<BodyModuleSystem>().HandleDeepIn();
|
|
}
|
|
|
|
public void MessageBoxSetWarning()
|
|
{
|
|
_state.text = "警告";
|
|
_state.color = new Color(1.0f, 0.55f, 0.0f); // 琥珀色
|
|
}
|
|
|
|
public void MessageBoxSetNormal()
|
|
{
|
|
_state.text = "正常";
|
|
_state.color = Color.blue; // 琥珀色
|
|
}
|
|
|
|
public void MessageBoxSetChecking()
|
|
{
|
|
_state.text = "检查中";
|
|
_state.color = Color.white; // 琥珀色
|
|
}
|
|
|
|
public void MessageBoxSetText(string text)
|
|
{
|
|
_screenText.color = Color.white; // 默认文本颜色
|
|
_screenText.text += text + "<br>";
|
|
}
|
|
|
|
public void MessageBoxSetNull()
|
|
{
|
|
_state.text = "未检测到信号";
|
|
_state.color = Color.white; // 蓝色
|
|
_screenText.text = "";
|
|
_screenText.color = Color.white; // 默认文本颜色
|
|
}
|
|
|
|
public IEnumerator EnableDeepInButton()
|
|
{
|
|
yield return _deepinButton.GetTransform().DOLocalMoveX(0.35f, 0.5f).WaitForCompletion();
|
|
_deepinButton.SetActive(true);
|
|
}
|
|
|
|
public IEnumerator DisableDeepInButton()
|
|
{
|
|
yield return _deepinButton.GetTransform().DOLocalMoveX(-0.2f, 0.5f).WaitForCompletion();
|
|
_deepinButton.SetActive(false);
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
/// <summary>
|
|
/// 示波器接口。暂时能想到的就是这几个对外接口
|
|
/// 用示波器显示对话的部分额外实现IDialogView接口。这部分方案定下来之后老丁来实现。
|
|
/// </summary>
|
|
public interface IOscilloscopeSystem
|
|
{
|
|
/// <summary>
|
|
/// 展示示波器上的图片和检测点位
|
|
/// </summary>
|
|
/// /// <param name="moduleImage">显示在示波器里的图片</param>
|
|
/// <param name="checkPoints">检查点信息</param>
|
|
public IEnumerator ShowScanImage(Sprite moduleImage, CheckPoint[] checkPoints);
|
|
|
|
/// <summary>
|
|
/// 聚焦到某个点上
|
|
/// </summary>
|
|
/// <param name="checkPointId">检查点</param>
|
|
public IEnumerator FocusOnPoint(string checkPointId);
|
|
|
|
/// <summary>
|
|
/// 停止聚焦
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public IEnumerator StopFocus();
|
|
|
|
/// <summary>
|
|
/// 隐藏显示屏上的图像
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public IEnumerator HideScanImage();
|
|
}
|
|
|
|
public static class OscilloscopeYarnCommand
|
|
{
|
|
private static IOscilloscopeSystem OscilloscopeSystem => FixSystemCenter.SystemDic.Get<IOscilloscopeSystem>();
|
|
|
|
[YarnCommand("focus_on_point")]
|
|
public static IEnumerator FocusOnPoint(string checkPointId)
|
|
{
|
|
return OscilloscopeSystem?.FocusOnPoint(checkPointId);
|
|
}
|
|
|
|
[YarnCommand("stop_focus")]
|
|
public static IEnumerator StopFocus()
|
|
{
|
|
return OscilloscopeSystem?.StopFocus();
|
|
}
|
|
}
|
|
} |