Ejemplo n.º 1
0
        public void EntityAdded(EntityWrapper entity)
        {
            Healthbar healthbarSettings = this.GetHealthbarSettings(entity);

            if (healthbarSettings != null)
            {
                this.healthBars[(int)healthbarSettings.prio].Add(healthbarSettings);
            }
        }
Ejemplo n.º 2
0
        private void EntityList_OnEntityAdded(Entity entity)
        {
            Healthbar healthbarSettings = this.GetHealthbarSettings(entity);

            if (healthbarSettings != null)
            {
                this.healthBars[(int)healthbarSettings.prio].Add(healthbarSettings);
            }
        }
Ejemplo n.º 3
0
        private void RenderHealthBar(RenderingContext rc, Poe.Camera camera, Healthbar current, float clientWidth, float clientHeight)
        {
            Vec3 worldCoords     = current.entity.Pos;
            Vec2 mobScreenCoords = camera.WorldToScreen(worldCoords.Translate(0f, 0f, -170f));

            // System.Diagnostics.Debug.WriteLine("{0} is at {1} => {2} on screen", current.entity.Path, worldCoords, mobScreenCoords);
            if (mobScreenCoords == Vec2.Empty)
            {
                return;
            }

            int   scaledWidth       = (int)(current.settings.Width * clientWidth);
            int   scaledHeight      = (int)(current.settings.Height * clientHeight);
            Color color             = current.settings.Color;
            Color color2            = current.settings.Outline;
            Color percentsTextColor = current.settings.PercentTextColor;
            float hpPercent         = current.entity.GetComponent <Life>().HPPercentage;
            float esPercent         = current.entity.GetComponent <Life>().ESPercentage;
            float hpWidth           = hpPercent * scaledWidth;
            float esWidth           = esPercent * scaledWidth;
            Rect  bg = new Rect(mobScreenCoords.X - scaledWidth / 2, mobScreenCoords.Y - scaledHeight / 2, scaledWidth,
                                scaledHeight);

            if (current.entity.IsHostile && hpPercent <= 0.1)
            // Set healthbar color to configured in settings.txt for hostiles when hp is <=10%
            {
                color = current.settings.Under10Percent;
            }
            // Draw healthbar
            this.DrawEntityHealthbar(color, color2, bg, hpWidth, esWidth, rc);

            // Draw percents or health text for hostiles. Configurable in settings.txt
            if (current.entity.IsHostile)
            {
                int    curHp = current.entity.GetComponent <Life>().CurHP;
                int    maxHp = current.entity.GetComponent <Life>().MaxHP;
                string monsterHpCorrectString = this.GetCorrectMonsterHealthString(curHp, maxHp);
                string hppercentAsString      = ((int)(hpPercent * 100)).ToString();
                Color  monsterHpTextColor     = (hpPercent <= 0.1)
                                        ? current.settings.HealthTextColorUnder10Percent
                                        : current.settings.HealthTextColor;

                if (current.settings.PrintPercents)
                {
                    this.DrawEntityHealthPercents(percentsTextColor, hppercentAsString, bg, rc);
                }
                if (current.settings.PrintHealthText)
                {
                    this.DrawEntityHealthbarText(monsterHpTextColor, monsterHpCorrectString, bg, rc);
                }
            }
        }
Ejemplo n.º 4
0
        private void RenderHealthBar(RenderingContext rc, Poe.Camera camera, Healthbar current, float clientWidth, float clientHeight)
        {
            Vec3 worldCoords = current.entity.Pos;
            Vec2 mobScreenCoords = camera.WorldToScreen(worldCoords.Translate(0f, 0f, -170f));
            // System.Diagnostics.Debug.WriteLine("{0} is at {1} => {2} on screen", current.entity.Path, worldCoords, mobScreenCoords);
            if (mobScreenCoords == Vec2.Empty) return;

            int scaledWidth = (int) (current.settings.Width*clientWidth);
            int scaledHeight = (int) (current.settings.Height*clientHeight);
            Color color = current.settings.Color;
            Color color2 = current.settings.Outline;
            Color percentsTextColor = current.settings.PercentTextColor;
            float hpPercent = current.entity.GetComponent<Life>().HPPercentage;
            float esPercent = current.entity.GetComponent<Life>().ESPercentage;
            float hpWidth = hpPercent*scaledWidth;
            float esWidth = esPercent*scaledWidth;
            Rect bg = new Rect(mobScreenCoords.X - scaledWidth/2, mobScreenCoords.Y - scaledHeight/2, scaledWidth,
                scaledHeight);
            if (current.entity.IsHostile && hpPercent <= 0.1)
                // Set healthbar color to configured in settings.txt for hostiles when hp is <=10%
            {
                color = current.settings.Under10Percent;
            }
            // Draw healthbar
            this.DrawEntityHealthbar(color, color2, bg, hpWidth, esWidth, rc);

            // Draw percents or health text for hostiles. Configurable in settings.txt
            if (current.entity.IsHostile)
            {
                int curHp = current.entity.GetComponent<Life>().CurHP;
                int maxHp = current.entity.GetComponent<Life>().MaxHP;
                string monsterHpCorrectString = this.GetCorrectMonsterHealthString(curHp, maxHp);
                string hppercentAsString = ((int) (hpPercent*100)).ToString();
                Color monsterHpTextColor = (hpPercent <= 0.1)
                    ? current.settings.HealthTextColorUnder10Percent
                    : current.settings.HealthTextColor;

                if (current.settings.PrintPercents)
                    this.DrawEntityHealthPercents(percentsTextColor, hppercentAsString, bg, rc);
                if (current.settings.PrintHealthText)
                    this.DrawEntityHealthbarText(monsterHpTextColor, monsterHpCorrectString, bg, rc);
            }
        }