Permalink
Browse files

Merge pull request #476 from Sturmflut/buildingjavadoc

Add JavaDoc comments to all files in com.mojang.mojam.entity.building
  • Loading branch information...
2 parents 43659f8 + aed6ab9 commit 5fbfced6b44febef2adb1c0497e62ff5b8d61635 @master-lincoln master-lincoln committed Feb 26, 2012
@@ -3,13 +3,26 @@
import com.mojang.mojam.screen.Art;
import com.mojang.mojam.screen.Bitmap;
+/**
+ * Player base
+ */
public class Base extends Building {
+ /**
+ * Constructor
+ *
+ * @param x Initial X coordinate
+ * @param y Initial Y coordinate
+ * @param team Team number
+ * @param localTeam Local team number
+ */
public Base(double x, double y, int team, int localTeam) {
super(x, y, team, localTeam);
+
setStartHealth(20);
freezeTime = 10;
}
+ @Override
public void tick() {
super.tick();
if (freezeTime > 0)
@@ -10,20 +10,33 @@
import com.mojang.mojam.screen.Art;
import com.mojang.mojam.screen.Bitmap;
+/**
+ * Bomb object. Triggered by bullets, destroys special wall tiles
+ */
public class Bomb extends Building {
-
+ /** Affected destruction radius around the bomb in pixels*/
public static final double BOMB_DISTANCE = 50;
+
private boolean hit = false;
+ /**
+ * Constructor
+ *
+ * @param x X coordinate
+ * @param y Y Coordinate
+ * @param localTeam Local team bumber
+ */
public Bomb(double x, double y, int localTeam) {
super(x, y, Team.Neutral,localTeam);
+
setStartHealth(8);
yOffs = 2;
setSize(7, 7);
doShowHealthBar = false;
buildingRegen(false);
}
+ @Override
public void die() {
level.addEntity(new LargeBombExplodeAnimation(pos.x, pos.y));
MojamComponent.soundPlayer.playSound("/sound/Explosion 2.wav",
@@ -90,7 +103,10 @@ public Bitmap getSprite() {
public void hurt(Entity source, float damage) {
}
+ /**
+ * Mark this object as hit
+ */
public void hit() {
- hit = true;;
+ hit = true;
}
}
@@ -138,14 +138,27 @@ public void tick() {
yd = 0.0;
}
+ /**
+ * Called if this building is picked up
+ *
+ * @param mob Reference to the mob object carrying this building
+ */
public void onPickup(Mob mob) {
carriedBy = mob;
}
+ /**
+ * Called if this building is dropped by its carrier
+ */
public void onDrop() {
carriedBy = null;
}
+ /**
+ * Check if this building is being carried
+ *
+ * @return True if carried, false if not
+ */
public boolean isCarried() {
return carriedBy != null;
}
@@ -178,13 +191,8 @@ public void slideMove(double xa, double ya) {
fallDownHole();
}
- //
- //upgrade
- //
/**
- * IF YOU REMOVE THIS, I COME TO YOUR HOUSE AND KILL YOU
- * IN YOUR SLEEP!
- * or nicer said, this is used by other functions
+ * Called if building upgrade is complete
*/
protected void upgradeComplete() {
}
@@ -227,7 +235,7 @@ public boolean upgrade(Player p) {
}
/**
- * Make the building upgradeable
+ * Make this building upgradeable
*
* @param costs Cost vector
*/
@@ -264,10 +272,20 @@ public boolean isAllowedToCancel() {
return true;
}
+ /**
+ * Set regeneration status for this building
+ *
+ * @param regen True if building can regenerate, false if not
+ */
public void buildingRegen(boolean regen) {
healthRegenB = regen;
}
+ /**
+ * Check if this building is able to regenerate
+ *
+ * @return True if building can regenerate, false if not
+ */
public boolean buildingRegenEnabled() {
return healthRegenB;
}
@@ -14,8 +14,10 @@
import com.mojang.mojam.screen.Bitmap;
import com.mojang.mojam.screen.Screen;
+/**
+ * Harvester building. Automatically collects all coins within a given radius around itself
+ */
public class Harvester extends Building implements LootCollector {
-
private int capacity = 1500;
private int money = 0;
private int time = 0;
@@ -28,7 +30,17 @@
private int[] upgradeRadius = new int[] { (int) (1.5 * Tile.WIDTH),
2 * Tile.WIDTH, (int) (2.5 * Tile.WIDTH) };
private int[] upgradeCapacities = new int[] { 1500, 2500, 3500 };
+
+ public Bitmap areaBitmap;
+ /**
+ * Constructor
+ *
+ * @param x Initial X coordinate
+ * @param y Initial Y coordinate
+ * @param team Team number
+ * @param localTeam Local team number
+ */
public Harvester(double x, double y, int team, int localTeam) {
super(x, y, team,localTeam);
setStartHealth(10);
@@ -39,16 +51,17 @@ public Harvester(double x, double y, int team, int localTeam) {
areaBitmap = Bitmap.rangeBitmap(radius,Color.YELLOW.getRGB());
}
- public Bitmap areaBitmap;
-
+ @Override
public void notifySucking() {
harvestingTicks = 30;
}
+ @Override
public boolean isAllowedToCancel() {
return !isEmptying;
}
+ @Override
public void tick() {
super.tick();
if (--freezeTime > 0) {
@@ -106,6 +119,7 @@ public Bitmap getSprite() {
}
}
+ @Override
protected void upgradeComplete() {
maxHealth += 10;
health += 10;
@@ -115,10 +129,16 @@ protected void upgradeComplete() {
if (upgradeLevel != 0) justDroppedTicks = 80; //show the radius for a brief time
}
+ /**
+ * Check if this collector still hascapacity for additional coins
+ *
+ * @return True if remaining capacity is more than zero, false if not
+ */
public boolean canTake() {
return money < capacity;
}
+ @Override
public void render(Screen screen) {
if(justDroppedTicks-- > 0 && localTeam==team) {
@@ -138,12 +158,17 @@ public void render(Screen screen) {
}
+ /**
+ * Draw the money bar onto the given screen
+ *
+ * @param screen Screen
+ */
private void addMoneyBar(Screen screen) {
-
int start = (int) (money * 20 / capacity);
screen.blit(Art.moneyBar[start][0], pos.x - 16, pos.y + 8);
}
+ @Override
public void take(Loot loot) {
loot.remove();
money += loot.getScoreValue();
@@ -152,19 +177,24 @@ public void take(Loot loot) {
}
}
+ @Override
public double getSuckPower() {
return radius / 60.0;
}
+ @Override
public void flash() {
}
+ @Override
public int getScore() {
return money;
}
+ /**
+ * Drop all money, comes with a nice animation
+ */
public void dropAllMoney() {
-
while (money > 0) {
double dir = TurnSynchronizer.synchedRandom.nextDouble() * Math.PI
* 2;
@@ -177,6 +207,7 @@ public void dropAllMoney() {
money = 0;
}
+ @Override
public void use(Entity user) {
if(money > 0) {
isEmptying = true;
@@ -12,6 +12,9 @@
import com.mojang.mojam.screen.Bitmap;
import com.mojang.mojam.screen.Screen;
+/**
+ * Generic shop item, available from the players base
+ */
public class ShopItem extends Building {
private int facing = 0;
@@ -29,6 +32,14 @@
MojamComponent.texts.shopTooltipLines("bomb")
};
+ /**
+ * Constructor
+ *
+ * @param x Initial X coordinate
+ * @param y Initial Y coordinate
+ * @param team Team number
+ * @param localTeam Local team number
+ */
public ShopItem(double x, double y, int type, int team, int localTeam) {
super(x, y, team, localTeam);
this.type = type;
@@ -39,6 +50,10 @@ public ShopItem(double x, double y, int type, int team, int localTeam) {
setBuildingCost();
yOffs = YOFFS[type];
}
+
+ /**
+ * Set building cost depending if creative mode is on or not
+ */
public void setBuildingCost(){
if(Options.getAsBoolean(Options.CREATIVE)){
COST[0] = 0;
@@ -59,14 +74,17 @@ public void render(Screen screen) {
}
}
+ @Override
public void init() {
effectiveCost = DifficultyInformation.calculateCosts(COST[type]);
}
+ @Override
public void tick() {
super.tick();
}
+ @Override
public Bitmap getSprite() {
switch (type) {
case SHOP_TURRET:
@@ -79,6 +97,11 @@ public Bitmap getSprite() {
return Art.turret[facing][0];
}
+ /**
+ * Get tool tip
+ *
+ * @return Tool tip
+ */
public String[] getTooltip() {
return TOOLTIPS[type];
}
Oops, something went wrong.

0 comments on commit 5fbfced

Please sign in to comment.