Commit 50c74286 by Philipp Adolf

Initialize PlayerHealth from PlayerControl

parent f2431858
...@@ -68,6 +68,8 @@ public class PlayerControl : MonoBehaviour ...@@ -68,6 +68,8 @@ public class PlayerControl : MonoBehaviour
{ {
this.playerNumber = playerNumber; this.playerNumber = playerNumber;
GetComponent<PlayerHealth>().init(playerNumber);
switch (playerNumber) switch (playerNumber)
{ {
case 1: case 1:
......
...@@ -13,13 +13,9 @@ public class PlayerHealth : MonoBehaviour { ...@@ -13,13 +13,9 @@ public class PlayerHealth : MonoBehaviour {
private GameStateTracker gameStateTracker; private GameStateTracker gameStateTracker;
private bool hasShield = false; private bool hasShield = false;
public void init(int playerNumber)
void Start()
{ {
gameStateTracker = GameObject.Find("GameMaster").GetComponent<GameStateTracker>(); //warning: geht kaputt wenn der name "Game Master" sich aendert. string healthbarName = "HealthBar" + playerNumber;
playerControl = gameObject.GetComponent<PlayerControl>();
string healthbarName = "HealthBar" + playerControl.playerNumber.ToString();
healthbar = GameObject.Find(healthbarName).GetComponent<Scrollbar>(); healthbar = GameObject.Find(healthbarName).GetComponent<Scrollbar>();
if (name.EndsWith("(Clone)")) if (name.EndsWith("(Clone)"))
......
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