private void AttackTarget(ServerMob target) { //effect by chance var effect = _random.Next(0, 100) <= TowerData.EffectChance; var hit = new MobHit { Damage = DamageCalculator.GetTowerDamageForMob(TowerData, target.MobData, target.StatusEffect), SendingTower = this, Status = effect?TowerData.Effect:null }; target.Hit(hit); }
public void Hit(MobHit hit) { if (hit.Status != null) { if (StatusEffect.All(s => hit.Status.Type != s.Type)) { hit.Status.LeftDuration = hit.Status.Duration; StatusEffect.Add(hit.Status); } } //Calculate Splash if (hit.SendingTower.TowerData.SplashRange > 0 && !hit.NoSplash) { var mobsInDistance = GetMobsInDistance(this, hit.SendingTower.TowerData.SplashRange); var splashHit = new MobHit { Status = hit.Status, SendingTower = hit.SendingTower, NoSplash = true }; mobsInDistance.ForEach(m => { splashHit.Damage = hit.Damage; m.Hit(splashHit); }); } Hp -= hit.Damage; if (Hp <= 0) { Killed(hit.SendingTower); return; } }