예제 #1
0
 /// <summary>
 /// Tie this HUD to a player's PlayerStats.cs script to visualize the correct player
 /// </summary>
 /// <param name="playerStats"></param>
 public void SetPlayerStats(PlayerStats playerStats)
 {
     ps = playerStats;
     pl = playerStats.GetComponent<PlayerLogic>();
     playerNameText.text = "";
     pl.CmdWhatNumberAmI();
     // Turn off world-space healthBar
     ps.GetComponentInChildren<Canvas>().enabled = false;
     #region Abilities
     try {
         ability1.sprite = ps.abilities[0].Icon;
         actionBar.GetComponentsInChildren<Image>()[0].sprite = ps.abilities[0].Icon;
         ability2.sprite = ps.abilities[1].Icon;
         actionBar.GetComponentsInChildren<Image>()[2].sprite = ps.abilities[1].Icon;
         ability3.sprite = ps.abilities[2].Icon;
         actionBar.GetComponentsInChildren<Image>()[4].sprite = ps.abilities[2].Icon;
         SetTooltips();
     } catch { Debug.Log("Actionbar (automatic) setup for abilities failed.."); }
     #endregion
     #region Inventory
     //Activate Inventory GO
     inventory.gameObject.SetActive(true);
     //Set count status text
     inventory.transform.FindChild("Banana").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().bananaCount;
     inventory.transform.FindChild("Stick").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().stickCount;
     inventory.transform.FindChild("Sap").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().stickCount;
     inventory.transform.FindChild("Leaf").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().stickCount;
     inventory.transform.FindChild("BerryR").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().berryRCount;
     inventory.transform.FindChild("BerryG").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().berryGCount;
     inventory.transform.FindChild("BerryB").GetComponentInChildren<Text>().text = "" + inventory.GetComponent<Inventory>().berryBCount;
     #endregion
     // TODO: Do stuff with setting up correct ability images
     SetCursorState(true);
     if (miniMap) foreach (MinimapBlip mmb in miniMap.GetComponentsInChildren<MinimapBlip>()) Destroy(mmb.gameObject); //Removes previous icons if players reconnect (important when they swap teams)
     SetupMiniMap(playerStats.transform);
 }