Commit 50c74286 by Philipp Adolf

Initialize PlayerHealth from PlayerControl

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