Exemplo n.º 1
0
 private void resetAttacks()
 {
     player.resetAttack();
     for (int i = 0; i < creatures.getLength(); i++)
     {
         GenericCreature creature = (GenericCreature)creatures.getItem(i);
         creature.resetAttack();
     }
 }
Exemplo n.º 2
0
        //initializes the creatures for the floor that the player is currently on
        private void loadCreatures()
        {
            int points = challengeMultiplier - 1;   //the floor will get a certain number of "points" that can be used for either more creatures (with a max), or to increase an laready existing creatures level

            creatures.newItem(new TestCreature(1)); //must have at least one creature at level 1 for the floor

            while (points > 0)
            {
                int nextPoint = Constants.rand.Next(2);                                //returns 0<=nextPoint<2, essentially, flip a coin
                if (nextPoint == 0 && creatures.getLength() < Constants.MAX_CREATURES) //one choice, add another creature, so long as we haven't hit our max
                {
                    creatures.newItem(new TestCreature(1));
                }
                else//otherwise, we want to increase the level of a creature already in the list
                {
                    int             selectedCreature = Constants.rand.Next(creatures.getLength());
                    GenericCreature creature         = (GenericCreature)creatures.getItem(selectedCreature);
                    creature.lvlUp();
                }
                points--;
            }
        }
Exemplo n.º 3
0
        //let's the player attack a creature, if theres only one creature just attacks that creature
        private void playerAttack()
        {
            Constants.writeLine("It's your turn.");
            int    choice = 0;
            Strike playerAttack;

            do
            {
                playerAttack = new Strike(player);
                if (!playerAttack.isStriking())
                {
                    return;
                }
                Constants.writeLine("Who would you like to target?");
                choice = chooseCreature();
            } while (choice == 0);

            Attack attack = new Attack(playerAttack);

            if (choice == 1)
            {
                Constants.writeLine("You targeted yourself.");
                player.attacked(attack);
            }
            else
            {
                GenericCreature target = (GenericCreature)creatures.getItem(choice - 2);
                Constants.writeLine("You targeted " + target.getName() + ".");
                target.attacked(attack);
                if (!target.isAlive())
                {
                    Constants.writeLine("The creature falls to the ground dead.");
                    creatures.removeItem(choice - 2);
                }
                System.Threading.Thread.Sleep(750);
            }
        }
Exemplo n.º 4
0
 //create a strike class for a creature
 public Strike(GenericCreature creature)
 {
     thing = creature;
     getAttack();
 }