-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathMovementTutorialState.cs
63 lines (56 loc) · 1.94 KB
/
MovementTutorialState.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using UnityEngine;
using System.Collections;
namespace UnityCheatSheet.Patterns.StatePattern.States
{
public class MovementTutorialState : IState
{
private readonly OnboardingManager manager;
private bool movementCompleted = false;
public MovementTutorialState(OnboardingManager manager)
{
this.manager = manager;
}
public void Enter()
{
Debug.Log("Welcome to the movement tutorial! Use WASD or arrow keys to move.");
}
public void Update()
{
if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
{
manager.SetDirectionTried("up", true);
Debug.Log("Moved up!");
}
if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
{
manager.SetDirectionTried("down", true);
Debug.Log("Moved down!");
}
if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
{
manager.SetDirectionTried("left", true);
Debug.Log("Moved left!");
}
if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
{
manager.SetDirectionTried("right", true);
Debug.Log("Moved right!");
}
if (manager.HasTriedAllDirections() && !movementCompleted)
{
movementCompleted = true;
Debug.Log("Great job! You've mastered movement.");
manager.StartCoroutine(TransitionToNextState());
}
}
public void Exit()
{
Debug.Log("Movement tutorial completed!");
}
private IEnumerator TransitionToNextState()
{
yield return new WaitForSeconds(2f);
manager.ChangeState(new CombatTutorialState(manager));
}
}
}