Exemplo n.º 1
0
    /// <summary>
    /// Handles the agent trigger collisions- passing the checkpoint or going through the starting line.
    /// </summary>
    /// <param name="other">The object the agent collided with.</param>
    void OnTriggerEnter(Collider other)
    {
        // The agent passed the checkpoint
        if (other.CompareTag("LapCheckpoint"))
        {
            passedCheckpoint = true;
        }

        // The agent went through the starting line
        if (other.CompareTag("StartingLine"))
        {
            // If the agent didn't pass the checkpoint,
            // it means that the agent is starting a new lap after a crash
            if (passedCheckpoint)
            {
                // Update the lap counter
                LapsMade++;
                UIManager.UpdateLapCount(this);

                // If the agent won, the game
                if (LapsMade == 2)
                {
                    raceManager.EndGame();
                }
            }

            // Reset passedCheckpoint status
            passedCheckpoint = false;
        }
    }