fix: replace isBlinking logic with proper isFinished state to fix Ping first-click advancing
This commit is contained in:
@@ -4,15 +4,16 @@ public class ChanraoTuibuHandler : MonoBehaviour
|
||||
{
|
||||
public GameObject nextObject;
|
||||
private MeshRenderer _outlineMesh;
|
||||
private bool _isBlinking;
|
||||
private float _lastClickTime;
|
||||
private bool _isFinished;
|
||||
|
||||
public bool CanBeClicked() { return _isBlinking; }
|
||||
public bool CanBeClicked() { return !_isFinished; }
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if (GetComponent<Collider>() == null) gameObject.AddComponent<SphereCollider>().radius = 0.5f;
|
||||
foreach (var r in GetComponentsInChildren<Renderer>(true)) r.enabled = false; CreateOutlineMesh();
|
||||
_isBlinking = true;
|
||||
_isFinished = false;
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(BlinkOutline());
|
||||
Debug.Log($"[ChanraoTuibu] OnEnable outline={_outlineMesh!=null}");
|
||||
@@ -63,10 +64,13 @@ public class ChanraoTuibuHandler : MonoBehaviour
|
||||
|
||||
public void PerformClick()
|
||||
{
|
||||
if (!_isBlinking) return; // 防止重复点击
|
||||
if (Time.time - _lastClickTime < 0.3f) return; // 防止重复点击
|
||||
_lastClickTime = Time.time;
|
||||
if (_isFinished) return;
|
||||
|
||||
Debug.Log($"[ChanraoTuibu] {name} 被点击");
|
||||
ActionHistory.Push(ActionHistory.ActionType.ChanraoTuibu, this);
|
||||
_isBlinking = false;
|
||||
_isFinished = true;
|
||||
StopAllCoroutines();
|
||||
if (_outlineMesh != null) _outlineMesh.enabled = false;
|
||||
var mr = GetComponent<MeshRenderer>(); if (mr != null) mr.enabled = true;
|
||||
@@ -90,7 +94,7 @@ public class ChanraoTuibuHandler : MonoBehaviour
|
||||
|
||||
public void ResetState()
|
||||
{
|
||||
_isBlinking = true;
|
||||
_isFinished = false;
|
||||
var mr = GetComponent<MeshRenderer>(); if (mr != null) mr.enabled = false;
|
||||
var smr = GetComponent<SkinnedMeshRenderer>(); if (smr != null) smr.enabled = false;
|
||||
foreach (var r in GetComponentsInChildren<Renderer>(true)) { if (_outlineMesh != null && r == _outlineMesh) continue; r.enabled = false; }
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -6,6 +6,7 @@ public class ShoseClickHandler : MonoBehaviour
|
||||
public Transform targetPoint;
|
||||
private MeshRenderer _outlineMesh;
|
||||
private bool _clicked;
|
||||
private float _lastClickTime;
|
||||
|
||||
public bool CanBeClicked() { return !_clicked; }
|
||||
|
||||
@@ -76,6 +77,8 @@ public class ShoseClickHandler : MonoBehaviour
|
||||
|
||||
public void PerformClick()
|
||||
{
|
||||
if (Time.time - _lastClickTime < 0.3f) return;
|
||||
_lastClickTime = Time.time;
|
||||
if (_clicked) return;
|
||||
_clicked = true;
|
||||
Debug.Log("[ShoseClick] ★ 被点击 ★");
|
||||
|
||||
@@ -10,6 +10,7 @@ public class TouchPositionHandler : MonoBehaviour
|
||||
public GameObject womanObject;
|
||||
public GameObject nextTouchObject;
|
||||
public AudioClip voiceClip;
|
||||
private float _lastClickTime;
|
||||
|
||||
private MeshRenderer _meshRenderer;
|
||||
|
||||
@@ -59,6 +60,9 @@ public class TouchPositionHandler : MonoBehaviour
|
||||
private void OnMouseDown()
|
||||
{
|
||||
if (_meshRenderer == null || !_meshRenderer.enabled) return; // 防止重复点击
|
||||
if (Time.time - _lastClickTime < 0.3f) return;
|
||||
_lastClickTime = Time.time;
|
||||
|
||||
Debug.Log($"[TouchPosition] {name}: 被点击");
|
||||
|
||||
if (womanObject != null && targetPosition != null)
|
||||
|
||||
Reference in New Issue
Block a user