-
Notifications
You must be signed in to change notification settings - Fork 0
/
AgentControls.cs
136 lines (113 loc) · 2.81 KB
/
AgentControls.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
using UdonSharp;
using UnityEngine;
using UnityEngine.UI;
using VRC.SDKBase;
using VRC.Udon;
[AddComponentMenu("")]
public class AgentControls : UdonSharpBehaviour
{
public Manager manager;
[UdonSynced]
public bool isEnabled;
private int hintNumber;
private int card;
private string teamName;
public void Setup(string team)
{
Debug.Log("Setting up agent");
this.teamName = team;
this.reset();
}
public void Teardown()
{
this.reset();
}
public void StartTurn(int hints)
{
Debug.Log("Starting agent turn: " + teamName);
this.hintNumber = hints;
this.isEnabled = true;
this.updateText();
manager.UpdateCursor(this.card);
}
public void EndTurn()
{
Debug.Log("Ending agent turn: " + teamName);
this.reset();
this.manager.DestroyCursor();
}
public void SelectCard()
{
if (this.isEnabled == false)
{
return;
}
bool isCardSelected = this.manager.IsCardSelected(this.card);
if (isCardSelected == false)
{
Debug.Log(this.teamName + " agent: Card already selected");
return;
}
Debug.Log(this.teamName + " agent: Card selected");
this.hintNumber = this.hintNumber - 1;
this.updateText();
this.manager.SelectCard(this.card);
}
public void ContinueTurn()
{
if (this.hintNumber < 0)
{
this.manager.AgentEndTurn();
}
}
public void IncrementCard()
{
if (this.isEnabled == false)
{
return;
}
Debug.Log("Incremented card");
if (this.card >= 24)
{
this.card = 0;
}
else
{
this.card = this.card + 1;
}
Debug.Log("New cursor location: " + this.card);
this.manager.UpdateCursor(this.card);
}
public void DecrementCard()
{
if (this.isEnabled == false)
{
return;
}
if (this.card <= 0)
{
this.card = 24;
}
else
{
this.card = this.card - 1;
}
Debug.Log("New cursor location: " + this.card);
this.manager.UpdateCursor(this.card);
}
private void stopTurn()
{
this.isEnabled = false;
this.manager.AgentEndTurn();
}
private void reset()
{
this.card = 0;
this.hintNumber = 0;
this.isEnabled = false;
}
private void updateText()
{
manager.UpdateText("It's the " + this.teamName + " agent's turn! Hints remaining: " + this.hintNumber);
}
}