private void DamageTarget() { if (Target == null) { return; } if (Target.HasComponent <OwnerComponent>() && Parent.HasComponent <OwnerComponent>() && Target.GetComponent <OwnerComponent>() != Parent.GetComponent <OwnerComponent>()) { if (Type == AttackType.Far) { var type = Parent.GetComponent <HealthComponent>().ArmyType; ((IGameEntityFactory)Parent.Scene.EntityFactory).CreateProjectile(Parent, Target, new Vector2(type == 2 ? 0.4f : 0.25f), AttackDamage); } else if (Type == AttackType.Melee) { var damage = AttackDamage; var targetMultiplierType = Target.GetComponent <HealthComponent>().ArmyType; if (DamageMultipliers.ContainsKey(targetMultiplierType)) { damage *= DamageMultipliers[targetMultiplierType]; } Target.GetComponent <HealthComponent>().Damage(damage, Parent); } } damaged = true; }
private bool HasInRange(IEntity other) { if (other.HasComponent <HealthComponent>()) { var targetMultiplierType = other.GetComponent <HealthComponent>().ArmyType; if (DamageMultipliers.ContainsKey(targetMultiplierType)) { if (DamageMultipliers[targetMultiplierType] == 0) { return(false); } } } return((Parent.Position - other.Position).Length < Range + (Parent.Size.X / 2)); }