fix: replace isBlinking logic with proper isFinished state to fix Ping first-click advancing

This commit is contained in:
yangbear
2026-07-09 03:51:55 +08:00
parent 14b03b5859
commit a9d97d4b17
4 changed files with 28 additions and 14 deletions
+11 -8
View File
@@ -6,9 +6,10 @@ public class PingClickHandler : MonoBehaviour
public int pingIndex;
private MeshRenderer _modelRenderer, _outlineMesh;
private bool _modelShown;
private bool _isBlinking;
private float _lastClickTime;
private bool _isFinished;
public bool CanBeClicked() { return _isBlinking; }
public bool CanBeClicked() { return !_isFinished; }
void OnEnable()
{
@@ -18,7 +19,7 @@ public class PingClickHandler : MonoBehaviour
if (GetComponent<Collider>() == null) gameObject.AddComponent<SphereCollider>().radius = 0.5f;
CreateOutlineMesh();
_modelShown = false;
_isBlinking = true;
_isFinished = false;
StopAllCoroutines();
StartCoroutine(BlinkOutline());
}
@@ -58,7 +59,10 @@ public class PingClickHandler : MonoBehaviour
public void PerformClick()
{
if (!_isBlinking) return; // 防止重复点
if (Time.time - _lastClickTime < 0.3f) return; // 防
_lastClickTime = Time.time;
if (_isFinished) return;
foreach (var c in Object.FindObjectsOfType<Camera>())
{
if (!c.enabled) continue;
@@ -69,7 +73,6 @@ public class PingClickHandler : MonoBehaviour
if (!_modelShown)
{
_modelShown = true;
_isBlinking = false;
ActionHistory.Push(ActionHistory.ActionType.PingFirst, this);
StopAllCoroutines();
if (_modelRenderer != null) _modelRenderer.enabled = true;
@@ -129,7 +132,7 @@ public class PingClickHandler : MonoBehaviour
if (chanraoObject != null) chanraoObject.SetActive(false);
ShowSelf();
_modelShown = true;
_isBlinking = false;
_isFinished = false;
}
public void UndoShow() { HideSelf(); }
@@ -137,7 +140,7 @@ public class PingClickHandler : MonoBehaviour
{
foreach (var r in GetComponentsInChildren<Renderer>(true)) r.enabled = false;
var col = GetComponent<Collider>(); if (col != null) col.enabled = false;
_isBlinking = false;
_isFinished = true;
StopAllCoroutines();
}
@@ -151,7 +154,7 @@ public class PingClickHandler : MonoBehaviour
public void ResetState()
{
_modelShown = false;
_isBlinking = true;
_isFinished = false;
if (_modelRenderer != null) _modelRenderer.enabled = false;
// 隐藏自身模型
foreach (var r in GetComponentsInChildren<Renderer>(true)) { if (_outlineMesh != null && r == _outlineMesh) continue; r.enabled = false; }