오늘은 튜토리얼 시스템을 구현해볼 예정이다.
public abstract class TutorialBase : MonoBehaviour
{
public abstract void Enter();
public abstract void Execute(TutorialController controller);
public abstract void Exit();
}
위처럼 fsm방식으로 베이스를 만들어주었다,
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TutorialController : MonoBehaviour
{
[SerializeField] private List<TutorialBase> tutorials;
[SerializeField] private string nextSceneName = "InGameTownScene";
private TutorialBase curTutorial = null;
private int curIndex = -1;
private void Start()
{
SetNextTutorial();
}
private void Update()
{
if(curTutorial != null)
{
curTutorial.Execute(this);
}
}
public void SetNextTutorial()
{
if( curTutorial != null)
{
curTutorial.Exit();
}
if(curIndex >= tutorials.Count - 1)
{
CompletedAllTutorials();
return;
}
curIndex++;
curTutorial = tutorials[curIndex];
curTutorial.Enter();
}
private void CompletedAllTutorials()
{
curTutorial = null;
if(!nextSceneName.Equals("nextSceneName"))
{
SceneLoadManager.Instance.ChangeScene(nextSceneName, () => { }, UnityEngine.SceneManagement.LoadSceneMode.Single);
}
}
}
컨트롤러를 통해 튜토리얼이 순차적으로 실행 되도록 하였다.
이제 순차적으로 들어갈 튜토리얼들을 만들어주면 된다,