Commit 6de62506 authored by Jonas's avatar Jonas

GameHandler v2

parent 320b7c7d
......@@ -58,6 +58,9 @@ namespace _Game.Scripts.GameManager {
print("Round End");
roundTime.StopCountdown = true;
UpdateScorePoints();
SwitchRolesOfPlayers(); // changes playerX.role in GameData
data.RoundsPlayed++;
print("Rounds Played = " + data.RoundsPlayed);
......@@ -82,5 +85,75 @@ namespace _Game.Scripts.GameManager {
SceneManager.LoadScene("DelayTimer", LoadSceneMode.Additive);
}
}
private void UpdateScorePoints()
{
Debug.Log("Updated Scores");
if (data.player1.role == GameData.Role.Body)
{
// Punkte = [Punkte von letzter Runde] + ( [MaxRundenzeit] - [Noch Übrige Zeit] );
data.player1.UpdateScore(data.player1.scoreLastRound + data.roundTime - roundTime.CurrentTime);
}
else if (data.player1.role == GameData.Role.Head)
{
// Punkte = [Punkte von letzter Runde] + ( Rundenzeit ) - ( [ Rundenzeit ] - [ noch übrige Zeit ] ) )
data.player1.UpdateScore(data.player1.scoreLastRound +
((data.roundTime) - (data.roundTime - roundTime.CurrentTime)));
}
else
{
throw new UnityException(
"Can't update score of player 1 because he didn't does not have a role (Head or Body)");
}
if (data.player2.role == GameData.Role.Body)
{
// Punkte = [Punkte von letzter Runde] + ( [MaxRundenzeit] - [Noch Übrige Zeit] );
data.player2.UpdateScore(data.player2.scoreLastRound + data.roundTime - roundTime.CurrentTime);
}
else if (data.player2.role == GameData.Role.Head)
{
// Punkte = [Punkte von letzter Runde] + ( Rundenzeit ) - ( [ Rundenzeit ] - [ noch übrige Zeit ] ) )
data.player2.UpdateScore(data.player2.scoreLastRound +
((data.roundTime) - (data.roundTime - roundTime.CurrentTime)));
}
else
{
throw new UnityException(
"Can't update score of player 2 because he didn't does not have a role (Head or Body)");
}
}
void SwitchRolesOfPlayers()
{
Debug.Log("Switching Roles of Players");
switch (data.player1.role)
{
case GameData.Role.Body:
data.player1.role = GameData.Role.Head;
break;
case GameData.Role.Head:
data.player1.role = GameData.Role.Body;
break;
default:
throw new UnityException(
"Can't update roles of player 1 because he didn't does not have a role (Head or Body)");
break;
}
switch (data.player2.role)
{
case GameData.Role.Body:
data.player2.role = GameData.Role.Head;
break;
case GameData.Role.Head:
data.player2.role = GameData.Role.Body;
break;
default:
throw new UnityException(
"Can't update roles of player 2 because he didn't does not have a role (Head or Body)");
break;
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment