MimeMimeTutorial.cs 4.41 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class MimeMimeTutorial : MonoBehaviour
{

    public GameObject dialogueBox;
    public Camera faceCam;
    public Text SilasText;
    public GameObject silas;
    public SilasSpeech speech;
    public Button button;
    public SpawnKeys spawner;
    public AudioSource music;
nedboy3's avatar
nedboy3 committed
18
    public Text tutorialText;
19

nedboy3's avatar
nedboy3 committed
20
21
    private bool canProgress = false;
    private bool freeze = false;
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
    private int state;

    private void Start()
    {
        GameManager.SilasTutorial = true;
        dialogueBox.SetActive(false);
        speech = silas.GetComponent<SilasSpeech>();
        print(speech.GreetingMessage());
        SilasText.text = speech.converse();
        StartCoroutine(noticePlayer());
    }

    private void Update()
    {
        if ((Input.GetKeyDown(KeyCode.Q) || Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.R)) && GameManager.TutorialState == 1)
        {
nedboy3's avatar
nedboy3 committed
38
            //player just danced
39
            progress();
nedboy3's avatar
nedboy3 committed
40

41
42
43
        }
        if (GameManager.TutorialState == 3 && GameManager.SilasNoteInPlace)
        {
nedboy3's avatar
nedboy3 committed
44
            //practice note needs to be hit.
45
46
47
48
            progress();
        }
        if (Input.GetKeyDown(KeyCode.Q) && GameManager.TutorialState == 4)
        {
nedboy3's avatar
nedboy3 committed
49
            //practice note has been hit.
50
51
52
53
            progress();
            Time.timeScale = 1f;
            music.Play();
            GameManager.SilasNoteInPlace = false;
nedboy3's avatar
nedboy3 committed
54
55
56
57
58
59
60
61
62
63
64
65
66
67
            StartCoroutine(finish(0.6f));
        }
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            ButtonPress();
        }
        if (freeze == true && GameObject.FindWithTag("TutorialBlock").transform.position.y <= -4f)
        {
            freeze = false;
            GameObject.FindWithTag("TutorialBlock").transform.localPosition = new Vector3(GameObject.FindWithTag("TutorialBlock").transform.position.x, -4.000f, GameObject.FindWithTag("TutorialBlock").transform.position.z);
            Time.timeScale = 0f;
            
            progress();
            music.Pause();
68
69
70
        }
    }

nedboy3's avatar
nedboy3 committed
71
    private IEnumerator finish(float time)
72
    {
nedboy3's avatar
nedboy3 committed
73
        yield return new WaitForSeconds(time);
74
75
76
77
78
        progress();
    }

    private IEnumerator noticePlayer()
    {
nedboy3's avatar
nedboy3 committed
79
80
        yield return new WaitForSeconds(1);
        canProgress = true;
81
82
83
84
85
86
87
        dialogueBox.SetActive(true);
        faceCam.gameObject.SetActive(true);
        StopCoroutine(noticePlayer());
    }

    public void ButtonPress()
    {
nedboy3's avatar
nedboy3 committed
88
89
90
91
        if (canProgress == true)
        {
            progress();
        }
92
93
94
95
96
97
98
    }

    void progress()
    {
        state++;
        if (state == 4)
        {
nedboy3's avatar
nedboy3 committed
99
100
            canProgress = false;
            tutorialText.text = "Test out those dancing shoes";
101
102
103
104
            GameManager.TutorialState = 1;
        }
        else if (state == 5)
        {
nedboy3's avatar
nedboy3 committed
105
106
            canProgress = true;
            tutorialText.text = "(1)Continue";
107
108
109
110
111
            button.gameObject.SetActive(true);
            GameManager.TutorialState = 2;
        }
        else if(state == 8)
        {
nedboy3's avatar
nedboy3 committed
112
            canProgress = false;
113
114
115
            button.gameObject.SetActive(false);
            GameManager.TutorialState = 3;
            spawner.startTutorial();
nedboy3's avatar
nedboy3 committed
116
            freeze = true;
117
118
119
120
            GameManager.PlayerCanDance = false;
        }
        else if (state == 9)
        {
nedboy3's avatar
nedboy3 committed
121
            canProgress = false;
122
123
124
            button.gameObject.SetActive(false);
            GameManager.PlayerCanDance = true;
            GameManager.TutorialState = 4;
nedboy3's avatar
nedboy3 committed
125
            //practice note can now be hit.
126
127
128
        }
        else if (state == 11)
        {
nedboy3's avatar
nedboy3 committed
129
130
131
            canProgress = true;
            Time.timeScale = 0f;
            music.Pause();
132
133
            button.gameObject.SetActive(true);
        }
nedboy3's avatar
nedboy3 committed
134
        else if (state == 13)
135
        {
nedboy3's avatar
nedboy3 committed
136
            canProgress = false;
137
138
139
            button.gameObject.SetActive(false);
            Time.timeScale = 1f;
            music.Play();
nedboy3's avatar
nedboy3 committed
140
            StartCoroutine(finish(5f));
141
        }
nedboy3's avatar
nedboy3 committed
142
        else if (state == 14)
143
        {
nedboy3's avatar
nedboy3 committed
144
            canProgress = true;
145
146
147
            button.gameObject.SetActive(true);
            music.volume = 0.05f;
        }
nedboy3's avatar
nedboy3 committed
148
        else if (state == 15)
149
        {
mmaluschnig's avatar
mmaluschnig committed
150
151
152
            GameManager.FirstTimeMime = false;
            GameManager.TutorialState = 0;
            GameManager.SilasTutorial = false;
153
154
155
156
157
            SceneManager.LoadScene("MimeMime");
        }
        SilasText.text = speech.converse();
    }
}