コード例 #1
0
        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());
            }
        }
コード例 #2
0
 // properties
 public void AddAttack(OffensiveAbility newAbility)
 {
     if (newAbility != null)
     {
         _Attacks.Add(newAbility);
     }
 }
コード例 #3
0
 // constructors
 public CharacterAttributes()
 {
     _Attacks       = new List <OffensiveAbility>();
     _Defenses      = new List <DefensiveAbility>();
     _ActiveAttack  = new NullAttack();
     _ActiveDefense = new NullDefend();
 }
コード例 #4
0
 public void SetActiveAttack(OffensiveAbility value)
 {
     if (value != null)
     {
         _ActiveAttack = value;
     }
 }
コード例 #5
0
 public bool RemoveAttack(OffensiveAbility value)
 {
     if (_ActiveAttack == value)
     {
         return(false);
     }
     return(_Attacks.Remove(value));
 }