public void endGame()
{
// find the highest scoring player, add conditions for a tie.
StartCoroutine(restartWorld());
int winningIndex = 0;
for(int i = 1; i < scoreSystem.Length; i++)
{
if(scoreSystem[i].playerScore > scoreSystem[winningIndex].playerScore)
{
winningIndex = i;
}
else if(scoreSystem[i].playerScore == scoreSystem[winningIndex].playerScore)
{
print ("There was a tie!");
gameEndText.text = "There was a tie!";
Rpc_showWin(gameEndText.text);
return;
}
}
print ("Player: " + (winningIndex + 1) + " has won the game");
gameEndText.text = "Player: " + (winningIndex + 1) + " has won the game";
Rpc_showWin(gameEndText.text);
}