all repos — RPG @ d7044262357209ad359fad4b2664315aea7096d0

Fully functional 3D turn based role playing game coded in C# and base Unity.

Assets/TutorialManager.cs (view raw)

 1using System.Collections;
 2using System.Collections.Generic;
 3using UnityEngine;
 4using UnityEngine.SceneManagement;
 5using UnityEngine.UI;
 6
 7public class TutorialManager : MonoBehaviour
 8{
 9    [SerializeField] private GameObject backButton = null, prevButton = null, nextButton = null, startButton = null;
10    [SerializeField] private GameObject[] pages = null;
11
12    private int page = 0;
13
14    private void showPage()
15    {
16        if(page > -1 && page <= pages.Length)
17        {
18            foreach(GameObject p in pages)
19            {
20                p.SetActive(false);
21            }
22            pages[page].SetActive(true);
23        } else {
24            Debug.Log("Can't show page " + page);
25        }
26
27        if(page == pages.Length - 1)
28        {
29            nextButton.SetActive(false);
30            startButton.gameObject.SetActive(true);
31        } else {
32            nextButton.SetActive(true);
33            startButton.gameObject.SetActive(false);
34        }
35        if(page == 0)
36        {
37            prevButton.SetActive(false);
38            backButton.gameObject.SetActive(true);
39        } else {
40            prevButton.SetActive(true);
41            backButton.gameObject.SetActive(false);
42        }
43
44    }
45
46    public void backToMenu()
47    {
48        Time.timeScale = 1;
49        SceneManager.LoadScene("Menu");
50    }
51
52    public void nextPage()
53    {
54        page++;
55        //Debug.Log((page - 1) + " => " + page);
56        showPage();
57    }
58
59    public void prevPage()
60    {
61        page--;
62        //Debug.Log((page + 1) + " => " + page);
63        showPage();
64    }
65
66    public void startGame()
67    {
68        Time.timeScale = 1;
69        GameMaster.Instance.resetGame();
70        SceneManager.LoadScene("Level0");
71    }
72    void Start()
73    {
74        Time.timeScale = 0;
75    }
76}