Added respawn for AI, Game manager keeps track of laps
This commit is contained in:
@@ -24,16 +24,40 @@ public class GameManager : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
foreach (GameObject player in players)
|
||||
for (int i = 0; i < players.Count(); i++)
|
||||
{
|
||||
try
|
||||
GameObject player = players[i];
|
||||
|
||||
bool isAI = true;
|
||||
if (player.GetComponent<PlayerController>().enabled)
|
||||
isAI = false;
|
||||
|
||||
if (isAI)
|
||||
{
|
||||
bool isFinished = player.GetComponent<AgentController>().isFinished;
|
||||
|
||||
if (isFinished)
|
||||
{
|
||||
player.GetComponent<AgentController>().isFinished = false;
|
||||
playerLaps[i] += 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int checkpointsCollected = player.GetComponent<PlayerController>().checkpointsCollected;
|
||||
|
||||
if (checkpointsCollected == checkpoints.Count())
|
||||
{
|
||||
player.GetComponent<PlayerController>().checkpointsCollected = 0;
|
||||
playerLaps[i] += 1;
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
||||
if (playerLaps[i] > lapAmount)
|
||||
{
|
||||
int checkpointsCollected = player.GetComponent<AgentController>().checkpointsCollected;
|
||||
player.GetComponent<Rigidbody>().isKinematic = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user