// Show all monsters but highlight only target
 private void ShowAllButFocusTarget()
 {
     if (this.Context != null && this.Context.IsAlive)
     {
         this.Visibility = Visibility.Visible;
     }
     else
     {
         this.Visibility = Visibility.Collapsed;
     }
     if (!Context.IsTarget)
     {
         this.Width = 240;
         // Parts
         MonsterAilmentsContainer.ItemWidth = (this.Width - 2) / 2;
         MonsterPartsContainer.ItemWidth    = (this.Width - 2) / 2;
         UpdatePartHealthBarSizes(MonsterPartsContainer.ItemWidth);
         // Monster Bar
         MonsterHealthBar.MaxSize = this.Width * 0.8;
         MonsterHealthBar.UpdateBar(Context.CurrentHP, Context.TotalHP);
         this.Opacity = 0.5;
     }
     else
     {
         this.Width = 320;
         // Parts
         MonsterAilmentsContainer.ItemWidth = (this.Width - 2) / 2;
         MonsterPartsContainer.ItemWidth    = (this.Width - 2) / 2;
         UpdatePartHealthBarSizes(MonsterPartsContainer.ItemWidth);
         // Monster Bar
         MonsterHealthBar.MaxSize = this.Width * 0.8;
         MonsterHealthBar.UpdateBar(Context.CurrentHP, Context.TotalHP);
         this.Opacity = 1;
     }
 }
        private void UpdateMonsterInfo(Monster Monster)
        {
            // Used when starting HunterPie for the first time, since the events won't be triggered
            this.Visibility       = Visibility.Visible;
            this.MonsterName.Text = Monster.Name;

            // Update monster health

            MonsterHealthBar.MaxSize = this.Width * 0.7833333333333333;
            MonsterHealthBar.UpdateBar(Monster.CurrentHP, Monster.TotalHP);
            SetMonsterHealthBarText(Monster.CurrentHP, Monster.TotalHP);

            // Gets monster icon
            MonsterIcon.Source = GetMonsterIcon(Monster.ID);

            SwitchSizeBasedOnTarget();

            // Parts
            this.MonsterPartsContainer.Children.Clear();
            foreach (Part mPart in Monster.Parts)
            {
                Monster_Widget.Parts.MonsterPart PartDisplay = new Monster_Widget.Parts.MonsterPart()
                {
                    Style = FindResource("OVERLAY_MONSTER_PART_BAR_STYLE") as Style
                };
                PartDisplay.SetContext(mPart, this.MonsterPartsContainer.ItemWidth);
                this.MonsterPartsContainer.Children.Add(PartDisplay);
            }

            // Enrage
            if (Monster.IsEnraged)
            {
                ANIM_ENRAGEDICON.Begin(this.MonsterHealthBar, true);
                ANIM_ENRAGEDICON.Begin(this.HealthBossIcon, true);
                EnrageTimerText.Visibility = Visibility.Visible;
                EnrageTimerText.Text       = $"{Monster.EnrageTimerStatic - Monster.EnrageTimer:0}s";
            }

            // Set monster crown
            this.MonsterCrown.Source     = Monster.Crown == null ? null : (ImageSource)FindResource(Monster.Crown);
            this.MonsterCrown.Visibility = Monster.Crown == null ? Visibility.Collapsed : Visibility.Visible;
            Weaknesses.Children.Clear(); // Removes every weakness icon
            if (Monster.Weaknesses == null)
            {
                return;
            }
            foreach (string Weakness in Monster.Weaknesses.Keys)
            {
                ImageSource img = this.Resources[Weakness] as ImageSource;
                img.Freeze();
                WeaknessDisplay MonsterWeaknessDisplay = new WeaknessDisplay {
                    Icon   = img,
                    Width  = 20,
                    Height = 20
                };
                Weaknesses.Children.Add(MonsterWeaknessDisplay);
            }
        }
Exemple #3
0
 private void ChangeBarsSizes(double NewSize)
 {
     // Parts
     MonsterPartsContainer.MaxWidth  = MonsterAilmentsContainer.MaxWidth = (NewSize - 2) / 2;
     MonsterPartsContainer.ItemWidth = MonsterAilmentsContainer.ItemWidth = MonsterPartsContainer.MaxWidth / Math.Max(1, UserSettings.PlayerConfig.Overlay.MonstersComponent.MaxPartColumns);
     UpdatePartHealthBarSizes(MonsterPartsContainer.ItemWidth);
     // Monster Bar
     MonsterHealthBar.MaxSize  = NewSize - 69;
     MonsterStaminaBar.MaxSize = NewSize - 72;
     MonsterHealthBar.UpdateBar(Context.CurrentHP, Context.TotalHP);
     MonsterStaminaBar.UpdateBar(Context.Stamina, Context.MaxStamina);
 }
Exemple #4
0
 private void ChangeBarsSizes(double NewSize)
 {
     UserSettings.Config.Monsterscomponent config = UserSettings.PlayerConfig.Overlay.MonstersComponent;
     // Parts
     MonsterPartsContainer.MaxWidth    = config.EnableMonsterAilments ? (NewSize - 2) / 2 : (NewSize - 1);
     MonsterAilmentsContainer.MaxWidth = config.EnableMonsterParts || config.EnableRemovableParts ? (NewSize - 2) / 2 : (NewSize - 1);
     UpdateContainerBarsSizeDynamically();
     // Monster Bar
     MonsterHealthBar.MaxSize  = NewSize - 69;
     MonsterStaminaBar.MaxSize = NewSize - 72;
     MonsterHealthBar.UpdateBar(Context.Health, Context.MaxHealth);
     MonsterStaminaBar.UpdateBar(Context.Stamina, Context.MaxStamina);
 }
 private void ChangeBarsSizes(double NewSize)
 {
     UserSettings.Config.Monsterscomponent config = UserSettings.PlayerConfig.Overlay.MonstersComponent;
     // Parts
     MonsterPartsContainer.MaxWidth    = config.EnableMonsterAilments ? (NewSize - 2) / 2 : (NewSize - 1);
     MonsterAilmentsContainer.MaxWidth = config.EnableMonsterParts ? (NewSize - 2) / 2 : (NewSize - 1);
     MonsterPartsContainer.ItemWidth   = MonsterAilmentsContainer.ItemWidth = MonsterPartsContainer.MaxWidth / Math.Max(1, UserSettings.PlayerConfig.Overlay.MonstersComponent.MaxPartColumns);
     UpdateContainerBarsSizeDynamically();
     // Monster Bar
     MonsterHealthBar.MaxSize  = NewSize - 69;
     MonsterStaminaBar.MaxSize = NewSize - 72;
     MonsterHealthBar.UpdateBar(Context.CurrentHP, Context.TotalHP);
     MonsterStaminaBar.UpdateBar(Context.Stamina, Context.MaxStamina);
 }
 // Only show one monster
 private void ShowOnlyTargetMonster()
 {
     if (Context == null || !Context.IsTarget)
     {
         this.Visibility = Visibility.Collapsed;
     }
     else
     {
         this.Visibility = Visibility.Visible;
         this.Width      = 500;
         MonsterAilmentsContainer.ItemWidth = (this.Width - 2) / 2;
         MonsterPartsContainer.ItemWidth    = (this.Width - 2) / 2;
         UpdatePartHealthBarSizes(MonsterPartsContainer.ItemWidth);
         this.Opacity             = 1;
         MonsterHealthBar.MaxSize = this.Width * 0.9;
         MonsterHealthBar.UpdateBar(Context.CurrentHP, Context.TotalHP);
     }
 }
 // Show all monsters at once
 private void ShowAllMonstersAtOnce()
 {
     if (this.Context != null && this.Context.IsAlive)
     {
         this.Visibility = Visibility.Visible;
     }
     else
     {
         this.Visibility = Visibility.Collapsed;
     }
     this.Width = 300;
     MonsterAilmentsContainer.ItemWidth = (this.Width - 2) / 2;
     MonsterPartsContainer.ItemWidth    = (this.Width - 2) / 2;
     UpdatePartHealthBarSizes(MonsterPartsContainer.ItemWidth);
     MonsterHealthBar.MaxSize = 231;
     MonsterHealthBar.UpdateBar(Context.CurrentHP, Context.TotalHP);
     this.Opacity = 1;
 }
Exemple #8
0
    public void TakeDamage(float damage, Transform source)
    {
        if (health == maxHealth && damage > 0f)
        {
            MonsterHealthBar mhb = ((GameObject)Instantiate(Global.instance.monsterHealthBar, transform.GetComponentInParent <LRScreen> ().UIObject.transform)).GetComponent <MonsterHealthBar> ();
            mhb.SetTarget(transform);
        }
        if (invulnTimer >= invulnerableTime)
        {
            float damageTaken = Mathf.Round(damage * (1 - armor / (100 + armor)));
            invulnTimer = 0f;

            if (health > 0f)
            {
                this.health -= damageTaken;
                Global.instance.SpawnDamageText(damageTaken, transform, GetComponentInParent <LRScreen> ().gameObject);
            }

            if (target == null)
            {
                target = source;
            }
        }
    }
Exemple #9
0
        private void UpdateMonsterInfo(Monster Monster)
        {
            Visibility       = Visibility.Visible;
            MonsterName.Text = Monster.Name;
            // Update monster health
            MonsterHealthBar.MaxSize = Width * 0.7833333333333333;
            MonsterHealthBar.UpdateBar(Monster.Health, Monster.MaxHealth);
            SetMonsterHealthBarText(Monster.Health, Monster.MaxHealth);

            if ((Monster.Health / Monster.MaxHealth * 100) < Monster.CaptureThreshold)
            {
                CapturableIcon.Visibility = Visibility.Visible;
            }

            // Monster stamina
            MonsterStaminaBar.MaxSize = Width - 72;
            MonsterStaminaBar.UpdateBar(Monster.Stamina, Monster.MaxStamina);
            SetMonsterStaminaText(Monster.Stamina, Monster.MaxStamina);

            // Gets monster icon
            MonsterIcon.Source = GetMonsterIcon(Monster.Id);

            SwitchSizeBasedOnTarget();

            // Parts
            int index = 0;

            MonsterPartsContainer.Children.Clear();
            while (index < Monster.Parts.Count)
            {
                Part mPart = Monster.Parts[index];
                Monster_Widget.Parts.MonsterPart PartDisplay = new Monster_Widget.Parts.MonsterPart()
                {
                    Style = FindResource("OVERLAY_MONSTER_PART_BAR_STYLE") as Style
                };
                PartDisplay.SetContext(mPart, MonsterPartsContainer.ItemWidth);
                MonsterPartsContainer.Children.Add(PartDisplay);
                index++;
            }

            // Ailments
            index = 0;
            MonsterAilmentsContainer.Children.Clear();
            while (index < Monster.Ailments.Count)
            {
                Ailment ailment = Monster.Ailments[index];
                Monster_Widget.Parts.MonsterAilment AilmentDisplay = new Monster_Widget.Parts.MonsterAilment()
                {
                    Style = FindResource("OVERLAY_MONSTER_AILMENT_BAR_STYLE") as Style
                };
                AilmentDisplay.SetContext(ailment, MonsterAilmentsContainer.ItemWidth);
                MonsterAilmentsContainer.Children.Add(AilmentDisplay);
                index++;
            }

            // Enrage
            if (Monster.IsEnraged)
            {
                ANIM_ENRAGEDICON.Begin(MonsterHealthBar, true);
                ANIM_ENRAGEDICON.Begin(HealthBossIcon, true);
                EnrageTimerText.Visibility = Visibility.Visible;
                EnrageTimerText.Text       = $"{Monster.EnrageTimerStatic - Monster.EnrageTimer:0}s";
            }

            // Set monster crown
            MonsterCrown.Source     = Monster.Crown == null ? null : (ImageSource)FindResource(Monster.Crown);
            MonsterCrown.Visibility = Monster.Crown == null ? Visibility.Collapsed : Visibility.Visible;
            Weaknesses.Children.Clear(); // Removes every weakness icon
            if (Monster.Weaknesses == null)
            {
                return;
            }
            index = 0;
            while (index < Monster.Weaknesses.Keys.Count)
            {
                string      Weakness = Monster.Weaknesses.Keys.ElementAt(index);
                ImageSource img      = FindResource(Weakness) as ImageSource;
                img?.Freeze();
                WeaknessDisplay MonsterWeaknessDisplay = new WeaknessDisplay
                {
                    Icon   = img,
                    Width  = 20,
                    Height = 20
                };
                Weaknesses.Children.Add(MonsterWeaknessDisplay);
                index++;
            }
        }
 private void Awake()
 {
     monsterHealthBar = GameObject.Find("MonsterHealthbar").GetComponent <MonsterHealthBar>();
     playerHealthBar  = GameObject.Find("PlayerHealthbar").GetComponent <PlayerHealthBar>();
 }