This commit is contained in:
2025-05-29 15:27:49 +08:00
parent 08a377724b
commit 2610c769d9
5 changed files with 989 additions and 901 deletions
@@ -398,16 +398,20 @@ public class ShockSystem : MonoBehaviour
}
// 自动充能并释放
public IEnumerator AutoChargeAndRelease(float chargeSpeed = 5f, float duration = 1f)
public IEnumerator AutoChargeAndRelease(float duration = 1f)
{
// 设置杆的角度
targetLeverAngle = maxLeverAngle;
// 计算需要的充能速度
float targetProgress = progressBar.MaxValue;
float chargeSpeed = targetProgress / duration;
// 等待充能完成
float startTime = Time.time;
while (Time.time - startTime < duration)
{
// 使用指定的充能速度
// 使用计算出的充能速度
currentProgress += chargeSpeed * Time.deltaTime;
progressBar.CurrentValue = Mathf.FloorToInt(currentProgress);
yield return null;
@@ -428,7 +432,7 @@ public class ShockSystem : MonoBehaviour
// 使用默认参数的自动充能方法
public IEnumerator AutoChargeAndRelease()
{
yield return AutoChargeAndRelease(autoChargeSpeed, autoChargeDuration);
yield return AutoChargeAndRelease(autoChargeDuration);
}
private void OnDestroy()