Ejemplo n.º 1
0
        private void Unit_OnTookDamage(object sender, Unit.DamageEventArgs e)
        {
            if (e.wasKilled)
            {
                _unit.OnTookDamage -= Unit_OnTookDamage;
            }

            if (!IsShowing)
            {
                Show();
            }

            _healthbarAnim?.Stop();

            float startFill = e.previousHealth / (float)e.targetUnit.MaxHealth;
            float endFill   = e.newHealth / (float)e.targetUnit.MaxHealth;

            _healthbarAnim = new TofuAnimation()
                             .Value01(HealthBarAnimTime, EEaseType.Linear, (float newValue) =>
            {
                _healthBar.Percent = Mathf.LerpUnclamped(startFill, endFill, newValue);
            })
                             .Then()
                             .Wait(2f)
                             .Then()
                             .Execute(() =>
            {
                Hide();
            })
                             .Play();
        }
Ejemplo n.º 2
0
        // --------------------------------------------------------------------------------------------
        private void OnUnitTookDamage(object sender, Unit.DamageEventArgs e)
        {
            foreach (Player player in _playerToPlayerPanels.Keys)
            {
                if (player.Hero != e.targetUnit)
                {
                    continue;
                }

                _playerToPlayerPanels[player].SetHealth(e.newHealth, e.targetUnit.MaxHealth);
            }
        }