65 lines
1.4 KiB
C#
65 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PanelGuide : BasePanel
|
|
{
|
|
public Action<int> DelStepDone;
|
|
public Action DelGuideFinish;
|
|
|
|
[SerializeField] Transform mCtnGuide;
|
|
|
|
private int mGuideIndex;
|
|
private int mCurStepIndex = -1;
|
|
private List<GuideStep> mSteps;
|
|
|
|
public void InitGuide(int pGuideIndex)
|
|
{
|
|
mGuideIndex = pGuideIndex;
|
|
|
|
for (int i = 0; i < mCtnGuide.childCount; i++)
|
|
{
|
|
mCtnGuide.GetChild(i).gameObject.SetActive(i == pGuideIndex);
|
|
}
|
|
|
|
mSteps = Utils.GetChildListFirstLayer<GuideStep>(mCtnGuide.GetChild(pGuideIndex));
|
|
for (int i = 0; i < mSteps.Count; i++)
|
|
{
|
|
mSteps[i].DelStepDone = OnStepDone;
|
|
mSteps[i].InitStep(i);
|
|
}
|
|
|
|
mCurStepIndex = -1;
|
|
}
|
|
|
|
public void NextStep(Vector3 pScreenPos = default)
|
|
{
|
|
mCurStepIndex++;
|
|
if (mCurStepIndex < mSteps.Count)
|
|
{
|
|
mSteps[mCurStepIndex].StartStep(pScreenPos);
|
|
}
|
|
else
|
|
{
|
|
DelGuideFinish?.Invoke();
|
|
}
|
|
}
|
|
|
|
public void FinishCurrentStep()
|
|
{
|
|
if (mCurStepIndex >= 0 && mCurStepIndex < mSteps.Count)
|
|
{
|
|
mSteps[mCurStepIndex].FinishStep();
|
|
}
|
|
}
|
|
|
|
private void OnStepDone(int pIndex, bool pAutoNext)
|
|
{
|
|
DelStepDone?.Invoke(pIndex);
|
|
|
|
if (pAutoNext)
|
|
{
|
|
NextStep();
|
|
}
|
|
}
|
|
} |