Example #1
0
        //member methods

        public void PopulateMovePool()
        {
            movePool[0] = new DinoAttack("claw attack", 8);
            movePool[1] = new DinoAttack("bite attack", 12);
            movePool[2] = new DinoAttack("tail whip", 7);
            movePool[3] = new DinoAttack("charge attack", 15);
        }
Example #2
0
        //Deprecated attack function
        //public void Attack(Robot targetRobot)
        //{
        //    Console.WriteLine(type + " attacks " + targetRobot.name);
        //    if (targetRobot.health <= attackPower)
        //    {
        //        targetRobot.health = 0;
        //        Console.WriteLine(targetRobot.name + " has fallen in battle");
        //    }
        //    else
        //    {
        //        targetRobot.health -= attackPower;
        //        Console.WriteLine(targetRobot.name + " takes " + attackPower + " damage and has " + targetRobot.health + " HP remaining");
        //    }

        //}

        public void TryAttack(Robot targetRobot, Random rng)
        {
            if (health > 0 && energy > 0)
            {
                DinoAttack attackType = ChooseAttack(rng);

                Console.WriteLine(type + " attacks " + targetRobot.name + " with a " + attackType.type);
                if (energy >= 10)
                {
                    energy -= 10;
                }
                else if (energy < 10)
                {
                    energy = 0;
                    Console.WriteLine("The " + type + " is out of energy and can no longer attack");
                    Console.WriteLine("");
                }
                if (targetRobot.health <= attackType.attackPower)
                {
                    targetRobot.health = 0;
                    Console.WriteLine(targetRobot.name + " has fallen in battle");
                    Console.WriteLine("");
                }
                else
                {
                    targetRobot.health -= attackType.attackPower;
                    Console.WriteLine(targetRobot.name + " takes " + attackPower + " damage and has " + targetRobot.health + " HP remaining");
                    Console.WriteLine("");
                }
            }
        }
Example #3
0
 //Constructor
 public Dinosaur(string type, DinoAttack dinoAttack)
 {
     this.type        = type;
     this.dinoAttack  = dinoAttack;
     health           = 100;
     energyPercentage = 100;
 }
Example #4
0
        //Constructor
        public Herd()
        {
            dinosaurs   = new  List <Dinosaur>();
            dinoAttacks = new DinoAttack[3];

            dinoAttacks[0] = new DinoAttack("bite", 10);
            dinoAttacks[1] = new DinoAttack("scratch", 15);
            dinoAttacks[2] = new DinoAttack("fire blast", 20);

            Dinosaur sharpTooth = new Dinosaur("Tyrannosaurus", dinoAttacks[2]);
            Dinosaur spike      = new Dinosaur("Ankylosaurus", dinoAttacks[1]);
            Dinosaur topps      = new Dinosaur("Triceratops", dinoAttacks[0]);

            PopulateHeard(sharpTooth);
            PopulateHeard(spike);
            PopulateHeard(topps);
        }