CanBeAttacked() public method

Tell if the object can be attacked by military units.
public CanBeAttacked ( ) : bool
return bool
Example #1
0
    /// <summary>
    /// Begins an attack on the given target object.
    /// To stop the current attack sequence, pass null to this method.
    /// </summary>
    /// <param name="target">The target of the attack. If null is given, the attack will stop.</param>
    public void AttackObject(RTSObject target)
    {
        if (!CanAttack ())
            throw new InvalidOperationException ("Called AttackObject over an object that can't attack.");

        if (target != null) {
            if (!target.CanBeAttacked ())
                throw new InvalidOperationException ("Called AttackObject over a target object that can't defend.");

            BeginAttack (target);
        } else {
            EndAttack ();
        }
    }