-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmarker.cs
304 lines (268 loc) · 11.1 KB
/
marker.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
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//---------- CHANGE THIS NAME HERE -------
public class marker : MonoBehaviour
{
public ObjectiveScript middleObjective;
public ObjectiveScript leftObjective;
public ObjectiveScript rightObjective;
public float timer = 0;
//---------- CHANGE THIS NAME HERE -------
public static marker AddYourselfTo(GameObject host) {
//---------- CHANGE THIS NAME HERE -------
return host.AddComponent<marker>();
}
/*vvvv DO NOT MODIFY vvvvv*/
[SerializeField]
public CharacterScript character1;
[SerializeField]
public CharacterScript character2;
[SerializeField]
public CharacterScript character3;
void Start()
{
// populate the objectives
middleObjective = GameObject.Find("MiddleObjective").GetComponent<ObjectiveScript>();
leftObjective = GameObject.Find("LeftObjective").GetComponent<ObjectiveScript>();
rightObjective = GameObject.Find("RightObjective").GetComponent<ObjectiveScript>();
character1 = transform.Find("Character1").gameObject.GetComponent<CharacterScript>();
character2 = transform.Find("Character2").gameObject.GetComponent<CharacterScript>();
character3 = transform.Find("Character3").gameObject.GetComponent<CharacterScript>();
}
/*^^^^ DO NOT MODIFY ^^^^*/
/* Your code below this line */
bool char1HasMoved = false;
bool inPosition = false;
// Update() is called every frame
void Update()
{
basicUpdate(character1);
basicUpdate(character2);
basicUpdate(character3);
Char1();
Char2();
Char3();
}
/*
* function for all charachter to run every turn
*/
void basicUpdate(CharacterScript character)
{
//Set caracter loadouts, can only happen when the characters are at base.
// in the first couple of seconds we just scan around
if (timer < 10)
{
character.FaceClosestWaypoint();
}
}
void Char1()
{
//set loadout
character1.MoveChar(leftObjective.transform.position);
if (character1.getZone() == zone.BlueBase || character1.getZone() == zone.RedBase)
{
character1.setLoadout(loadout.MEDIUM);
}
character1.FaceClosestWaypoint();
if(goToNearItem(character1)) {
}
else if (leftObjective.getControllingTeam() != character1.getTeam()) //changed from middleObjective to leftObjective
{
character1.MoveChar(leftObjective.transform.position);
character1.SetFacing(leftObjective.transform.position);
//Vector3 offset = new Vector3(10.0f,10.0f,10.0f);
//character1.FindClosestCover(offset);
//character1.MoveChar(leftObjective.transform.position + offset);
//character3.SetFacing(middleObjective.transform.position);
//finds closest cover regardless of whether it is attacked or not
//if(character1.attackedFromLocations.Count>0)
//character1.FindClosestCover(character1.attackedFromLocations[0]);
}
//if (character1.attackedFromLocations.Capacity == 0)
{
// character1.MoveChar(new Vector3(-8.8f, 1.5f, 13.5f));
// character1.SetFacing(leftObjective.transform.position);
}
//else
{
// //Vector3 bla = new Vector3(10.0f,10.0f,10.0f);
// character1.MoveChar(character1.FindClosestCover(visibleEnemyLocations));
}
//else {
// Vector3 offset = new Vector3(10.0f,10.0f,10.0f);
// character1.FindClosestCover(offset);
//Vector3 offset = new Vector3(10.0f,10.0f,10.0f);
//character1.MoveChar(leftObjective.transform.position + offset);
//character1.FindClosestCover(character1.attackedFromLocations[0]);
//}
/**if(character1.attackedFromLocations.Count>0)
{
character1.FindClosestCover(character1.attackedFromLocations[0]);
}
}
/*
// place sniper in position, run to cover if attacked
if (character1.attackedFromLocations.Capacity == 0)
{
character1.MoveChar(new Vector3(-8.8f, 1.5f, 13.5f));
character1.SetFacing(middleObjective.transform.position);
}
else
{
character1.MoveChar(character1.FindClosestCover(character1.attackedFromLocations[0]));
}
*/
/*depending on how close the enemy is either stops or continues rotating
foreach(Vector3 x in character1.visibleEnemyLocations)
{
if(Vector3.Distance(character1.getPrefabObject().transform.position, x)<5)
{
}
else {
character1.rotateAngle(120.0f);
character1.MoveChar(leftObjective.transform.position);
}
}
*/
}
void Char2()
{
//Debug.Log(rightObjective.getControllingTeam());
//sendToCapture(character2);
//character2.FaceClosestWaypoint();
//character2.MoveChar(middleObjective.transform.position);
if(goToNearItem(character2)) {
}
else if (rightObjective.getControllingTeam() != character2.getTeam())
{
character2.MoveChar(rightObjective.transform.position);
character2.SetFacing(rightObjective.transform.position);
}
/*
if (middleObjective.getControllingTeam() != character2.getTeam())
{
character2.MoveChar(middleObjective.transform.position);
character2.SetFacing(middleObjective.transform.position);
}
if ((rightObjective.getControllingTeam() == character2.getTeam()) & (rightObjective.getControllingTeam() == character2.getTeam()));
{
if(character2.attackedFromLocations.Count>0)
{
character2.FindClosestCover(character2.attackedFromLocations[0]);
}
character2.isDoneMoving();
}
*/
}
//Agresssive attacc Charachter
//bool clockwise = false;
void Char3()
{
if(!goToNearItem(character3)) {
if(character3.visibleEnemyLocations.Count>0) {
character3.MoveChar(character3.FindClosestCover(character3.visibleEnemyLocations[character3.visibleEnemyLocations.Count-1]));
character3.SetFacing(character3.visibleEnemyLocations[character3.visibleEnemyLocations.Count-1]);
} else {
Vector3 offset = new Vector3(-30.0f,0.0f,10.0f);
character3.MoveChar(middleObjective.transform.position+offset);
character3.rotateAngle(80.0f);
}
}
/*
if(character3.visibleEnemyLocations.Count>0) {
character3.FindClosestCover(character3.visibleEnemyLocations[character3.visibleEnemyLocations.Count-1]);
}
if(character3.visibleEnemyLocations.Count==0 && !inPosition) {
character3.rotateAngle(80.0f);
} else {
if(inPosition) {
//Vector3 offset = new Vector3(-30.0f,0.0f,10.0f);
character3.SetFacing(character3.getPrefabObject().transform.position+offset);
}
//Debug.Log(character3.visibleEnemyLocations.Count);
//character3.SetFacing(character3.visibleEnemyLocations[character3.visibleEnemyLocations.Count-1]);
}
if(goToNearItem(character3)) {
}
else {
Vector3 offset = new Vector3(0.0f,0.0f,20.0f);
character3.MoveChar(middleObjective.transform.position + offset);
if(Vector3.Distance(character3.getPrefabObject().transform.position,middleObjective.transform.position + offset)<2) {
//inPosition=true;
}
//character3.SetFacing(middleObjective.transform.position);
}
*/
}
void sendToCapture(CharacterScript character)
{
// send other two to capture
if (middleObjective.getControllingTeam() != character1.getTeam())
{
character.MoveChar(rightObjective.transform.position);
character.SetFacing(rightObjective.transform.position);
if (character.attackedFromLocations.Capacity != 0)
{
character.FindClosestCover(character.attackedFromLocations[0]);
}
}
else
{
// Then RIght
if (rightObjective.getControllingTeam() != character1.getTeam())
{
character.MoveChar(rightObjective.transform.position);
character.SetFacing(rightObjective.transform.position);
}
// Then left
if (leftObjective.getControllingTeam() != character1.getTeam())
{
character.MoveChar(leftObjective.transform.position);
character.SetFacing(leftObjective.transform.position);
}
}
}
bool goToNearItem(CharacterScript character) {
if(Vector3.Distance(character.getPrefabObject().transform.position, character.FindClosestItem().transform.position)<5)
{
character.MoveChar(character.FindClosestItem().transform.position);
character.SetFacing(character.FindClosestItem().transform.position);
return true;
}
return false;
}
}
/*
if (character1.getZone() == zone.BlueBase || character1.getZone() == zone.RedBase)
{
character1.setLoadout(loadout.SHORT);
}
character1.FaceClosestWaypoint();
if (middleObjective.getControllingTeam() != character1.getTeam())
{
character1.MoveChar(leftObjective.transform.position);
character1.SetFacing(leftObjective.transform.position);
character1.FindClosestCover(character1.attackedFromLocations[0]);
}
character1.isDoneMoving();
if (character1.getHP() <= 40)
{
character1.FindClosestItem();
}
if (rightObjective.getControllingTeam() != character2.getTeam())
{
character2.MoveChar(rightObjective.transform.position);
character2.SetFacing(rightObjective.transform.position);
}
if (middleObjective.getControllingTeam() != character.getTeam())
{
character2.MoveChar(middleObjective.transform.position);
character2.SetFacing(middleObjective.transform.position);
}
if ((rightObjective.getControllingTeam() = character2.getTeam()) & (rightObjective.getControllingTeam() = character2.getTeam()));
{
character2.FindClosestCover(character2.attackedFromLocations[0]);
character2.isDoneMoving();
}
*/