public MinionAttackBehaviour(ISpaceshipAttacker owner) : base(owner) { }
/// <summary> /// Use this function iff you want an idle SpaceShipAttacker to attack an ISpaceship /// If the Attacker is already moving or attacking, it will disregard this command /// </summary> /// <param name="attacker"></param> /// <param name="target"></param> public void AutoAttackSpaceship(ISpaceshipAttacker attacker, ISpaceship target) { if (attacker.Allegiance != target.Allegiance) { attacker.AutoAttackSpaceship(target); } }
/// <summary> /// Goes through the according viewlist and checks if there is a spaceship that is in range. /// if there is a spaceship in range, autoAttack it. /// </summary> /// <param name="attacker"></param> private void AttackNearbySpaceships(ISpaceshipAttacker attacker) { if (attacker.Allegiance == Allegiance.Player) { foreach (GameObject unit in mPlayerView) { if (unit is ISpaceship && InRange(attacker, unit)) mGameObjectManager.AutoAttackSpaceship(attacker, (ISpaceship) unit); } } else if (attacker.Allegiance == Allegiance.Computer) { foreach (GameObject unit in mComputerView) { if (unit is ISpaceship && InRange(attacker, unit)) mGameObjectManager.AutoAttackSpaceship(attacker, (ISpaceship)unit); } } }
/// <summary> /// Use this function to attack with the attacking ISpaceshipAttacker an ISpaceship (defendingUnit). /// The defending unit will defend itself and attack the attacking unit, if it is an ISpaceshipAttacker (it is allowed to retaliate) /// If the units are of the same allegiance the "attacker" moves to the Position of the "defending" unit. /// </summary> /// <param name="attackingUnit"></param> /// <param name="defendingUnit"></param> public void AttackSpaceship(ISpaceshipAttacker attackingUnit, ISpaceship defendingUnit) { if (attackingUnit.Allegiance == defendingUnit.Allegiance) { if (attackingUnit is IMovable) { ((IMovable) attackingUnit).MoveTo(defendingUnit.Position); } } else { attackingUnit.AttackSpaceship(defendingUnit); } }
public SpaceshipAttackBehaviour(ISpaceshipAttacker owner) : base(owner) { if (owner is ISpaceship) mOwnerIsSpaceship = true; }