Exemplo n.º 1
0
        private static void UpdateHP(ref EnemyHud __instance, Player player, float dt)
        {
            if (!Main.customEnemyHud.Value)
            {
                return;
            }

            Character character = null;

            foreach (KeyValuePair <Character, EnemyHud.HudData> keyValuePair in __instance.m_huds)
            {
                EnemyHud.HudData value = keyValuePair.Value;
                if (!value.m_character || !__instance.TestShow(value.m_character))
                {
                    if (character == null)
                    {
                        character = value.m_character;
                        Object.Destroy(value.m_gui);
                    }
                }
                else
                {
                    if (value.m_character.IsPlayer())
                    {
                        // Currently no edits to player
                    }
                    else if (value.m_character.IsBoss())
                    {
                        if (!Main.hideEnemyHPText.Value)
                        {
                            Utils.FindChild(value.m_name.transform.parent, _bossHPPrefix).GetComponent <Text>().text = $"<size={_bossHPFontSize}>{Mathf.CeilToInt(value.m_character.GetHealth())} / {value.m_character.GetMaxHealth():0}</size>";
                        }
                    }
                    else
                    {
                        value.m_alerted.gameObject.SetActive(false);
                        value.m_aware.gameObject.SetActive(false);

                        bool aware   = value.m_character.GetBaseAI().HaveTarget();
                        bool alerted = value.m_character.GetBaseAI().IsAlerted();
                        value.m_name.color = (aware || alerted) ? (alerted ? Color.red : Color.yellow) : Color.white;

                        if (!Main.hideEnemyHPText.Value)
                        {
                            Utils.FindChild(value.m_name.transform.parent, _hpPrefix).GetComponent <Text>().text = $"<size={_hpFontSize}>{Mathf.CeilToInt(value.m_character.GetHealth())}/{value.m_character.GetMaxHealth():0}</size>";
                        }

                        if (Main.enemyLvlStyle.Value == 1)
                        {
                            value.m_level2.gameObject.SetActive(false);
                            value.m_level3.gameObject.SetActive(false);
                        }
                    }
                }
            }
            if (character != null)
            {
                __instance.m_huds.Remove(character);
            }
        }
Exemplo n.º 2
0
    // Token: 0x060004E4 RID: 1252 RVA: 0x00028744 File Offset: 0x00026944
    private void ShowHud(Character c)
    {
        EnemyHud.HudData hudData;
        if (this.m_huds.TryGetValue(c, out hudData))
        {
            return;
        }
        GameObject original;

        if (c.IsPlayer())
        {
            original = this.m_baseHudPlayer;
        }
        else if (c.IsBoss())
        {
            original = this.m_baseHudBoss;
        }
        else
        {
            original = this.m_baseHud;
        }
        hudData             = new EnemyHud.HudData();
        hudData.m_character = c;
        hudData.m_ai        = c.GetComponent <BaseAI>();
        hudData.m_gui       = UnityEngine.Object.Instantiate <GameObject>(original, this.m_hudRoot.transform);
        hudData.m_gui.SetActive(true);
        hudData.m_healthRoot = hudData.m_gui.transform.Find("Health").gameObject;
        hudData.m_healthFast = hudData.m_healthRoot.transform.Find("health_fast").GetComponent <GuiBar>();
        hudData.m_healthSlow = hudData.m_healthRoot.transform.Find("health_slow").GetComponent <GuiBar>();
        hudData.m_level2     = (hudData.m_gui.transform.Find("level_2") as RectTransform);
        hudData.m_level3     = (hudData.m_gui.transform.Find("level_3") as RectTransform);
        hudData.m_alerted    = (hudData.m_gui.transform.Find("Alerted") as RectTransform);
        hudData.m_aware      = (hudData.m_gui.transform.Find("Aware") as RectTransform);
        hudData.m_name       = hudData.m_gui.transform.Find("Name").GetComponent <Text>();
        hudData.m_name.text  = Localization.instance.Localize(c.GetHoverName());
        this.m_huds.Add(c, hudData);
    }
Exemplo n.º 3
0
    // Token: 0x060004E5 RID: 1253 RVA: 0x000288F0 File Offset: 0x00026AF0
    private void UpdateHuds(Player player, float dt)
    {
        Camera mainCamera = Utils.GetMainCamera();

        if (!mainCamera)
        {
            return;
        }
        Character y = player ? player.GetHoverCreature() : null;

        if (player)
        {
            player.IsCrouching();
        }
        Character character = null;

        foreach (KeyValuePair <Character, EnemyHud.HudData> keyValuePair in this.m_huds)
        {
            EnemyHud.HudData value = keyValuePair.Value;
            if (!value.m_character || !this.TestShow(value.m_character))
            {
                if (character == null)
                {
                    character = value.m_character;
                    UnityEngine.Object.Destroy(value.m_gui);
                }
            }
            else
            {
                if (value.m_character == y)
                {
                    value.m_hoverTimer = 0f;
                }
                value.m_hoverTimer += dt;
                float healthPercentage = value.m_character.GetHealthPercentage();
                if (value.m_character.IsPlayer() || value.m_character.IsBoss() || value.m_hoverTimer < this.m_hoverShowDuration)
                {
                    value.m_gui.SetActive(true);
                    int level = value.m_character.GetLevel();
                    if (value.m_level2)
                    {
                        value.m_level2.gameObject.SetActive(level == 2);
                    }
                    if (value.m_level3)
                    {
                        value.m_level3.gameObject.SetActive(level == 3);
                    }
                    if (!value.m_character.IsBoss() && !value.m_character.IsPlayer())
                    {
                        bool flag  = value.m_character.GetBaseAI().HaveTarget();
                        bool flag2 = value.m_character.GetBaseAI().IsAlerted();
                        value.m_alerted.gameObject.SetActive(flag2);
                        value.m_aware.gameObject.SetActive(!flag2 && flag);
                    }
                }
                else
                {
                    value.m_gui.SetActive(false);
                }
                value.m_healthSlow.SetValue(healthPercentage);
                value.m_healthFast.SetValue(healthPercentage);
                if (!value.m_character.IsBoss() && value.m_gui.activeSelf)
                {
                    Vector3 position = Vector3.zero;
                    if (value.m_character.IsPlayer())
                    {
                        position = value.m_character.GetHeadPoint() + Vector3.up * 0.3f;
                    }
                    else
                    {
                        position = value.m_character.GetTopPoint();
                    }
                    Vector3 vector = mainCamera.WorldToScreenPoint(position);
                    if (vector.x < 0f || vector.x > (float)Screen.width || vector.y < 0f || vector.y > (float)Screen.height || vector.z > 0f)
                    {
                        value.m_gui.transform.position = vector;
                        value.m_gui.SetActive(true);
                    }
                    else
                    {
                        value.m_gui.SetActive(false);
                    }
                }
            }
        }
        if (character != null)
        {
            this.m_huds.Remove(character);
        }
    }
Exemplo n.º 4
0
        private static void PatchName(ref EnemyHud __instance, ref Character c)
        {
            if (!Main.customEnemyHud.Value)
            {
                return;
            }

            EnemyHud.HudData hudData;
            if (__instance.m_huds.TryGetValue(c, out _))
            {
                return;
            }

            GameObject original;

            if (c.IsPlayer())
            {
                original = __instance.m_baseHudPlayer;
            }
            else if (c.IsBoss())
            {
                original = __instance.m_baseHudBoss;
            }
            else
            {
                original = __instance.m_baseHud;
            }

            hudData = new EnemyHud.HudData
            {
                m_character = c,
                m_ai        = c.GetComponent <BaseAI>(),
                m_gui       = Object.Instantiate(original, __instance.m_hudRoot.transform)
            };

            hudData.m_gui.SetActive(true);
            hudData.m_healthRoot = hudData.m_gui.transform.Find("Health").gameObject;
            hudData.m_healthFast = hudData.m_healthRoot.transform.Find("health_fast").GetComponent <GuiBar>();
            hudData.m_healthSlow = hudData.m_healthRoot.transform.Find("health_slow").GetComponent <GuiBar>();
            hudData.m_level2     = (hudData.m_gui.transform.Find("level_2") as RectTransform);
            hudData.m_level3     = (hudData.m_gui.transform.Find("level_3") as RectTransform);
            hudData.m_alerted    = (hudData.m_gui.transform.Find("Alerted") as RectTransform);
            hudData.m_aware      = (hudData.m_gui.transform.Find("Aware") as RectTransform);
            hudData.m_name       = hudData.m_gui.transform.Find("Name").GetComponent <Text>();
            hudData.m_name.text  = Localization.instance.Localize(c.GetHoverName());

            if (c.IsPlayer())
            {
                // Currently no edits to player
            }
            else if (c.IsBoss())
            {
                if (!Main.hideEnemyHPText.Value)
                {
                    // Edits to Boss HP Bar
                    Text hpText = Object.Instantiate(hudData.m_name, hudData.m_name.transform.parent);
                    hpText.name = _bossHPPrefix;
                    hpText.rectTransform.anchoredPosition = new Vector2(hpText.rectTransform.anchoredPosition.x, 0.0f); // orig.y = 21f
                    hpText.text  = $"<size={_bossHPFontSize}>{hudData.m_character.GetHealth():0} / {hudData.m_character.GetMaxHealth():0}</size>";
                    hpText.color = Color.white;
                    Object.Destroy(hpText.GetComponent <Outline>());
                }
            }
            else
            {
                hudData.m_name.fontSize = Main.enemyHudTextSize.Value;
                if (Main.enemyLvlStyle.Value != 0)
                {
                    hudData.m_name.text = hudData.m_name.text.Insert(0, $"<size={Main.enemyHudTextSize.Value - 2}><color=white>Lv.{c.m_level} </color></size> ");
                }
                if (!Main.hideEnemyHPText.Value)
                {
                    Text hpText = Object.Instantiate(hudData.m_name, hudData.m_name.transform.parent);
                    hpText.name = _hpPrefix;
                    hpText.rectTransform.anchoredPosition = new Vector2(hpText.rectTransform.anchoredPosition.x, 7.0f); // orig.y = 21f
                    hpText.text  = $"<size={_hpFontSize}>{hudData.m_character.GetHealth():0}/{hudData.m_character.GetMaxHealth():0}</size>";
                    hpText.color = Color.white;
                    Object.Destroy(hpText.GetComponent <Outline>());
                }

                // Resize and position everything
                RectTransform hpRoot    = (hudData.m_healthRoot.transform as RectTransform);
                Vector2       biggerBar = new Vector2(hpRoot.sizeDelta.x, hpRoot.sizeDelta.y * 3f);
                hpRoot.sizeDelta = biggerBar;
                hudData.m_alerted.gameObject.SetActive(false);
                hudData.m_aware.gameObject.SetActive(false);
                hudData.m_healthFast.m_bar.sizeDelta = new Vector2(hudData.m_healthFast.m_width, hpRoot.sizeDelta.y);
                hudData.m_healthSlow.m_bar.sizeDelta = new Vector2(hudData.m_healthSlow.m_width, hpRoot.sizeDelta.y);

                if (Main.enemyLvlStyle.Value == 1)
                {
                    hudData.m_level2.gameObject.SetActive(false);
                    hudData.m_level3.gameObject.SetActive(false);
                }
            }
            __instance.m_huds.Add(c, hudData);
        }