Merge remote-tracking branch 'origin/12月版本优化' into feature/merge

This commit is contained in:
2024-12-26 14:38:34 +08:00
48 changed files with 12250 additions and 1284 deletions
@@ -11,9 +11,16 @@ namespace AibisDream.FixSystem
private const string SocketObjName = "Socket";
private const string ModulePicName = "Module Pic";
private const string IndicatorName = "Indicator";
public Transform _socketPos;
// public Transform _indicatorPos;
private BodyModuleSystem _bodyModuleSystem;
private Material highlightMaterial;
private Material alarmMaterial;
private Material originalMaterial; // 原材质
private SpriteRenderer targetSpriteRenderer; // 目标的 SpriteRenderer
#endregion
// 模块基本数据
@@ -25,15 +32,18 @@ namespace AibisDream.FixSystem
// 获取组件索引
InitReference();
}
private void InitReference()
{
_socketPos = transform.Find(SocketObjName);
_bodyModuleSystem = transform.parent.parent.GetComponent<BodyModuleSystem>();
targetSpriteRenderer=transform.Find("Module Pic").GetComponent<SpriteRenderer>();
originalMaterial = targetSpriteRenderer.GetComponent<SpriteRenderer>().material;
highlightMaterial = Resources.Load<Material>("Materials/HighlightMaterial");
alarmMaterial=Resources.Load<Material>("Materials/AlarmMaterial");
}
#region
public bool IsAvailable()
{
return available;
@@ -42,11 +52,10 @@ namespace AibisDream.FixSystem
{
available=isAvailable;
}
public void PlugIn()
{
// 插入后先播放wave
ShowWave();
//ShowWave();
if(DialogController.Instance!=null)
// 然后触发Yarn节点
DialogController.Instance.StartDialogNode(_bodyModuleSystem.inHotErr ? "系统过热" : data.PlugInNodeName);
@@ -54,16 +63,18 @@ namespace AibisDream.FixSystem
public void PlugOut()
{
_bodyModuleSystem.oscilloscopeSystem.MessageBoxSetNull();
StartCoroutine(_bodyModuleSystem.oscilloscopeSystem.DisableDeepInButton());
// 先关闭wave
_bodyModuleSystem.oscilloscopeSystem.ShowScreenMessage("未插入任何模块", Color.white);
CloseWave();
//_bodyModuleSystem.oscilloscopeSystem.ShowScreenMessage("未插入任何模块", Color.white);
//CloseWave();
// TODO 触发Yarn节点(似乎目前没有拔出对话?)
}
public void DeepIn()
{
if (!data.waveHasError&&!data.ignoreWaveCheck) return;
// 如果有错误并且已经深入了
// if (!data.waveHasError&&!data.ignoreWaveCheck) return;
// // 如果有错误并且已经深入了
if(DialogController.Instance!=null)
DialogController.Instance.StartDialogNode(data.DeepInNodeName);
}
@@ -130,6 +141,7 @@ namespace AibisDream.FixSystem
{
var modulePic = transform.Find(ModulePicName).GetComponent<SpriteRenderer>();
var socketPos = transform.Find(SocketObjName);
//var indicatorPos = transform.Find(IndicatorName);
return new BodyModuleData
{
@@ -140,13 +152,40 @@ namespace AibisDream.FixSystem
waveformType = data.waveformType,
waveHasError = data.waveHasError,
ignoreWaveCheck = data.ignoreWaveCheck,
cantStopRunning=data.cantStopRunning
cantStopRunning=data.cantStopRunning,
//IndicatorPos=indicatorPos.localPosition
//indicatorPos= indicatorPos.position
};
}
#endregion
}
#region
public void Highlight(bool enable)
{
if (targetSpriteRenderer != null && highlightMaterial != null&&targetSpriteRenderer.material!=alarmMaterial)
{
targetSpriteRenderer.material = enable ? highlightMaterial : originalMaterial;
}
}
public void Alarm(bool enable)
{
if (targetSpriteRenderer != null && alarmMaterial != null)
{
targetSpriteRenderer.material = enable ? alarmMaterial : originalMaterial;
}
}
// public void HideModule(bool enable)
// {
// if (targetSpriteRenderer != null && highlightMaterial != null)
// {
// targetSpriteRenderer.material = enable ? highlightMaterial : originalMaterial;
// }
// }
#endregion
}
[Serializable]
public struct BodyModuleData
{
@@ -161,6 +200,8 @@ namespace AibisDream.FixSystem
public SerializableVector3 modulePos;
public SerializableVector3 socketPos;
public SerializableVector3 indicatorPos;
// 功能信息
public WaveformType waveformType;
@@ -194,5 +235,11 @@ namespace AibisDream.FixSystem
get => socketPos.ToVector3();
set => socketPos = new SerializableVector3(value);
}
// [JsonIgnore]
// public Vector3 IndicatorPos
// {
// get => indicatorPos.ToVector3();
// set => indicatorPos = new SerializableVector3(value);
// }
}
}
@@ -7,8 +7,9 @@ namespace AibisDream
public static class BodyModuleYarnCommand
{
private static BodyModuleSystem BodyModuleSystem => FixSystemCenter.SystemDic.Get<BodyModuleSystem>();
private static OscilloscopeSystem OscilloscopeSystem => FixSystemCenter.SystemDic.Get<OscilloscopeSystem>();
private static PunchTapeSystem PunchTapeSystem => FixSystemCenter.SystemDic.Get<PunchTapeSystem>();
[YarnCommand("SetModuleState_CantStopRunning")]
public static void SetModuleState_CantStopRunning(string ModuleName,bool state)
{
@@ -68,7 +69,7 @@ namespace AibisDream
[YarnCommand("Temp_InstallChip")]
public static void Temp_InstallChip()
{
var _UFCover = BodyModuleSystem.FindBodyModuleByName("Color").transform.Find("Module Pic").gameObject;
var _UFCover = BodyModuleSystem.FindBodyModuleByName("Color").transform.Find("Chip").gameObject;
if(!_UFCover.activeInHierarchy)
{
_UFCover.SetActive(true);
@@ -77,7 +78,7 @@ namespace AibisDream
[YarnCommand("Temp_RemoveChip")]
public static void Temp_RemoveChip()
{
var _UFCover = BodyModuleSystem.FindBodyModuleByName("Color").transform.Find("Module Pic").gameObject;
var _UFCover = BodyModuleSystem.FindBodyModuleByName("Color").transform.Find("Chip").gameObject;
if(_UFCover.activeInHierarchy)
{
_UFCover.SetActive(false);
@@ -89,5 +90,62 @@ namespace AibisDream
var targetModule = BodyModuleSystem.FindBodyModuleByName(moduleName);
targetModule.SetSocketAvailable(isAvailable);
}
[YarnCommand("ModuleHightLight")]
public static void ModuleHightLight(string moduleName,bool enable)
{
var targetModule = BodyModuleSystem.FindBodyModuleByName(moduleName);
targetModule.Highlight(enable);
}
[YarnCommand("ModuleAlarm")]
public static void ModuleAlarm(string moduleName,bool enable)
{
var targetModule = BodyModuleSystem.FindBodyModuleByName(moduleName);
targetModule.Alarm(enable);
}
[YarnCommand("MessageBoxSetError")]
public static void MessageBoxSetError()
{
OscilloscopeSystem.MessageBoxSetError();
}
[YarnCommand("MessageBoxSetWarning")]
public static void MessageBoxSetWarning()
{
OscilloscopeSystem.MessageBoxSetWarning();
}
[YarnCommand("MessageBoxSetNormal")]
public static void MessageBoxSetNormal()
{
OscilloscopeSystem.MessageBoxSetNormal();
}
[YarnCommand("MessageBoxSetChecking")]
public static void MessageBoxSetChecking()
{
OscilloscopeSystem.MessageBoxSetChecking();
}
[YarnCommand("MessageBoxSetNull")]
public static void MessageBoxSetNull()
{
OscilloscopeSystem.MessageBoxSetNull();
}
[YarnCommand("MessageBoxSetText")]
public static void MessageBoxSetText(string text)
{
OscilloscopeSystem.MessageBoxSetText(text);
}
[YarnCommand("EnableDeepInButton")]
public static void EnableDeepInButton()
{
OscilloscopeSystem.StartCoroutine(OscilloscopeSystem.EnableDeepInButton());
}
[YarnCommand("DisableDeepInButton")]
public static void DisableDeepInButton()
{
OscilloscopeSystem.StartCoroutine(OscilloscopeSystem.DisableDeepInButton());
}
[YarnCommand("PrintPunchTapes")]
public static IEnumerator PrintPunchTapes(int count)
{
yield return PunchTapeSystem.StartCoroutine(PunchTapeSystem.PrintPunchTapes(count));
}
}
}
@@ -1,7 +1,10 @@
using AibisDream.Utility;
using TMPro;
using UnityEngine;
using DG.Tweening;
using Febucci.UI;
using Random = UnityEngine.Random;
using System.Collections;
namespace AibisDream.FixSystem
{
@@ -10,8 +13,8 @@ namespace AibisDream.FixSystem
#region
private BodyModuleSystem _bodyModuleSystem;
private TMP_Text _screenText;
public TMP_Text state; // 显示状态的TextMeshPro组件
private TMP_Text _screenText;// 显示消息的TextMeshPro组件
private WaveformLine _waveformLine;
private ScanLine _scanLine;
private SpriteRenderer _screen;
@@ -44,10 +47,10 @@ namespace AibisDream.FixSystem
_screen = transform.Find("Screen").GetComponent<SpriteRenderer>();
_waveSlider = transform.Find("Wave Slider").GetComponent<WaveSlider>();
_deepinButton = new SpriteButton(transform.Find("Deepin Button").gameObject, false);
_waveformLine.SetLineSize(_screen.bounds.size.x, _screen.bounds.size.y);
_scanLine.SetScreenSize(_screen.bounds.size.x, _screen.bounds.size.y);
_screenText.text = "";
//_screenText.text = "";
MessageBoxSetNull();
_deepinButton.OnButtonDown += HandleDeepInButtonClick;
_scanLine.ScanErrorEvent += OnScanSuccess;
@@ -119,14 +122,15 @@ namespace AibisDream.FixSystem
}
public void HandleDeepInButtonClick()
{
if(_bodyModuleSystem.CableSystem.curBodyModule.data.ignoreWaveCheck==true)
{
_bodyModuleSystem.HandleDeepIn();
}
else
{
StartScan();
}
// if(_bodyModuleSystem.CableSystem.curBodyModule.data.ignoreWaveCheck==true)
// {
// _bodyModuleSystem.HandleDeepIn();
// }
// else
// {
// StartScan();
// }
_bodyModuleSystem.HandleDeepIn();
}
@@ -159,8 +163,62 @@ namespace AibisDream.FixSystem
}
#endregion
}
public void MessageBoxSetError()
{
state.text = "错误";
state.color = Color.red; // 红色
// _screenText.text = message;
// _screenText.color = Color.white; // 默认文本颜色
}
public void MessageBoxSetWarning()
{
state.text = "警告";
state.color = new Color(1.0f, 0.55f, 0.0f); // 琥珀色
// _screenText.text = message;
// _screenText.color = Color.white; // 默认文本颜色
}
public void MessageBoxSetNormal()
{
state.text = "正常";
state.color = Color.blue; // 琥珀色
// _screenText.text = message;
// _screenText.color = Color.white; // 默认文本颜色
}
public void MessageBoxSetChecking()
{
state.text = "检查中";
state.color = Color.white; // 琥珀色
// _screenText.text = string.Empty;
// _screenText.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 = string.Empty;
_screenText.color = Color.white; // 默认文本颜色
}
public IEnumerator EnableDeepInButton()
{
yield return _deepinButton.GetTransform().DOLocalMoveX(0.5f, 0.5f).WaitForCompletion();
_deepinButton.SetActive(true);
}
public IEnumerator DisableDeepInButton()
{
yield return _deepinButton.GetTransform().DOLocalMoveX(-0.1f, 0.5f).WaitForCompletion();
_deepinButton.SetActive(false);
}
}
public enum WaveformType
{
Default,
@@ -0,0 +1,76 @@
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using AibisDream.FixSystem;
using UnityEngine.UI;
public class PunchTapeSystem : MonoBehaviour
{
public RectTransform punchTapeMachine;
public RectTransform punchTape;
public float stepInterval = 0.1f; // Interval between each printing step
public float stepDistance = 0.5f; // Distance moved per step
public float[] stepPatterns = { 0.3f, 0.5f, 0.2f, 0.4f, 0.6f }; // Pattern of intervals to simulate rhythmic printing
private void Awake()
{
FixSystemCenter.SystemDic.Register(this);
}
public void Update()
{
if (Input.GetKeyDown(KeyCode.P))
{
StartPrinting(2);
}
}
public void StartPrinting(int tapeCount)
{
StartCoroutine(PrintPunchTapes(tapeCount));
}
public IEnumerator PrintPunchTapes(int tapeCount)
{
Vector3 machineStartPos = punchTapeMachine.anchoredPosition;
Vector3 tapeStartPos = punchTape.anchoredPosition;
Color tapeStartColor = punchTape.GetComponent<Image>().color;
while (tapeCount > 0)
{
// Move the printer to x = 2 over 1 second
yield return punchTapeMachine.DOAnchorPos(new Vector2(-1252f, punchTapeMachine.anchoredPosition.y), 1f).WaitForCompletion();
// Gradually move the punch tape to x = -3.8 with rhythmic pattern
Vector2 targetPosition = new Vector2(796f, punchTape.anchoredPosition.y);
int patternIndex = 0;
while (Vector2.Distance(punchTape.anchoredPosition, targetPosition) > stepDistance)
{
punchTape.anchoredPosition = Vector3.MoveTowards(punchTape.anchoredPosition, targetPosition, stepDistance);
yield return new WaitForSeconds(stepPatterns[patternIndex % stepPatterns.Length]);
patternIndex++;
}
// Ensure exact final position
punchTape.anchoredPosition = targetPosition;
// Fade out the punch tape over 1 second
yield return punchTape.GetComponent<Image>().DOFade(0f, 1f).WaitForCompletion();
// Reset the punch tape position and opacity
punchTape.anchoredPosition = tapeStartPos;
punchTape.GetComponent<Image>().color = tapeStartColor;
// Decrement the tape count
tapeCount--;
}
// Move the printer back to x = 0 over 1 second
yield return punchTapeMachine.DOAnchorPos(new Vector2(-1428.186f, punchTapeMachine.anchoredPosition.y), 1f).WaitForCompletion();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4075ea95a82355544862690e0de983bd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: