-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaming.cs
More file actions
252 lines (210 loc) · 6.35 KB
/
Taming.cs
File metadata and controls
252 lines (210 loc) · 6.35 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Taming : MonoBehaviour {
public GameObject gameManager;
public TamingPetList petList;
public GameObject help_text;
public GameObject screenfade;
public GameObject[] areas;
public GameObject petnameChange;
public GameObject buttons;
public GameObject interactMenu;
public Text textTame;
SceneSwitch scene;
ScreenFade fade;
Player_party plist;
private Text change;
private bool waitDelay = true;
public int i;
public int tamingPercentage = 30;
public int playerState = 1;
public int petFightBack;
public int playerAction = 0;
public bool tameSuccess = false;
public bool run;
// Use this for initialization
void Start () {
petList = FindObjectOfType<TamingPetList>();
gameManager = GameObject.FindGameObjectWithTag("GameManager");
change = help_text.GetComponent<Text>();
scene = gameManager.GetComponent<SceneSwitch>();
fade = screenfade.GetComponent<ScreenFade>();
plist = gameManager.GetComponent<Player_party>();
petnameChange.SetActive(false);
buttons.SetActive(true);
fade.FadeToClear();
if (scene.areaNum == 1)
Instantiate(areas[0]);
else if (scene.areaNum == 6)
Instantiate(areas[2]);
StartCoroutine(TimeDelay(0.5f));
}
// Update is called once per frame
void Update () {
if (playerState == 1)//players turn
{
}
else if (playerState == 0)//pets turn
{
petFightBack = RandomNumber(1, 10);
if (petFightBack == 1)
{
change.text = "The monster accepts your action";
}
else if (petFightBack == 2)
{
change.text = "The monster lets out a shriek";
tamingPercentage -= 20;
}
else if (petFightBack == 3 && playerAction == 1)
{
change.text = "The monster enjoys the food";
}
else if (petFightBack == 4 && playerAction == 2)
{
change.text = "The monster smacks its tail on the ground";
}
else if (petFightBack == 5)
{
change.text = "The monster breathes heavily...";
tamingPercentage -= 20;
}
else if (petFightBack == 6 && playerAction == 3)
{
change.text = "The monster accepts your respect";
}
else if (petFightBack == 7 && playerAction == 3)
{
change.text = "The monster is insulted by your respectful action";
tamingPercentage -= 40;
}
else if (petFightBack == 8)
{
change.text = "The monster just stares at you";
tamingPercentage -= 20;
}
else if (petFightBack == 9)
{
change.text = "The monster lays its head down";
}
else if (petFightBack == 10 && tamingPercentage <= 20)
{
change.text = "The monster charges at you";
StartCoroutine(TimeDelay(1.0f));
textTame.text = "";
Destroy(petList.clones);
run = true;
}
else
{
change.text = "Your action didn't get the attention of the monster";
tamingPercentage -= 30;
}
playerState = 1;
}
textTame.text = "Taming " + tamingPercentage + "%";
if (tameSuccess == true)
{
for (i = 0; i < 8; i++)
{
if (plist.party_clones[i] == null)
{
petList.clones.GetComponent<SpriteRenderer>().flipX = false;
plist.party_clones[i] = petList.clones;
break;
}
}
scene.SceneLoad("World");
}
else if (run == true)
{
change.text = "You ran from the Monster";
StartCoroutine(TimeDelay(2.0f));
scene.SceneLoad("World");
}
}
public void Tame()
{
if (tamingPercentage >= 90)
{
change.text = "You have tamed " + petList.clones.GetComponent<Pets_stats>().petname + ". Congratulations! ";
petnameChange.SetActive(true);
buttons.SetActive(false);
}
if (tamingPercentage < 30)
{
change.text = "You failed to tame and the monster is angry";
playerState = 0;
}
else if (tamingPercentage < 50)
{
change.text = "You failed to tame and the monster is timid";
playerState = 0;
}
else if (tamingPercentage < 70)
{
change.text = "You failed to tame and the monster is discouraged";
playerState = 0;
}
else if (tamingPercentage < 90)
{
change.text = "You failed to tame, but the monster is calm";
playerState = 0;
}
}
public void Interact()
{
if (interactMenu.active == true)
interactMenu.SetActive(false);
else
interactMenu.SetActive(true);
}
public void Feed()
{
tamingPercentage += 30;
playerAction = 1;
playerState = 0;
}
public void Fight()
{
tamingPercentage += 30;
playerAction = 2;
playerState = 0;
}
public void Respect()
{
tamingPercentage += 30;
playerAction = 3;
playerState = 0;
}
public void Wait()
{
tamingPercentage += 30;
playerAction = 4;
playerState = 0;
}
public void petName(string newPetname)
{
petList.clones.GetComponent<Pets_stats>().petname = newPetname;
tameSuccess = true;
}
public void isRun()
{
textTame.text = "";
Destroy(petList.clones);
run = true;
}
int RandomNumber(int min, int max)
{
int randNum;
randNum = Random.Range(min, max);
return randNum;
}
IEnumerator TimeDelay(float timedelay)
{
waitDelay = true;
yield return new WaitForSeconds(timedelay);
waitDelay = false;
}
}