Implement scene transition
This commit is contained in:
parent
edc3abff84
commit
0b295af56b
6 changed files with 30 additions and 16 deletions
|
|
@ -4,6 +4,8 @@ using UnityEngine;
|
|||
|
||||
public enum SceneId
|
||||
{
|
||||
None,
|
||||
|
||||
Prologue_First,
|
||||
Chapter1_Cave,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,6 @@ public class Scene_Prologue_First: StoryScene {
|
|||
DialogPosition.Right);
|
||||
yield return new WaitForSeconds(2f);
|
||||
|
||||
// TODO: Transition to Chapter 1.
|
||||
this.SetNextSceneId(SceneId.Chapter1_Cave);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,12 +12,10 @@ public class StoryBox : MonoBehaviour {
|
|||
private bool clicked;
|
||||
|
||||
void Start() {
|
||||
Debug.Log("StoryBox Start");
|
||||
this.button.onClick.AddListener(NotifyOnClick);
|
||||
}
|
||||
|
||||
public IEnumerator Display(string message) {
|
||||
Debug.Log("StoryBox Display");
|
||||
this.gameObject.SetActive(true);
|
||||
this.clicked = false;
|
||||
this.text.text = message;
|
||||
|
|
|
|||
|
|
@ -6,19 +6,22 @@ public class StoryController : MonoBehaviour
|
|||
{
|
||||
public StoryDisplay storyDisplay;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
// TODO: Read which scene should be loaded.
|
||||
//StoryScene scene = StorySceneDatabase.Load(SceneId.Chapter1_Cave);
|
||||
StoryScene scene = StorySceneDatabase.Load(SceneId.Prologue_First);
|
||||
private SceneId nextSceneId;
|
||||
|
||||
StartCoroutine(scene.Play(this.storyDisplay));
|
||||
void Start() {
|
||||
// TODO: Read which scene should be loaded.
|
||||
this.nextSceneId = SceneId.Prologue_First;
|
||||
|
||||
StartCoroutine(this.PlayScenes());
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
private IEnumerator PlayScenes() {
|
||||
while (true) {
|
||||
SceneId id = this.nextSceneId;
|
||||
this.nextSceneId = SceneId.None;
|
||||
StoryScene scene = StorySceneDatabase.Load(id);
|
||||
yield return scene.Play(this.storyDisplay);
|
||||
this.nextSceneId = scene.GetNextSceneId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ public class StoryDisplay : MonoBehaviour
|
|||
private StoryBox storyBoxLeft;
|
||||
|
||||
void Awake() {
|
||||
Debug.Log("StoryDisplay Awake");
|
||||
this.storyBoxLeft = GameObject.Instantiate(this.storyBox, this.uiCanvas.transform);
|
||||
RectTransform rt = this.storyBoxLeft.GetComponent<RectTransform>();
|
||||
rt.anchorMin = new Vector2(0, 0.5f);
|
||||
|
|
@ -28,7 +27,6 @@ public class StoryDisplay : MonoBehaviour
|
|||
}
|
||||
|
||||
public IEnumerator DisplayText(string message, DialogPosition position) {
|
||||
Debug.Log("DisplayText " + message);
|
||||
if (position == DialogPosition.Left) {
|
||||
yield return this.storyBoxLeft.Display(message);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -4,5 +4,18 @@ using UnityEngine;
|
|||
|
||||
public abstract class StoryScene
|
||||
{
|
||||
private SceneId nextSceneId = SceneId.None;
|
||||
|
||||
public abstract IEnumerator Play(StoryDisplay storyDisplay);
|
||||
|
||||
protected void SetNextSceneId(SceneId id) {
|
||||
this.nextSceneId = id;
|
||||
}
|
||||
|
||||
public SceneId GetNextSceneId() {
|
||||
if (nextSceneId == SceneId.None) {
|
||||
throw new System.InvalidOperationException("nextSceneId is None");
|
||||
}
|
||||
return this.nextSceneId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue