141 lines
3.6 KiB
C#
141 lines
3.6 KiB
C#
using DG.Tweening;
|
||
using SK.Framework;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using TMPro;
|
||
using UnityEngine;
|
||
|
||
public class GuanDaoXunBeiPage : UIPageBtnEventBase
|
||
{
|
||
public CustomTMPInputField 北斗坐标_X;
|
||
public CustomTMPInputField 北斗坐标_Y;
|
||
public CustomTMPInputField 北斗坐标_H;
|
||
public List<GameObject> seclects = new List<GameObject>();
|
||
public GameObject choosePage;
|
||
public TextMeshProUGUI 惯导寻北读秒Text;
|
||
public TextMeshProUGUI 北向角Text;
|
||
public TextMeshProUGUI 纵倾角Text;
|
||
public TextMeshProUGUI 横向角Text;
|
||
|
||
public CustomTMPInputField 校正坐标_X;
|
||
public CustomTMPInputField 校正坐标_Y;
|
||
public CustomTMPInputField 校正坐标_H;
|
||
|
||
public GameObject 北斗设置;
|
||
public GameObject 使用阵地;
|
||
GameObject currectObj;
|
||
|
||
private void OnEnable()
|
||
{
|
||
StartGuanDao();
|
||
currectObj = null;
|
||
}
|
||
public override void OnF2Click()
|
||
{
|
||
base.OnF2Click();
|
||
|
||
}
|
||
|
||
public override void OnF3Click()
|
||
{
|
||
base.OnF3Click();
|
||
北斗设置.SetActive(true);
|
||
currectObj = 北斗设置;
|
||
}
|
||
|
||
public override void OnF5Click()
|
||
{
|
||
base.OnF5Click();
|
||
使用阵地.SetActive(true);
|
||
currectObj = 使用阵地;
|
||
}
|
||
|
||
|
||
|
||
|
||
public override void OnESCClick()
|
||
{
|
||
base.OnESCClick();
|
||
|
||
if (currectObj != null)
|
||
{
|
||
currectObj.SetActive(false);
|
||
currectObj = null;
|
||
return;
|
||
}
|
||
ManagerPaoZhangBase.instance.paozhangMain.SetActive(true);
|
||
Destroy(gameObject);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// F2开始惯导
|
||
/// </summary>
|
||
void StartGuanDao()
|
||
{
|
||
this.Sequence()
|
||
.Events(() => {
|
||
|
||
//等待北斗,目前不知道如何等待
|
||
})
|
||
.Until(()=>true)
|
||
.Until(()=>Input.GetKeyDown(KeyCode.F4)) //按f4使用北斗
|
||
.Events(() => {
|
||
|
||
//视频显示三个坐标归零
|
||
校正坐标_X.text = "0";
|
||
校正坐标_Y.text = "0";
|
||
校正坐标_H.text = "0";
|
||
ShowSelectItem(0);
|
||
})
|
||
.Until(() => Input.GetKeyDown(KeyCode.F1)) //F1校正坐标
|
||
.Events(() => {
|
||
//惯导开始接收,校正坐标
|
||
ShowSelectItem(10);
|
||
})
|
||
.Until(() => Input.GetKeyDown(KeyCode.F2)) //F2开始惯导寻北
|
||
.Events(() => {
|
||
|
||
choosePage.SetActive(true);
|
||
})
|
||
.Until(()=>!choosePage.activeInHierarchy) //等待界面关闭
|
||
.Events(() => {
|
||
//开始读秒,N个时间以后显示坐标
|
||
AnimateNumber(惯导寻北读秒Text, 0, 288, 15);
|
||
})
|
||
.Delay(15f)
|
||
.Events(() => {
|
||
//结束后显示结果
|
||
北向角Text.gameObject.SetActive(true);
|
||
纵倾角Text.gameObject.SetActive(true);
|
||
横向角Text.gameObject.SetActive(true);
|
||
//北斗结束
|
||
})
|
||
.Begin();
|
||
}
|
||
|
||
void ShowSelectItem(int index)
|
||
{
|
||
foreach (GameObject go in seclects) {
|
||
|
||
go.SetActive(false);
|
||
}
|
||
if (index > seclects.Count || seclects[index] == null)
|
||
return;
|
||
seclects[index].SetActive(true);
|
||
}
|
||
|
||
void AnimateNumber(TextMeshProUGUI targetText, int from, int to, float duration)
|
||
{
|
||
// 使用 DOTween 的 float 动画
|
||
float current = from;
|
||
DOTween.To(() => current, x =>
|
||
{
|
||
current = x;
|
||
targetText.text = Mathf.RoundToInt(current).ToString("000"); // 保持三位数
|
||
}, to, duration)
|
||
.SetEase(Ease.Linear);
|
||
}
|
||
|
||
}
|