fix: ping两阶段点击—全部4个首次点击后才允许第二击显示chanrao
阶段0(_firstClickCount<4): 依次首次点击显示ping模型,激活下个ping 阶段1(_firstClickCount==4): 第二击显示chanrao并隐藏ping UndoSecondClick同步恢复_firstClickCount
This commit is contained in:
@@ -14,6 +14,7 @@ public class PingClickHandler : MonoBehaviour
|
||||
|
||||
private MeshRenderer _meshRenderer;
|
||||
private LineRenderer _outlineRenderer;
|
||||
private static int _firstClickCount = 0;
|
||||
private bool _clickedOnce;
|
||||
|
||||
void Start()
|
||||
@@ -75,39 +76,34 @@ public class PingClickHandler : MonoBehaviour
|
||||
|
||||
void OnMouseDown()
|
||||
{
|
||||
if (!_clickedOnce)
|
||||
// 阶段 0:4个ping依次首次点击(只显示模型)
|
||||
if (_firstClickCount < 4)
|
||||
{
|
||||
// 第一次点击:停止闪烁,显示模型
|
||||
if (_clickedOnce) return;
|
||||
_clickedOnce = true;
|
||||
_firstClickCount++;
|
||||
StopAllCoroutines();
|
||||
if (_meshRenderer != null) _meshRenderer.enabled = true;
|
||||
if (_outlineRenderer != null) _outlineRenderer.enabled = true;
|
||||
Debug.Log($"[PingClick] {name} 第一次点击,模型显示");
|
||||
// 激活下个 ping
|
||||
if (nextPing != null) { nextPing.SetActive(true); Debug.Log($"[PingClick] {name} → {nextPing.name} 激活"); }
|
||||
Debug.Log($"[PingClick] {name} 第1击 (model显示, {_firstClickCount}/4)");
|
||||
var sm = FindObjectOfType<StepManager>();
|
||||
if (sm != null) sm.RecordPingStep(pingIndex, false);
|
||||
}
|
||||
// 阶段 1:4个全部首次点击后,第二击显示chanrao
|
||||
else
|
||||
{
|
||||
// 第二次点击:显示 chanrao,隐藏自己,激活下个 ping
|
||||
if (chanraoObject != null)
|
||||
{
|
||||
chanraoObject.SetActive(true);
|
||||
Debug.Log($"[PingClick] {chanraoObject.name} 已显示");
|
||||
}
|
||||
|
||||
if (!_clickedOnce) return;
|
||||
if (chanraoObject != null) { chanraoObject.SetActive(true); Debug.Log($"[PingClick] {chanraoObject.name} 已显示"); }
|
||||
StopAllCoroutines();
|
||||
if (_meshRenderer != null) _meshRenderer.enabled = false;
|
||||
if (_outlineRenderer != null) _outlineRenderer.enabled = false;
|
||||
gameObject.SetActive(false);
|
||||
|
||||
if (nextPing != null)
|
||||
{
|
||||
nextPing.SetActive(true);
|
||||
Debug.Log($"[PingClick] {name} → {nextPing.name} 已激活");
|
||||
}
|
||||
Debug.Log($"[PingClick] {name} 第2击 (chanrao显示)");
|
||||
var sm = FindObjectOfType<StepManager>();
|
||||
if (sm != null) sm.RecordPingStep(pingIndex, true);
|
||||
}
|
||||
|
||||
// 通知 StepManager
|
||||
var sm = FindObjectOfType<StepManager>();
|
||||
if (sm != null) sm.RecordPingStep(pingIndex, _clickedOnce);
|
||||
}
|
||||
|
||||
/// <summary>上一步撤销:恢复到first-click状态</summary>
|
||||
@@ -115,6 +111,7 @@ public class PingClickHandler : MonoBehaviour
|
||||
{
|
||||
if (!_clickedOnce) return;
|
||||
_clickedOnce = false;
|
||||
_firstClickCount--;
|
||||
gameObject.SetActive(true);
|
||||
if (_meshRenderer != null) _meshRenderer.enabled = false;
|
||||
StopAllCoroutines();
|
||||
|
||||
Reference in New Issue
Block a user