多轮审查和修复

This commit is contained in:
2026-05-12 15:34:08 +08:00
parent f55d2a57c3
commit ebbbb7332e
805 changed files with 838724 additions and 1905 deletions

View File

@@ -0,0 +1,69 @@
using System.Collections;
using MoreMountains.Feedbacks;
using UnityEngine;
namespace BaseGames.World
{
/// <summary>
/// 碎裂平台。玩家踩上后经历 Warning → Crumbling → Gone → (Recovering) 四态。
/// _isOneShot = true 时碎裂后永久消失_respawnDelay &gt; 0 则在延迟后恢复。
/// </summary>
[RequireComponent(typeof(BoxCollider2D))]
public class CrumblePlatform : MonoBehaviour
{
[SerializeField] private float _warningDuration = 0.6f;
[SerializeField] private float _crumbleDuration = 0.3f;
[SerializeField] private float _respawnDelay = 3.0f; // 0 = 永久消失
[SerializeField] private bool _isOneShot = false;
[SerializeField] private MMF_Player _crumbleFeedback; // 预警震动 + 碎裂粒子 + 音效
[SerializeField] private BoxCollider2D _passengerSensor; // IsTrigger检测玩家踩踏
private BoxCollider2D _col;
private SpriteRenderer _sr;
private bool _isCrumbling;
private void Awake()
{
_col = GetComponent<BoxCollider2D>();
_sr = GetComponent<SpriteRenderer>();
}
private void OnTriggerEnter2D(Collider2D other)
{
if (_isCrumbling) return;
if (!other.CompareTag("Player")) return;
StartCoroutine(CrumbleSequence());
}
private IEnumerator CrumbleSequence()
{
_isCrumbling = true;
// 1. Warning抖动
_crumbleFeedback?.PlayFeedbacks();
yield return new WaitForSeconds(_warningDuration);
// 2. Crumbling 动画等待
yield return new WaitForSeconds(_crumbleDuration);
// 3. Gone禁用碰撞体 + 隐藏 Sprite
_col.enabled = false;
_sr.enabled = false;
if (_passengerSensor != null)
_passengerSensor.enabled = false;
if (_isOneShot || _respawnDelay <= 0f)
yield break; // 永久消失
// 4. Respawn
yield return new WaitForSeconds(_respawnDelay);
_col.enabled = true;
_sr.enabled = true;
if (_passengerSensor != null)
_passengerSensor.enabled = true;
_isCrumbling = false;
}
}
}