Example #1
0
        public Character createCharacter(string characterClass, string name, int age, bool admin)
        {
            if (characterClass == "" || characterClass == null)
            {
                throw new ArgumentNullException("Character cannot be empty");
            }
            if (name == "" || name == null)
            {
                throw new ArgumentNullException("Character name cannot be empty");
            }
            if (age <= 0)
            {
                throw new ArgumentNullException("Age cannot be zero");
            }
            switch (characterClass)
            {
            case "Warrior":
                Warrior warrior = new Warrior(name, age, admin, 0);
                return(warrior);

            case "Mage":
                Mage mage = new Mage(name, age, admin, 200);
                return(mage);

            case "Summoner":
                Summoner summoner = new Summoner(name, age, admin);
                return(summoner);
            }
            return(null);
        }
Example #2
0
 private void AbilityLabel()
 {
     lProgressBar.Text = ProgressBarSpecialAbility.Value + "/" + ProgressBarSpecialAbility.Maximum;
     if (character is Warrior)
     {
         Warrior warrior = character as Warrior;
         ProgressBarSpecialAbility.Value   = warrior.Rage;
         ProgressBarSpecialAbility.Maximum = 100;
     }
     else if (character is Mage)
     {
         Mage mage = character as Mage;
         ProgressBarSpecialAbility.Step = 1;
         ProgressBarSpecialAbility.PerformStep();
         ProgressBarSpecialAbility.Maximum = 200;
     }
     else if (character is Summoner)
     {
         Summoner summoner = character as Summoner;
         summoner.Cooldown++;
         ProgressBarSpecialAbility.Step = 1;
         ProgressBarSpecialAbility.PerformStep();
         ProgressBarSpecialAbility.Maximum = 30;
     }
 }
Example #3
0
        private void btnSpecialAbility_Click(object sender, EventArgs e)
        {
            int dmg = 0;

            if (character is Summoner)
            {
                Summoner summoner = character as Summoner;
                if (summoner.Cooldown >= 30)
                {
                    summoner.Cooldown = 0;
                    summoner.SummonMinion(summoner.Cooldown, (summoner.ClickDamage + character.GetUpgradeValue("ClickDamage")));

                    ProgressBarSpecialAbility.Step = -30;
                    ProgressBarSpecialAbility.PerformStep();
                    AbilityLabel();
                }
                else
                {
                    MessageBox.Show("It's still on cooldown, please wait " + (30 - summoner.Cooldown) + " seconds");
                }
            }
            if (character is Warrior)
            {
                Warrior warrior = character as Warrior;
                if (warrior.Rage > 0)
                {
                    ProgressBarSpecialAbility.Value = 0;
                    AbilityLabel();
                    dmg = warrior.UseRage(warrior.Rage);
                }
                else
                {
                    MessageBox.Show("You need rage to cast this");
                }
            }
            if (character is Mage)
            {
                Mage mage = character as Mage;
                if (mage.Mana >= 40)
                {
                    ProgressBarSpecialAbility.Step = -40;
                    ProgressBarSpecialAbility.PerformStep();
                    dmg = mage.UseSpell(40);
                    AbilityLabel();
                }
                else
                {
                    MessageBox.Show("Not enough mana");
                }
            }
            DamageEnemy(dmg);
        }
Example #4
0
 /// <summary>
 /// Own Functions
 /// </summary>
 private void abilities()
 {
     if (character is Summoner)
     {
         Summoner summoner = character as Summoner;
         if (summoner.Cooldown > 0)
         {
             summoner.Cooldown--;
         }
     }
     if (character is Mage)
     {
         Mage mage = character as Mage;
         if (mage.Mana < 200)
         {
             ProgressBarSpecialAbility.Step = 1;
             ProgressBarSpecialAbility.PerformStep();
             AbilityLabel();
             mage.Mana++;
         }
     }
 }