示例#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
        public void PerformActiveDefense(Double incomingDamage)
        {
            CharacterAttributes defenderAttributes = this._Attributes;
            DefensiveAbility    activeDefense      = defenderAttributes.GetActiveDefense();

            Double damagePrevented = defenderAttributes._armor;

            if (AbilitySuccessful(activeDefense._successRate))
            {
                damagePrevented += activeDefense._armorIncrease;
                AddMessage(this.GetName() + "'s " + activeDefense.ToString() + " defense was successful for a " + damagePrevented + " damage decrease!");

                defenderAttributes._health -= Math.Max(0, incomingDamage - damagePrevented);
                AddMessage(this.GetName() + " lost " + Math.Max(0, incomingDamage - damagePrevented) + " health points");
            }
            else
            {
                AddMessage(this.GetName() + "'s " + activeDefense.ToString() + " defense was unsuccessful! No damage will be prevented!");
                defenderAttributes._health -= Math.Max(0, incomingDamage);
                AddMessage(this.GetName() + " lost " + Math.Max(0, incomingDamage) + " health points");
            }
            if (GetAttributes()._health == 0)
            {
                HandleDeath();
            }
        }
示例#3
0
 public void SetAttributes(CharacterAttributes attributes)
 {
     if (attributes != null)
     {
         _Attributes = attributes;
     }
 }
        public Warrior() : base("Warrior")
        {
            CharacterAttributes myAttributes = new CharacterAttributes();

            myAttributes._basehealth = 10;
            myAttributes._health     = 10;
            myAttributes._baseEnergy = 25;
            myAttributes._energy     = 25;
            myAttributes._basePower  = 5;
            myAttributes._power      = 5;
            myAttributes.SetIsGoodGuy(true);
            myAttributes.SetActiveAttack(new WarriorAttack1());
        }
示例#5
0
        public Gargoyle() : base("Gargoyle")
        {
            CharacterAttributes myAttributes = new CharacterAttributes();

            myAttributes._basehealth = 120;
            myAttributes._health     = 120;
            myAttributes._baseEnergy = 50;
            myAttributes._energy     = 50;
            myAttributes._power      = 1;
            myAttributes._armor      = 1;
            myAttributes.SetIsGoodGuy(false);

            SetAttributes(myAttributes);

            //Add the abilities this concrete GameCharacter has by default
            base.GetAttributes().AddAttack(new GargoyleStare());
            base.GetAttributes().AddDefense(new GargoyleFreeze());
        }
示例#6
0
        public LandShark()
            : base("Land Shark")
        {
            CharacterAttributes myAttributes = new CharacterAttributes();

            myAttributes._basehealth = 100;
            myAttributes._health     = 100;
            myAttributes._baseEnergy = 20;
            myAttributes._energy     = 20;
            myAttributes._power      = 1;
            myAttributes._armor      = 1;
            myAttributes.SetIsGoodGuy(false);

            SetAttributes(myAttributes);

            //Add the abilities this concrete GameCharacter has by default
            base.GetAttributes().AddAttack(new LandSharkChomp());
            base.GetAttributes().AddDefense(new LandSharkEvade());
        }
示例#7
0
        public Leprachaun()
            : base("Leprachaun")
        {
            CharacterAttributes myAttributes = new CharacterAttributes();

            myAttributes._basehealth = 90;
            myAttributes._health     = 90;
            myAttributes._baseEnergy = 20;
            myAttributes._energy     = 20;
            myAttributes._power      = 1;
            myAttributes._armor      = 1;
            myAttributes.SetIsGoodGuy(false);

            SetAttributes(myAttributes);

            //Add the abilities this concrete GameCharacter has by default
            base.GetAttributes().AddAttack(new LeprachaunThrowGold());
            base.GetAttributes().AddDefense(new LeprachaunDisappear());
        }
示例#8
0
        public Warrior() : base("Warrior")
        {
            CharacterAttributes myAttributes = new CharacterAttributes();

            myAttributes._baseXP     = new int[] { 10, 20, 30, 40 };
            myAttributes._basehealth = 100;
            myAttributes._health     = 100;
            myAttributes._baseEnergy = 50;
            myAttributes._energy     = 50;
            myAttributes._power      = 1;
            myAttributes._armor      = 1;
            myAttributes.SetIsGoodGuy(true);

            SetAttributes(myAttributes);

            //Add the abilities this concrete GameCharacter has by default
            base.GetAttributes().AddAttack(new WarriorSlash());
            base.GetAttributes().AddDefense(new WarriorLiftShield());
        }
示例#9
0
        public Scout()
            : base("Scout")
        {
            CharacterAttributes myAttributes = new CharacterAttributes();

            myAttributes._baseXP     = new int[] { 10, 20, 30, 40 };
            myAttributes._basehealth = 50;
            myAttributes._health     = 50;
            myAttributes._baseEnergy = 20;
            myAttributes._energy     = 20;
            myAttributes._power      = 1;
            myAttributes._armor      = 1;
            myAttributes.SetIsGoodGuy(true);

            SetAttributes(myAttributes);

            //Add the abilities this concrete GameCharacter has by default
            base.GetAttributes().AddAttack(new ScoutShootPlainArrow());
            base.GetAttributes().AddDefense(new ScoutRoll());
        }
示例#10
0
        public Mage()
            : base("Mage")
        {
            CharacterAttributes myAttributes = new CharacterAttributes();

            myAttributes._baseXP     = new int[] { 10, 20, 30, 40 };
            myAttributes._basehealth = 100;
            myAttributes._health     = 100;
            myAttributes._baseEnergy = 50;
            myAttributes._energy     = 50;
            myAttributes._power      = 1;
            myAttributes._armor      = 1;
            myAttributes.SetIsGoodGuy(true);

            SetAttributes(myAttributes);

            //Add the abilities this concrete GameCharacter has by default
            base.GetAttributes().AddAttack(new MageShootLightning());
            base.GetAttributes().AddDefense(new MageCastShield());
        }