Commit 2fff6796 authored by Jonas's avatar Jonas

Score Calculation

parents 97452fe6 366cbe9f
......@@ -14,14 +14,12 @@ namespace _Game.Scripts.GameManager {
public Color color;
public bool isWinner;
public void Reset(string name, Color color, Role initRole) {
public void Reset(string name, Role initRole) {
this.name = name;
score = 0f;
scoreLastRound = 0f;
this.color = color;
isWinner = false;
role = initRole;
Debug.Log("Player Reset aufgerufen");
}
public void UpdateScore(float scoreNew)
......
......@@ -15,6 +15,13 @@ namespace _Game.Scripts.GameManager
[SerializeField] private Transform _handler1, _handler2;
private Transform _head, _body;
public enum PlayerIndex : int
{
Default = -1,
Player1 = 1,
Player2 = 2,
}
private void OnEnable()
{
SceneManager.sceneLoaded += OnSceneLoaded;
......@@ -36,7 +43,8 @@ namespace _Game.Scripts.GameManager
{
_head = GameObject.FindWithTag("HeadPlayer").transform;
_body = GameObject.FindWithTag("BodyPlayer").transform;
_handler1 = GameObject.FindWithTag("ControllHandler1").transform;
_handler2 = GameObject.FindWithTag("ControllHandler2").transform;
startDelay.Clear();
startDelay.Register(_handler1.GetComponent<ActiveController>().ActivateAllComponents);
......@@ -64,13 +72,17 @@ namespace _Game.Scripts.GameManager
print("Round End");
roundTime.StopCountdown = true;
UpdateScorePoints();
SwitchRolesOfPlayers(); // changes playerX.role in GameData
data.RoundsPlayed++;
print("Rounds Played = " + data.RoundsPlayed);
LoadCorrectScene();
}
private void LoadCorrectScene()
{
if (data.RoundsPlayed >= data.roundsToPlay)
{
print("Game Ends");
......@@ -87,8 +99,38 @@ namespace _Game.Scripts.GameManager
{
data.IsSwitched = true;
SceneManager.LoadScene("MainLevelSwitched");
}
}
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;
}
}
......@@ -129,37 +171,5 @@ namespace _Game.Scripts.GameManager
"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