private void SetTargetHUD() { myTargetHUD.Show(); myTarget.GetComponent <Health>().EventOnHealthChange += ChangeTargetHudHealth; ChangeTargetHudHealth(myTarget.GetComponent <Health>().GetHealthPercentage(), myTarget.GetComponent <Health>().myCurrentHealth.ToString() + "/" + myTarget.GetComponent <Health>().MaxHealth, myTarget.GetComponent <Health>().GetTotalShieldValue()); if (myTarget.GetComponent <Resource>() != null) { myTarget.GetComponent <Resource>().EventOnResourceChange += ChangeTargetHudResource; ChangeTargetHudResource(myTarget.GetComponent <Resource>().GetResourcePercentage(), myTarget.GetComponent <Resource>().myCurrentResource.ToString() + "/" + myTarget.GetComponent <Resource>().MaxResource); myTargetHUD.SetResourceBarColor(myTarget.GetComponent <Resource>().myResourceColor); } else { ChangeTargetHudResource(0.0f, "0/0"); } if (myTarget.tag == "Enemy") { myTargetHUD.SetName(myTarget.name); myTargetHUD.SetNameColor(Color.red); } else if (myTarget.tag == "Player") { if (myTarget.GetComponent <PlayerCharacter>() != null) { myTargetHUD.SetName(myTarget.GetComponent <PlayerCharacter>().Name); } myTargetHUD.SetNameColor(new Color(120f / 255f, 1.0f, 0.0f)); } }
private void ManualStart() { myHealth.EventOnHealthChange += ChangeMyHudHealth; myHealth.EventOnHealthZero += OnDeath; ChangeMyHudHealth(myHealth.GetHealthPercentage(), myHealth.myCurrentHealth.ToString() + "/" + myHealth.myMaxHealth.ToString(), GetComponent <Health>().GetTotalShieldValue()); myResource.EventOnResourceChange += ChangeMyHudResource; ChangeMyHudResource(myResource.GetResourcePercentage(), myResource.myCurrentResource.ToString() + "/" + myResource.MaxResource.ToString()); myClass.SetupSpellHud(CastSpell); myCharacterHUD.SetName(myName + " (" + myClass.myClassName + ")"); myCharacterHUD.Show(); }
public void SetFriendHud(PlayerList someConnectedPlayers) { if (!isLocalPlayer) { return; } myFriendList.Clear(); foreach (Transform child in myFriendList.gameObject.transform) { CmdUnsubscribe(child.gameObject); Destroy(child.gameObject); } for (int index = 0; index < someConnectedPlayers.Count; index++) { if (someConnectedPlayers[index].netId == myCharacter.GetComponent <NetworkIdentity>().netId) { continue; } GameObject player = ClientScene.FindLocalObject(someConnectedPlayers[index].netId); GameObject friend = Instantiate(myFriendList.myFriendlistHudPrefab, myFriendList.transform); friend.GetComponent <FriendHud>().SetCharacter(player); friend.GetComponent <FriendHud>().SetParent(myCharacter.GetComponent <PlayerCharacter>()); PlayerCharacter playerCharacter = player.GetComponent <PlayerCharacter>(); CharacterHUD hud = friend.GetComponent <CharacterHUD>(); hud.SetName(playerCharacter.Name); hud.SetHealthBarFillAmount(player.GetComponent <Health>().GetHealthPercentage()); myFriendList.AddHud(hud, someConnectedPlayers[index].netId, myCharacter.GetComponent <PlayerCharacter>().Name); CmdSubscribe(player); } }