打孔带打印,存储替换完成

This commit is contained in:
2024-12-25 19:46:56 +08:00
parent cc4d3a5a05
commit 1eae4e42d4
14 changed files with 650 additions and 61 deletions
@@ -9,7 +9,7 @@ namespace AibisDream
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)
{
@@ -142,5 +142,10 @@ namespace AibisDream
{
OscilloscopeSystem.StartCoroutine(OscilloscopeSystem.DisableDeepInButton());
}
[YarnCommand("PrintPunchTapes")]
public static IEnumerator PrintPunchTapes(int count)
{
yield return PunchTapeSystem.StartCoroutine(PunchTapeSystem.PrintPunchTapes(count));
}
}
}
@@ -197,7 +197,7 @@ namespace AibisDream.FixSystem
public void MessageBoxSetText(string text)
{
_screenText.color = Color.white; // 默认文本颜色
_screenText.text += text+"<br>";
_screenText.text += text+"<br>";
}
public void MessageBoxSetNull()
{
@@ -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: