public void PerformActiveAttack(GameCharacter enemy) { CharacterAttributes attackerAttributes = this._Attributes; OffensiveAbility activeAttack = attackerAttributes.GetActiveAttack(); Double attackDamage = 0.0; //Does the attacker have enough Energy to perform the attack? //Is the attack successful given the active attack's success rate? if (attackerAttributes._energy >= activeAttack._energyRequired) { if (AbilitySuccessful(activeAttack._successRate)) { attackerAttributes._energy -= activeAttack._energyRequired; attackDamage = (attackerAttributes._power) * activeAttack._baseDamage; AddMessage(this.GetName() + "\'s " + activeAttack.ToString() + " attack upon " + enemy.GetName() + " was successful for " + attackDamage + " attack damage!"); enemy.PerformActiveDefense(attackDamage); //AddMessage(this.GetName() + "\'s attack and " + enemy.GetName() + "\'s defense are completed. Moving on.\n\n"); } else//Attack Unsuccesful { AddMessage(this.GetName() + "\'s " + activeAttack.ToString() + " attack missed " + enemy.GetName() + "!"); } } else//Insufficient Energy { AddMessage(this.GetName() + "is too tired to use " + activeAttack._abilityName + " on " + enemy.GetName()); } }
// properties public void AddAttack(OffensiveAbility newAbility) { if (newAbility != null) { _Attacks.Add(newAbility); } }
// constructors public CharacterAttributes() { _Attacks = new List <OffensiveAbility>(); _Defenses = new List <DefensiveAbility>(); _ActiveAttack = new NullAttack(); _ActiveDefense = new NullDefend(); }
public void SetActiveAttack(OffensiveAbility value) { if (value != null) { _ActiveAttack = value; } }
public bool RemoveAttack(OffensiveAbility value) { if (_ActiveAttack == value) { return(false); } return(_Attacks.Remove(value)); }