通了一版

This commit is contained in:
2025-05-29 16:31:57 +08:00
parent 1dd27a51b9
commit 262ffad009
7 changed files with 1647 additions and 1294 deletions
@@ -31,6 +31,7 @@ public class ShockSystem : MonoBehaviour
[SerializeField] private Vector3 leftShockDeviceStartPos; // 左电击装置起始位置
[SerializeField] private Vector3 rightShockDeviceStartPos; // 右电击装置起始位置
[SerializeField] private Vector3 operationPanelTargetPos; // 操作面板目标位置
[SerializeField] private Vector3 operationPanelStartPos; // 操作面板起始位置
[SerializeField] private float moveDuration = 1f; // 移动动画时长
[SerializeField] private float shockDelay = 0.5f; // 释放电击延迟
[SerializeField] private float progressIncreaseSpeed = 1f; // 进度增加基础速度
@@ -97,6 +98,10 @@ public class ShockSystem : MonoBehaviour
{
rightDeviceOriginalPos = rightShockDevice.localPosition;
}
if (operationPanel != null)
{
operationPanelStartPos = operationPanel.localPosition;
}
// 初始化杆的位置
if (lever != null)
@@ -216,7 +221,7 @@ public class ShockSystem : MonoBehaviour
{
var moveLeft = leftShockDevice.DOLocalMove(leftDeviceOriginalPos, moveDuration);
var moveRight = rightShockDevice.DOLocalMove(rightDeviceOriginalPos, moveDuration);
var movePanel = operationPanel.DOLocalMove(operationPanelTargetPos, moveDuration);
var movePanel = operationPanel.DOLocalMove(operationPanelStartPos, moveDuration);
yield return moveLeft.WaitForCompletion();
yield return moveRight.WaitForCompletion();
@@ -400,29 +405,40 @@ public class ShockSystem : MonoBehaviour
// 自动充能并释放
public IEnumerator AutoChargeAndRelease(float duration = 1f)
{
// 禁用玩家输入
bool originalIsDraggingLever = isDraggingLever;
isDraggingLever = false;
// 设置杆的角度
targetLeverAngle = maxLeverAngle;
currentLeverAngle = maxLeverAngle;
lever.localRotation = Quaternion.Euler(0, 0, -maxLeverAngle);
// 开始充能
isCharging = true;
StartCharging();
// 计算需要的充能速度
float targetProgress = progressBar.MaxValue;
float chargeSpeed = targetProgress / duration;
float originalProgressIncreaseSpeed = progressIncreaseSpeed;
progressIncreaseSpeed = chargeSpeed;
// 等待充能完成
float startTime = Time.time;
while (Time.time - startTime < duration)
{
// 使用计算出的充能速度
currentProgress += chargeSpeed * Time.deltaTime;
progressBar.CurrentValue = Mathf.FloorToInt(currentProgress);
UpdateCharging();
yield return null;
}
// 确保进度达到最大值
currentProgress = progressBar.MaxValue;
progressBar.CurrentValue = Mathf.FloorToInt(currentProgress);
// 恢复原始设置
progressIncreaseSpeed = originalProgressIncreaseSpeed;
isCharging = false;
isDraggingLever = originalIsDraggingLever;
// 触发 Yarn 节点来决定使用哪种效果
DialogController.Instance.StartDialogNode(shockEffectNode);
// DialogController.Instance.StartDialogNode(shockEffectNode);
// 重置杆的角度
targetLeverAngle = 0f;