protected virtual void attack(HittableTarget target, Boolean isMelee, Castle enemy)
 {
     if (canAttackType == CharacterEnums.EType.BOTH || canAttackType == target.myType || target.myType == CharacterEnums.EType.BOTH)
     {
         attackCounter++;
         if (attackCounter >= getAttackCount())
         {
             attackCounter = 0;
             if (isMelee)
             {
                 Logger.d(ToString() + " attacked " + target.ToString() + "(Melee " + getMeleeDamage() + " dmg)");
                 if (splashRange == 0)
                 {
                     target.getHit(getMeleeDamage());
                 }
                 else
                 {
                     enemy.hitForSplash(getMeleeDamage(), splashRange, canAttackType);
                 }
             }
             else
             {
                 Logger.d(ToString() + " attacked " + target.ToString() + "(Ranged " + getRangedDamage() + " dmg)");
                 if (splashRange == 0)
                 {
                     target.getHit(getRangedDamage());
                 }
                 else
                 {
                     enemy.hitForSplash(getRangedDamage(), splashRange, canAttackType);
                 }
             }
         }
     }
 }
        public virtual void update(Castle enemy)
        {
            HittableTarget groundTarget = enemy.groundFrontTarget;
            HittableTarget airTarget    = enemy.airFrontTarget;

            if (dead())
            {
                return;
            }
            switch (brain.determine(this, groundTarget, airTarget))
            {
            case CharacterEnums.ECharacterAction.WALKFORWARD:
                walkForward();
                break;

            case CharacterEnums.ECharacterAction.WALKBACKWARD:
                walkBackward();
                break;

            case CharacterEnums.ECharacterAction.MELEEATTACK:
                attackTop(brain.myTarget, true, enemy);
                break;

            case CharacterEnums.ECharacterAction.RANGEATTACK:
                attackTop(brain.myTarget, false, enemy);
                break;
            }
            animSet.currentAnimation.Update();
        }
 private void attackTop(HittableTarget target, Boolean isMelee, Castle enemy)
 {
     if (facing == CharacterEnums.EDirection.RIGHT)
     {
         if (isMelee)
         {
             animSet.currentAnimation = animSet.rightAttack;
         }
         else
         {
             animSet.currentAnimation = animSet.rightAttackRange;
         }
     }
     else
     {
         if (isMelee)
         {
             animSet.currentAnimation = animSet.leftAttack;
         }
         else
         {
             animSet.currentAnimation = animSet.leftAttackRange;
         }
     }
     attack(target, isMelee, enemy);
 }
 /** filter out ground and air then call specific brain determining action */
 public FieldFighter.Hittable.CharacterEnums.ECharacterAction determine(HittableCharacter me, HittableTarget groundTarget, HittableTarget airTarget)
 {
     myTarget = groundTarget;
     if (me.myType == CharacterEnums.EType.BOTH)
     {
         myTarget = airTarget.inFront(airTarget, groundTarget);
     }
     else if (me.myType == CharacterEnums.EType.AIR)
     {
         myTarget = airTarget;
     }
     return(determineAction(me, myTarget));
 }
Esempio n. 5
0
 /** determine which hittable target is the front target */
 public HittableTarget inFront(HittableTarget a, HittableTarget b)
 {
     if (facing == CharacterEnums.EDirection.LEFT)
     {
         if (a.getFrontLocationX() < b.getFrontLocationX())
         {
             return(a);
         }
         return(b);
     }
     else
     {
         if (a.getFrontLocationX() > b.getFrontLocationX())
         {
             return(a);
         }
         return(b);
     }
 }
Esempio n. 6
0
 public Castle(FieldFighter.Hittable.CharacterEnums.EDirection facing, int Xco)
 {
     upgrader      = CastleUpgrader.set1;
     myType        = CharacterEnums.EType.BOTH;
     castleTexture = upgrader.texture;
     this.facing   = facing;
     if (facing == CharacterEnums.EDirection.LEFT)
     {
         this.xCoordinate = Xco - castleTexture.Width;
         this.healthBar   = new VerticalHealthBar(ELocation.RIGHT);
     }
     else
     {
         this.xCoordinate = Xco;
         this.healthBar   = new VerticalHealthBar(ELocation.LEFT);
     }
     healthBar.setNew(upgrader.maxHealth);
     groundFrontTarget = this;
     airFrontTarget    = this;
 }
Esempio n. 7
0
 /** updates the front target and held characters */
 public virtual void updateCharacters(Castle enemyCastle)
 {
     if (turret != null)
     {
         turret.update(enemyCastle);
     }
     money            += Constants.moneyEarnRate;
     groundFrontTarget = this;
     airFrontTarget    = this;
     for (int i = characters.Count - 1; i >= 0; i--)
     {
         if (characters[i].dead())
         {
             characterTotals.sub(characters[i].spawnAttribute);
             enemyCastle.pay(characters[i].getSpawnCost() / 2);
             characters.RemoveAt(i);
         }
         else
         {
             characters[i].update(enemyCastle);
             if (characters[i].myType == CharacterEnums.EType.BOTH)
             {
                 groundFrontTarget = inFront(characters[i], groundFrontTarget);
                 airFrontTarget    = inFront(characters[i], airFrontTarget);
             }
             else if (characters[i].myType == CharacterEnums.EType.AIR)
             {
                 airFrontTarget = inFront(characters[i], airFrontTarget);
             }
             else
             {
                 groundFrontTarget = inFront(characters[i], groundFrontTarget);
             }
         }
     }
 }
Esempio n. 8
0
 private Boolean withinRange(HittableTarget target, HittableTarget rangeof, int range)
 {
     return(Math.Abs(target.getFrontLocationX() - rangeof.getFrontLocationX()) < range);
 }
 public abstract FieldFighter.Hittable.CharacterEnums.ECharacterAction determineAction(HittableCharacter me, HittableTarget frontEnemy);