-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTEAM_RED_SCRIPT.cs
124 lines (109 loc) · 4.58 KB
/
TEAM_RED_SCRIPT.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//---------- CHANGE THIS NAME HERE -------
public class TEAM_RED_SCRIPT : MonoBehaviour
{
//private Vector3 position = new Vector3(20.0f, 0.0f, 20.0f);
/// <summary>
/// DO NOT MODIFY THIS!
/// vvvvvvvvv
/// </summary>
[SerializeField]
public CharacterScript character1;
[SerializeField]
public CharacterScript character2;
[SerializeField]
public CharacterScript character3;
/// <summary>
/// ^^^^^^^^
/// </summary>
///
// USEFUL VARIABLES
private ObjectiveScript middleObjective;
private ObjectiveScript leftObjective;
private ObjectiveScript rightObjective;
private float timer = 0;
private team ourTeamColor;
//---------- CHANGE THIS NAME HERE -------
public static TEAM_RED_SCRIPT AddYourselfTo(GameObject host)
{
//---------- CHANGE THIS NAME HERE -------
return host.AddComponent<TEAM_RED_SCRIPT>();
}
void Start()
{
// Set up code. This populates your characters with their controlling scripts
character1 = transform.Find("Character1").gameObject.GetComponent<CharacterScript>();
character2 = transform.Find("Character2").gameObject.GetComponent<CharacterScript>();
character3 = transform.Find("Character3").gameObject.GetComponent<CharacterScript>();
// populate the objectives
middleObjective = GameObject.Find("MiddleObjective").GetComponent<ObjectiveScript>();
leftObjective = GameObject.Find("LeftObjective").GetComponent<ObjectiveScript>();
rightObjective = GameObject.Find("RightObjective").GetComponent<ObjectiveScript>();
// save our team, changes every time
ourTeamColor = character1.getTeam();
//Makes gametimer call every second
InvokeRepeating("gameTimer", 0.0f, 1.0f);
}
void Update()
{
//Set caracter loadouts, can only happen when the characters are at base.
if (character1.getZone() == zone.BlueBase || character1.getZone() == zone.RedBase)
character1.setLoadout(loadout.LONG);
if (character2.getZone() == zone.BlueBase || character2.getZone() == zone.RedBase)
character2.setLoadout(loadout.LONG);
if (character2.getZone() == zone.BlueBase || character2.getZone() == zone.RedBase)
character3.setLoadout(loadout.LONG);
// in the first couple of seconds we just scan around
if (timer < 10)
{
character1.FaceClosestWaypoint();
character2.FaceClosestWaypoint();
character3.FaceClosestWaypoint();
character1.MoveChar(new Vector3(-8.8f, 1.5f, 13.5f));
}
// 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]));
}
// send other two to capture
if (middleObjective.getControllingTeam() != character1.getTeam())
{
character2.MoveChar(middleObjective.transform.position);
character2.SetFacing(middleObjective.transform.position);
character3.MoveChar(middleObjective.transform.position);
character3.SetFacing(middleObjective.transform.position);
}
else
{
// Then left
if (leftObjective.getControllingTeam() != character1.getTeam())
{
character2.MoveChar(leftObjective.transform.position);
character2.SetFacing(leftObjective.transform.position);
character3.MoveChar(leftObjective.transform.position);
character3.SetFacing(leftObjective.transform.position);
}
// Then RIght
if (rightObjective.getControllingTeam() != character1.getTeam())
{
character2.MoveChar(rightObjective.transform.position);
character2.SetFacing(rightObjective.transform.position);
character3.MoveChar(rightObjective.transform.position);
character3.SetFacing(rightObjective.transform.position);
}
}
}
// a simple function to track game time
public void gameTimer()
{
timer += 1;
}
}