feat: ping两步点击+蓝色描边+StepManager步骤追踪
PingClickHandler: - 蓝色圆环闪烁描边 - 第一点击: 停止闪烁显示模型 - 第二点击: 显示chanrao隐藏自己激活下个ping - UndoSecondClick/UndoShow 支持撤销 StepManager: - 新增PingStepPrevious/PingStepNext/RecordPingStep - PreviousStep/NextStep ping步优先于woman步 - InitPingSteps初始化ping/chanrao引用
This commit is contained in:
@@ -125,15 +125,98 @@ public class StepManager : MonoBehaviour
|
||||
public void NextStep()
|
||||
{
|
||||
// Woman 自由步进优先
|
||||
if (_pingObjects != null && _pingObjects.Length > 0 && _pingStepIndex < _pingMaxStep) { PingStepNext(); return; }
|
||||
if (_womanObject != null && _womanPositions != null) { WomanStepNext(); return; }
|
||||
if (_activeSteps == null) return;
|
||||
if (_currentStepIndex >= _activeSteps.Length - 1) { CompleteExperiment(); return; }
|
||||
GoToStep(_currentStepIndex + 1);
|
||||
}
|
||||
|
||||
public void PreviousStep()
|
||||
private void PingStepPrevious()
|
||||
{
|
||||
if (_pingStepIndex <= 0) return;
|
||||
int idx = (_pingStepIndex - 1) / 2; // ping index (0-3, mapping to 004-001)
|
||||
bool wasSecond = (_pingStepIndex - 1) % 2 == 1; // true if was second click
|
||||
|
||||
if (wasSecond)
|
||||
{
|
||||
// Undo second click: hide chanrao, restore ping to first-click state
|
||||
if (_chanraoObjects != null && idx < _chanraoObjects.Length && _chanraoObjects[idx] != null)
|
||||
_chanraoObjects[idx].SetActive(false);
|
||||
if (_pingObjects != null && idx < _pingObjects.Length && _pingObjects[idx] != null)
|
||||
{
|
||||
var h = _pingObjects[idx].GetComponent<PingClickHandler>();
|
||||
if (h != null) h.UndoSecondClick();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Undo first click: hide current ping, show previous ping (if any)
|
||||
if (_pingObjects != null && idx < _pingObjects.Length && _pingObjects[idx] != null)
|
||||
{
|
||||
var h = _pingObjects[idx].GetComponent<PingClickHandler>();
|
||||
if (h != null) h.UndoShow();
|
||||
}
|
||||
// If going back to start, show ping.004
|
||||
if (idx == 0 && _pingObjects != null && _pingObjects.Length > 0 && _pingObjects[0] != null)
|
||||
_pingObjects[0].SetActive(true);
|
||||
}
|
||||
_pingStepIndex--;
|
||||
Debug.Log($"StepManager: Ping撤销 -> {_pingStepIndex}");
|
||||
OnStepChanged?.Invoke(_pingStepIndex);
|
||||
}
|
||||
|
||||
private void PingStepNext()
|
||||
{
|
||||
if (_pingStepIndex >= _pingMaxStep) return;
|
||||
int idx = _pingStepIndex / 2;
|
||||
bool isSecond = _pingStepIndex % 2 == 1;
|
||||
|
||||
if (!isSecond)
|
||||
{
|
||||
// Advance to first click: ensure ping is visible and in first-click state
|
||||
if (_pingObjects != null && idx < _pingObjects.Length && _pingObjects[idx] != null)
|
||||
{
|
||||
var ping = _pingObjects[idx];
|
||||
ping.SetActive(true);
|
||||
var h = ping.GetComponent<PingClickHandler>();
|
||||
if (h != null)
|
||||
{
|
||||
h.UndoSecondClick(); // Reset to first-click state
|
||||
// Trigger first click via reflection/method
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Advance to second click: show chanrao
|
||||
if (_chanraoObjects != null && idx < _chanraoObjects.Length && _chanraoObjects[idx] != null)
|
||||
_chanraoObjects[idx].SetActive(true);
|
||||
if (_pingObjects != null && idx < _pingObjects.Length && _pingObjects[idx] != null)
|
||||
{
|
||||
var h = _pingObjects[idx].GetComponent<PingClickHandler>();
|
||||
if (h != null) h.UndoShow();
|
||||
}
|
||||
// Show next ping for first click
|
||||
if (idx + 1 < 4 && _pingObjects != null && _pingObjects[idx+1] != null)
|
||||
_pingObjects[idx+1].SetActive(true);
|
||||
}
|
||||
_pingStepIndex++;
|
||||
Debug.Log($"StepManager: Ping前进 -> {_pingStepIndex}");
|
||||
OnStepChanged?.Invoke(_pingStepIndex);
|
||||
}
|
||||
|
||||
public void RecordPingStep(int pingIndex, bool secondClick)
|
||||
{
|
||||
_pingStepIndex = pingIndex * 2 + (secondClick ? 2 : 1);
|
||||
Debug.Log($"StepManager: Ping步进 -> {_pingStepIndex} (ping{pingIndex} second={secondClick})");
|
||||
OnStepChanged?.Invoke(_pingStepIndex);
|
||||
}
|
||||
|
||||
public public void PreviousStep()
|
||||
{
|
||||
// Woman 自由步进优先
|
||||
if (_pingObjects != null && _pingObjects.Length > 0 && _pingStepIndex > 0) { PingStepPrevious(); return; }
|
||||
if (_womanObject != null && _womanPositions != null) { WomanStepPrevious(); return; }
|
||||
if (_activeSteps == null) return;
|
||||
if (_currentStepIndex <= 0) return;
|
||||
@@ -201,6 +284,25 @@ public class StepManager : MonoBehaviour
|
||||
Debug.Log($"StepManager: Woman步进已初始化, 共{_womanMaxStep}个位置");
|
||||
}
|
||||
|
||||
public void InitPingSteps()
|
||||
{
|
||||
var mi = GameObject.Find("manInjury");
|
||||
if (mi == null) return;
|
||||
_pingObjects = new GameObject[4];
|
||||
_chanraoObjects = new GameObject[4];
|
||||
for (int i = 1; i <= 4; i++)
|
||||
{
|
||||
string pn = "ping." + i.ToString("D3");
|
||||
string cn = "chanrao." + i.ToString("D3");
|
||||
var pt = mi.transform.Find(pn);
|
||||
var ct = mi.transform.Find(cn);
|
||||
if (pt != null) _pingObjects[i-1] = pt.gameObject;
|
||||
if (ct != null) _chanraoObjects[i-1] = ct.gameObject;
|
||||
}
|
||||
_pingStepIndex = 0;
|
||||
Debug.Log("StepManager: Ping步进已初始化");
|
||||
}
|
||||
|
||||
public void RecordWomanStep(int newStepIndex) { _womanStepIndex = Mathf.Clamp(newStepIndex, 0, _womanMaxStep); Debug.Log($"StepManager: Woman步进 -> {_womanStepIndex}"); OnStepChanged?.Invoke(_womanStepIndex); }
|
||||
|
||||
private void WomanStepPrevious()
|
||||
@@ -267,6 +369,10 @@ public class StepManager : MonoBehaviour
|
||||
private int _womanMaxStep = 3;
|
||||
private Transform[] _womanPositions;
|
||||
private GameObject[] _touchPoints;
|
||||
private GameObject[] _pingObjects;
|
||||
private GameObject[] _chanraoObjects;
|
||||
private int _pingStepIndex = 0;
|
||||
private int _pingMaxStep = 8; // 4 pings × 2 clicks each
|
||||
|
||||
|
||||
private Vector3 _womanInitPos;
|
||||
|
||||
Reference in New Issue
Block a user