Fix ping click handler resetting logic properly dividing phase 1 and phase 2
This commit is contained in:
@@ -218,6 +218,12 @@ public class StepManager : MonoBehaviour
|
||||
Debug.Log($"StepManager: Ping步进 -> {_pingStepIndex} (ping{pingIndex} second={secondClick})");
|
||||
OnStepChanged?.Invoke(_pingStepIndex);
|
||||
}
|
||||
|
||||
public void SetPingStepIndex(int index)
|
||||
{
|
||||
_pingStepIndex = index;
|
||||
Debug.Log($"StepManager: Ping彻底重置 -> {index}");
|
||||
}
|
||||
|
||||
public void DecrementPingStep()
|
||||
{
|
||||
|
||||
@@ -32,22 +32,40 @@ public static class ActionHistory
|
||||
var item = History.Pop();
|
||||
Debug.Log($"[ActionHistory] Undo {item.Type} handler={(item.Handler != null ? item.Handler.name : "null")}, remaining={History.Count}");
|
||||
|
||||
// 如果遇到任何 Ping 的动作,就代表用户想重置整个包扎步骤
|
||||
if (item.Type == ActionType.PingFirst || item.Type == ActionType.PingSecond)
|
||||
if (item.Type == ActionType.PingSecond)
|
||||
{
|
||||
// 1. 持续弹栈,直到把所有 Ping 相关的记录都清理掉
|
||||
while (History.Count > 0 && (History.Peek().Type == ActionType.PingFirst || History.Peek().Type == ActionType.PingSecond))
|
||||
// 如果在包扎(第二阶段),则重置所有的包扎纱布,退回到所有骨折点发光的状态
|
||||
while (History.Count > 0 && History.Peek().Type == ActionType.PingSecond)
|
||||
{
|
||||
History.Pop();
|
||||
}
|
||||
|
||||
var allPings = Object.FindObjectsOfType<PingClickHandler>(true);
|
||||
foreach (var p in allPings)
|
||||
{
|
||||
if (p.chanraoObject != null) p.chanraoObject.SetActive(false);
|
||||
p.gameObject.SetActive(true);
|
||||
p.ReEnableBorder();
|
||||
}
|
||||
|
||||
var sm = Object.FindObjectOfType<StepManager>();
|
||||
if (sm != null) sm.SetPingStepIndex(8); // 退回到 4 个底模已确认的状态 (Ping 阶段的第一半结束)
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (item.Type == ActionType.PingFirst)
|
||||
{
|
||||
// 如果在定位(第一阶段),则重置所有的定位,退回到只有第一个点发光的状态
|
||||
while (History.Count > 0 && History.Peek().Type == ActionType.PingFirst)
|
||||
{
|
||||
History.Pop();
|
||||
}
|
||||
|
||||
// 2. 将场景里的所有 Ping 彻底重置
|
||||
var allPings = Object.FindObjectsOfType<PingClickHandler>(true);
|
||||
foreach (var p in allPings)
|
||||
{
|
||||
if (p.chanraoObject != null) p.chanraoObject.SetActive(false);
|
||||
|
||||
// pingIndex 为 0 的通常是第一个出现的物体 (ping.004)
|
||||
if (p.pingIndex == 0)
|
||||
{
|
||||
p.gameObject.SetActive(true);
|
||||
@@ -55,13 +73,12 @@ public static class ActionHistory
|
||||
}
|
||||
else
|
||||
{
|
||||
p.UndoShow(); // 其他的全部隐藏
|
||||
p.UndoShow();
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 将 UI 的 Ping 进度清零
|
||||
var sm = Object.FindObjectOfType<StepManager>();
|
||||
if (sm != null) sm.ResetPingStep();
|
||||
if (sm != null) sm.SetPingStepIndex(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user