private void UpdateShieldBar()
    {
        if (IsShieldSpawned && CurrentShieldPoints > 0)
        {
            ShieldBar.SetActive(true);
            BlueBar.NewValue = CurrentShieldPoints;
            ShieldText.text  = $"{CurrentShieldPoints} / {MaxShieldPoints}";

            UpdateShieldBarPosition();
        }
        else if (CurrentShieldPoints <= 0 && IsShieldSpawned)
        {
            ShieldBar.SetActive(false);
        }
        // Only instantiates a shield if ability is called
        else if (CurrentShieldPoints > 0)
        {
            IsShieldSpawned = true;
            ShieldBar       = Instantiate(ShieldBarPrefab);
            ShieldBar.transform.SetParent(HealthBarUIPanel.transform);
            BlueBar          = ShieldBar.GetComponentInChildren <PointsBar>();
            ShieldText       = ShieldBar.GetComponentInChildren <TMP_Text>();
            BlueBar.NewValue = CurrentShieldPoints;
            BlueBar.MaxValue = MaxShieldPoints;
            ShieldText.text  = $"{CurrentShieldPoints} / {MaxShieldPoints}";
        }
    }
Exemple #2
0
 void MakeInstance()
 {
     if (pointsBarInstance == null)
     {
         pointsBarInstance = this;
     }
 }
    public void CreateUIInstances()
    {
        if (gameObject.tag == "Player")
        {
            Shield      = Instantiate(ShieldPrefab);
            Shield.name = gameObject.name + " Shield";
            Shield.transform.SetParent(GameObject.Find("CombatEffects").transform);
            Shield.SetActive(false);
        }

        HealthBar = Instantiate(HealthBarPrefab);
        HealthBar.transform.SetParent(HealthBarUIPanel.transform);
        RedBar          = HealthBar.GetComponentInChildren <PointsBar>();
        HealthText      = HealthBar.GetComponentInChildren <TMP_Text>();
        RedBar.MaxValue = MaxHealthPoints;

        HideBarsUI();
    }