Esempio n. 1
0
        public override BattleAction ai(Party goodGuys)
        {
            /* start ai */

            Character target = getTarget( goodGuys );
            BattleAction action;
            AbilitiesIterator abilities;
            Ability theAbility;

            if (mAbilities.Count != 0)
            {/* start if */

                abilities = getAbilities();
                theAbility = abilities.getAbilityAtIndex(0);

                foreach (Ability ability in abilities)
                    if (ability.AffectEnemy)
                        if (ability.BaseDamage > theAbility.BaseDamage)
                            theAbility = ability;

                if (theAbility.Cost > mEnemy.CurrentMana)
                    action = new AttackAction( target );
                else
                    action = new AbilityAction( theAbility, target );

            }/* end if */
            else
            {/* start else */

                action = new AttackAction(target);

            }/* end else */

            return action;
        }
Esempio n. 2
0
        public override BattleAction ai(Party goodGuys)
        {
            /* start ai */

            Random random = new Random();
            int target = random.Next( goodGuys.Size );

            return new AttackAction(goodGuys.getCharacter(target));
        }
Esempio n. 3
0
        private Character getTarget(Party goodGuys)
        {
            /* start getTarget */

            Character target = goodGuys.getCharacter(0);
            int i;

            for (i = 0; i < goodGuys.Size; i++)
                if (goodGuys.getCharacter(i).CurrentHealth < target.CurrentHealth)
                    target = goodGuys.getCharacter(i);

            return target;
        }
Esempio n. 4
0
        public override BattleAction ai(Party goodGuys)
        {
            /* start ai */

            Random random = new Random();
            int i;
            Character target = null;

            /* Should modularize these loops */
            for (i = 0; i < goodGuys.Size; i++)
                if (((PlayerCharacter)goodGuys.getCharacter(i)).Class == ClassEnum.WHITEMAGE)
                    target = goodGuys.getCharacter(i);

            if( target == null )
                for (i = 0; i < goodGuys.Size; i++)
                    if (((PlayerCharacter)goodGuys.getCharacter(i)).Class == ClassEnum.REDMAGE)
                        target = goodGuys.getCharacter(i);

            if (target == null)
                target = goodGuys.getCharacter(random.Next(Party.MAXPARTY));

            return new AttackAction(target);
        }
Esempio n. 5
0
        public Character[] getTurnOrder(Party otherParty)
        {
            /* start getTurnOrder */

            int size = this.mPartySize + otherParty.mPartySize;
            int i, j;
            Character[] turnOrder = new Character[size];
            Character temp;

            for (i = 0; i < mParty.Length; i++)
                turnOrder[ i ] = mParty[ i ];

            for( j = 0; j < otherParty.mPartySize; j++, i++ )
                turnOrder[ i ] = otherParty.mParty[ j ];

            for (i = 0; i < size; i++)
                for (j = 0; j < size; j++)
                    if ( turnOrder[ i ].CompareTo( turnOrder[ j ] ) )
                    {/* start if */

                        temp = turnOrder[i];
                        turnOrder[i] = turnOrder[j];
                        turnOrder[j] = temp;

                    }/* end if */

            return turnOrder;
        }
Esempio n. 6
0
        private void initialize()
        {
            /* start initialize */

            ClassEnum choice;
            int i;
            String name;
            Character[] characters = new Character[ Party.MAXPARTY ];

               // mView = new TextView();

            mDungeon = Dungeon.getInstance(this);
            mView = new DisplayView(viewWindow, mDungeon);

            //for (i = 0; i < Party.MAXPARTY; i++)
            for (i = 0; i < 1; i++)
            {/* start loop */

                choice = mView.getClassChoice();
                name = mView.getCharacterName();

                characters[ i ] = CharacterFactory.getInstance().getCharacter(choice, name);

            }/* end loop */

            mGoodGuys = new Party(characters);
            // mView.GoodGuys = mGoodGuys;
            mBattle = new Battle(this, mGoodGuys);

            mDungeon.SetView(mView);
            mDungeon.SetGame(this);
            //mView.Dungeon = mDungeon.Grid;
        }
Esempio n. 7
0
        public BattleAction getPlayerAction( Character character, Party badGuys )
        {
            /* start getPlayerAction */

            return mView.getPlayerAction(character, badGuys);
        }
Esempio n. 8
0
        public BattleAction takeTurn( Party goodGuys )
        {
            /* start takeTurn */

            return mAI.ai( goodGuys );
        }
Esempio n. 9
0
        public Party getSpecificParty(EnemyType type)
        {
            /* start getSpecificParty */

            Party badGuys = null;

            if( type == EnemyType.DRAGON )
                badGuys = new Party( new Character[] { getDragon() } );

               return badGuys;
        }
Esempio n. 10
0
 /* For Battle System */
 public BattleAction getPlayerAction(Character character, Party badGuys)
 {
     return null;
 }
Esempio n. 11
0
 public abstract BattleAction ai(Party goodGuys);
Esempio n. 12
0
 // Constructors
 public Battle(Game currentGame, Party goodGuyParty)
 {
     mGame = currentGame;
     mGoodGuys = goodGuyParty;
 }
Esempio n. 13
0
        public void startBattle(EnemyType type)
        {
            mBadGuys = EnemyFactory.getInstance().getSpecificParty(type);

            turnOrder = mGoodGuys.getTurnOrder(mBadGuys);
            selectFirstCharacter();

            turnOrder = mGoodGuys.getTurnOrder(mBadGuys);
            selectFirstCharacter();

            while (!battleOver())
            {
                if (currentActor.isPlayer)
                {
                    executeAction(mGame.getPlayerAction( currentActor, mBadGuys ));
                }
                else
                {
                    Enemy current_enemy = (Enemy) currentActor;
                    executeAction(current_enemy.takeTurn(mGoodGuys));
                }
            }
        }