-
Notifications
You must be signed in to change notification settings - Fork 1
/
UIMenuManager.cs
110 lines (98 loc) · 2.62 KB
/
UIMenuManager.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine;
using TMPro;
public class UIMenuManager : MonoBehaviour
{
public static UIMenuManager instance;
[Header("MainMenu Attribute")]
public int playerScore;
public int playerPlay;
public TextMeshProUGUI helloText;
public Text totalScoreText;
public Text totalPlayText;
public GameObject onlineChoice;
public GameObject quitChoice;
public bool touched = false;
[Header("HostJoin Attribute")]
public InputField codeRoom;
public TextMeshProUGUI notifText;
public string goToScene;
private void Awake()
{
if (instance == null)
instance = this;
else if (instance != this)
{
Debug.Log("Instance already exists, destroying object");
Destroy(this);
}
}
private void Start()
{
helloText.text = $"hello, {Client.instance.myUname} #{Client.instance.myId}";
//ClientSend.ScoreRequest(Client.instance.myUname);
}
private void Update()
{
if (Client.instance.isPlay)
SceneManager.LoadScene(goToScene);
totalScoreText.text = $"{Client.instance.myScore}";
totalPlayText.text = $"{Client.instance.myPlay}";
}
public void GameTest()
{
SceneManager.LoadScene("PropHunt");
}
public void ChooseOnline(int code)
{
if (!touched && code == 1)
{
onlineChoice.SetActive(true);
touched = true;
}
else if (touched)
{
onlineChoice.SetActive(false);
touched = false;
}
}
public void ChooseHost()
{
if (codeRoom.text != "")
{
ClientSend.HostRoomRequest(codeRoom.text);
RoomDatabase.instance.roomCode = codeRoom.text;
}
else
{
notifText.text = "please input the room code!";
}
}
public void ChooseJoin()
{
if (codeRoom.text != "")
{
ClientSend.JoinRoomRequest(codeRoom.text, Client.instance.myId, Client.instance.myUname);
RoomDatabase.instance.roomCode = codeRoom.text;
}
else
{
notifText.text = "please input the room code!";
}
}
public void ChooseQuit(int index)
{
if (index == 0)
quitChoice.SetActive(true);
else if (index == 1)
quitChoice.SetActive(false);
else if (index == 2)
{
Client.instance.Disconnect();
Application.Quit();
}
}
}