/// <summary> /// Internal call to perform a hit. /// </summary> /// <param name="item">Attacked Item</param> /// <param name="hitpoints">Hitpoints</param> internal void AttackHit(AttackableProperty item, int hitpoints) { if (OnAttackHit != null) { OnAttackHit(item.Item, hitpoints); } }
/// <summary> /// Default Constructor for the Type Mapper. /// </summary> /// <param name="item">Related Engine Item</param> /// <param name="property">Related Engine Property</param> public AttackableState(Item item, AttackableProperty property) : base(item, property) { MaximumHealth = property.AttackableMaximumHealth; Health = property.AttackableHealth; property.OnAttackableHealthChanged += (i, v) => { Health = v; }; property.OnAttackableMaximumHealthChanged += (i, v) => { MaximumHealth = v; }; }
/// <summary> /// Attacks the given Item. /// </summary> /// <param name="item">Item</param> public void Attack(AttackableProperty item) { // Handling des alten Ziels if (AttackTarget != null) { // Ziel ändert sich nicht - alles gut if (AttackTarget == item) { return; } // Altes Ziel entfernen StopAttack(); } // Neues Ziel - Counter muss resettet werden RecoveryCounter = 0; // Prüfen, ob Attacker Teil der Simulation ist if (Item.Engine == null) { throw new NotSupportedException("Attacker is not Part of the Simulation"); } // Prüfen, ob Attackable Teil der Simulation ist if (item.Item.Engine == null || item.Item.Engine != Item.Engine) { throw new NotSupportedException("Attackable is not Part of the same Simulation"); } // Prüfen, ob sich das Element gerade selbst angreifen will if (item.Item == Item) { throw new NotSupportedException("Item can not attack itself"); } // Ziel einfügen AttackTarget = item; }