Exemple #1
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;
 }
Exemple #2
0
 /** handle new health on upgrade */
 protected virtual void upgrade(CastleUpgrader g)
 {
     if (g != null)
     {
         if (money - g.upgradeCost < 0)
         {
             Logger.i("Cannot upgrade " + ToString() + " ($" + (getMoney() - g.upgradeCost) + ")");
             return;
         }
         money -= g.upgradeCost;
         Logger.i(ToString() + " upgraded to: " + g.ToString() + " ($" + getMoney() + ")");
         upgrader = g;
         double p = healthBar.getPercentage();
         p += Constants.upgradeHealthBoost; if (p > 1)
         {
             p = 1;
         }
         healthBar.maxHealth = g.maxHealth;
         healthBar.sethealth((int)(p * healthBar.maxHealth));
         castleTexture = upgrader.texture;
     }
     Logger.d(details());
 }