예제 #1
0
        private void Health_OnHealthChanging(object sender, HealthChangingArgs e)
        {
            Projectile projectile = e.HealthChanger as Projectile;

            if (covered && projectile != null && projectile.CrossedCover)
            {
                e.Cancel = true;
            }
        }
예제 #2
0
        public void ChangeHealth(Entity sender, float value)
        {
            HealthChangingArgs args = new HealthChangingArgs(sender, false);

            OnHealthChanging?.Invoke(this, args);
            if (!args.Cancel)
            {
                Health += value;
                OnHealthChanged?.Invoke(this, new HealthChangedArgs(sender));
                if (health <= 0)
                {
                    OnDeath?.Invoke(this, new HealthChangedArgs(sender));
                    if (destroyOnDeath)
                    {
                        parent.Destroy();
                    }
                }
            }
        }