feat: 上一步/下一步支持woman步进撤销重做
- StepManager新增自由步进模式(无Config时): InitWomanSteps/RecordWomanStep/WomanStepPrevious/WomanStepNext - PreviousStep/NextStep在_activeSteps为null时走woman步进 - TouchPositionHandler点击后通知StepManager.RecordWomanStep - PageController在实验启动时调用InitWomanSteps初始化 - 上一步→woman回到上个位置+显示对应touchPoint - 下一步→woman移到下个位置+显示对应touchPoint
This commit is contained in:
@@ -124,18 +124,15 @@ public class StepManager : MonoBehaviour
|
||||
|
||||
public void NextStep()
|
||||
{
|
||||
if (_activeSteps == null) return;
|
||||
if (_currentStepIndex >= _activeSteps.Length - 1)
|
||||
{
|
||||
CompleteExperiment();
|
||||
return;
|
||||
}
|
||||
if (_activeSteps == null) { WomanStepNext(); return; }
|
||||
if (_currentStepIndex >= _activeSteps.Length - 1) { CompleteExperiment(); return; }
|
||||
GoToStep(_currentStepIndex + 1);
|
||||
}
|
||||
|
||||
public void PreviousStep()
|
||||
{
|
||||
if (_activeSteps == null || _currentStepIndex <= 0) return;
|
||||
if (_activeSteps == null) { WomanStepPrevious(); return; }
|
||||
if (_currentStepIndex <= 0) return;
|
||||
GoToStep(_currentStepIndex - 1);
|
||||
}
|
||||
|
||||
@@ -178,4 +175,62 @@ public class StepManager : MonoBehaviour
|
||||
GameManager.Instance.CurrentFixationMethod = newFixation;
|
||||
Initialize(GameManager.Instance.CurrentExperimentType, GameManager.Instance.CurrentMode, newFixation);
|
||||
}
|
||||
|
||||
|
||||
public void InitWomanSteps()
|
||||
{
|
||||
_womanObject = GameObject.Find("woman");
|
||||
_touchArrayObject = GameObject.Find("touchArray");
|
||||
var pts = GameObject.Find("womanPointArray");
|
||||
if (pts != null) { _womanMaxStep = pts.transform.childCount; _womanPositions = new Transform[_womanMaxStep]; for (int i = 0; i < _womanMaxStep; i++) _womanPositions[i] = pts.transform.GetChild(i); }
|
||||
if (_touchArrayObject != null) { _touchPoints = new GameObject[_touchArrayObject.transform.childCount]; for (int i = 0; i < _touchPoints.Length; i++) _touchPoints[i] = _touchArrayObject.transform.GetChild(i).gameObject; }
|
||||
_womanStepIndex = 0;
|
||||
Debug.Log($"StepManager: Woman步进已初始化, 共{_womanMaxStep}个位置");
|
||||
}
|
||||
|
||||
public void RecordWomanStep(int newStepIndex) { _womanStepIndex = Mathf.Clamp(newStepIndex, 0, _womanMaxStep); Debug.Log($"StepManager: Woman步进 -> {_womanStepIndex}"); OnStepChanged?.Invoke(_womanStepIndex); }
|
||||
|
||||
private void WomanStepPrevious()
|
||||
{
|
||||
if (_womanStepIndex <= 0) return;
|
||||
_womanStepIndex--;
|
||||
MoveWomanToStep(_womanStepIndex);
|
||||
UpdateTouchVisibility(_womanStepIndex);
|
||||
Debug.Log($"StepManager: Woman撤销 -> {_womanStepIndex}");
|
||||
OnStepChanged?.Invoke(_womanStepIndex);
|
||||
}
|
||||
|
||||
private void WomanStepNext()
|
||||
{
|
||||
if (_womanStepIndex >= _womanMaxStep) return;
|
||||
_womanStepIndex++;
|
||||
MoveWomanToStep(_womanStepIndex);
|
||||
UpdateTouchVisibility(_womanStepIndex);
|
||||
Debug.Log($"StepManager: Woman前进 -> {_womanStepIndex}");
|
||||
OnStepChanged?.Invoke(_womanStepIndex);
|
||||
}
|
||||
|
||||
private void MoveWomanToStep(int step)
|
||||
{
|
||||
if (_womanObject == null || _womanPositions == null || step <= 0 || step > _womanPositions.Length) return;
|
||||
var t = _womanPositions[step - 1];
|
||||
_womanObject.transform.position = t.position;
|
||||
_womanObject.transform.rotation = t.rotation;
|
||||
}
|
||||
|
||||
private void UpdateTouchVisibility(int step)
|
||||
{
|
||||
if (_touchPoints == null) return;
|
||||
for (int i = 0; i < _touchPoints.Length; i++) _touchPoints[i].SetActive(i == step - 1);
|
||||
}
|
||||
|
||||
|
||||
[Header("=== Woman 步进追踪(不依赖 Config) ===")]
|
||||
[SerializeField] private GameObject _womanObject;
|
||||
[SerializeField] private GameObject _touchArrayObject;
|
||||
|
||||
private int _womanStepIndex = 0;
|
||||
private int _womanMaxStep = 3;
|
||||
private Transform[] _womanPositions;
|
||||
private GameObject[] _touchPoints;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user