Example #1
0
        public void GenerateDeath(IBattleEntity killer = null)
        {
            if (!IsAlive || IsInvicible) // Act4 Guardians
            {
                CurrentHp = IsInvicible ? 1 : CurrentHp;
                return;
            }

            IsAlive   = false;
            CurrentHp = 0;
            CurrentMp = 0;
            Death     = DateTime.Now;
            LastMove  = DateTime.Now.AddMilliseconds(500);
            BattleEntity.Buffs.Clear();
            Target = null;
            if (MapInstance?.InstanceBag != null)
            {
                MapInstance.InstanceBag.Combo += IsBonus ? 1 : 0;
                MapInstance.InstanceBag.Point +=
                    EventHelper.Instance.CalculateComboPoint(MapInstance.InstanceBag.Combo + (IsBonus ? 1 : 0));
                MapInstance.InstanceBag.MonstersKilled++;
            }
            BattleEntity.OnDeathEvents.ToList().ForEach(e => { EventHelper.Instance.RunEvent(e, monster: this); });
            killer?.GenerateRewards(this);
        }
Example #2
0
 public void GetDamage(int damage, IBattleEntity entity, bool canKill = true)
 {
     if (CurrentHp <= 0)
     {
         return;
     }
     CurrentHp -= damage;
     CurrentHp  = CurrentHp <= 0 ? !canKill ? 1 : 0 : CurrentHp;
     if (CurrentHp <= 0)
     {
         GenerateDeath(entity);
         entity.GenerateRewards(this);
     }
 }
Example #3
0
 public void GetDamage(int damage, IBattleEntity entity, bool canKill = true)
 {
     if (Hp <= 0)
     {
         return;
     }
     LastDefence = DateTime.Now;
     Hp         -= damage;
     if (Hp < 0)
     {
         Hp = !canKill ? 1 : 0;
         if (canKill)
         {
             GenerateDeath(entity);
             entity.GenerateRewards(this);
         }
     }
 }