-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathCombatTutorialState.cs
53 lines (45 loc) · 1.4 KB
/
CombatTutorialState.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
using UnityEngine;
using System.Collections;
namespace UnityCheatSheet.Patterns.StatePattern.States
{
public class CombatTutorialState : IState
{
private readonly OnboardingManager manager;
private bool attackPerformed = false;
private bool blockPerformed = false;
public CombatTutorialState(OnboardingManager manager)
{
this.manager = manager;
}
public void Enter()
{
Debug.Log("Welcome to combat training! Press Left Mouse Button to attack, Right Mouse Button to block.");
}
public void Update()
{
if (Input.GetMouseButtonDown(0) && !attackPerformed)
{
attackPerformed = true;
Debug.Log("Excellent attack!");
}
if (Input.GetMouseButtonDown(1) && !blockPerformed)
{
blockPerformed = true;
Debug.Log("Perfect block!");
}
if (attackPerformed && blockPerformed)
{
manager.StartCoroutine(TransitionToNextState());
}
}
public void Exit()
{
Debug.Log("Combat tutorial completed!");
}
private IEnumerator TransitionToNextState()
{
yield return new WaitForSeconds(2f);
manager.ChangeState(new InventoryTutorialState(manager));
}
}
}