Exemple #1
0
 public static void Update(float max, float hp)
 {
     try
     {
         healthBarFast.SetMaxValue(max);
         healthBarFast.SetValue(hp);
         healthBarSlow.SetMaxValue(max);
         healthBarSlow.SetValue(hp);
         healthText.text = $"{Mathf.CeilToInt(hp)}/{Mathf.CeilToInt(max)}";
     }
     catch (Exception e)
     {
         Debug.LogError($"HealthBar.Update() {e.Message}");
     }
 }
Exemple #2
0
        public static GuiBar Awake(Hud __instance)
        {
            Transform hudroot = Utils.FindChild(__instance.gameObject.transform, "hudroot");
            GuiBar    xp_bar  = UnityEngine.Object.Instantiate(Hud.instance.m_stealthBar, hudroot, true);

            xp_bar.m_barImage    = Hud.instance.m_stealthBar.m_bar.GetComponent <Image>();
            xp_bar.m_smoothFill  = smoothFill;
            xp_bar.m_smoothDrain = smoothDrain;
            xp_bar.m_smoothSpeed = smoothSpeed;
            xp_bar.Awake();

            xp_bar.name            = "BU_XP_BAR";
            xp_bar.m_originalColor = barColor;
            xp_bar.ResetColor();

            xp_bar.SetMaxValue(maxValue);
            xp_bar.SetValue(0f);

            RectTransform xpRect = (xp_bar.transform as RectTransform);

            xpRect.anchorMin        = Vector2.zero;
            xpRect.anchorMax        = new Vector2(1f, 0f);
            xpRect.anchoredPosition = Vector2.zero;

            xpRect.offsetMin = Vector2.zero;
            xpRect.offsetMax = Vector2.zero;
            xpRect.sizeDelta = new Vector2(0f, 5f);

            xp_bar.m_bar.anchorMin = Vector2.zero;
            xp_bar.m_bar.anchorMax = new Vector2(1f, 0.5f);
            xp_bar.m_bar.offsetMin = Vector2.zero;
            xp_bar.m_bar.offsetMax = Vector2.zero;

            xp_bar.m_bar.sizeDelta = new Vector2(xpRect.rect.width, 5f);
            // Render the XP Bar
            xp_bar.gameObject.SetActive(true);
            _xp_bar = xp_bar;

            return(xp_bar);
        }