Rev 1334 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
package com.gebauz.burutaru.game;
public class ShipParameters
{
// Constants========================================================================================
public static final int MAX_SPEED_LEVEL = 5;
public static final int DEFAULT_HEALTH = 10;
public static final int DEFAULT_EXTRA_LIVES = 3;
public static final float SPEED_FACTORS[] =
{
1.0f,
2.0f,
3.0f,
4.0f,
5.0f
};
// Embedded Types===================================================================================
public enum WeaponType
{
PLASMA_SHOT,
BEAM_SHOT,
SPREAD_SHOT,
NAPALM_SHOT,
}
// Fields===========================================================================================
private GameLogic mGameLogic = null;
private int mSpeedLevel = 2;
private boolean mMissilesEnabled = false;
private boolean mBombEnabled = false;
private int mHealth = DEFAULT_HEALTH;
private int mExtraLives = DEFAULT_EXTRA_LIVES;
private WeaponType mWeaponType = WeaponType.PLASMA_SHOT;
// Methods==========================================================================================
public ShipParameters(GameLogic gameLogic)
{
mGameLogic = gameLogic;
}
public void upgradeSpeed()
{
if (mSpeedLevel < MAX_SPEED_LEVEL)
mSpeedLevel++;
}
public void upgradeMissile()
{
mMissilesEnabled = true;
}
public void upgradeBomb()
{
mBombEnabled = true;
}
public void activateBeamShot()
{
mWeaponType = WeaponType.BEAM_SHOT;
}
public float modifySpeed(float move)
{
return move * SPEED_FACTORS[mSpeedLevel-1];
}
public void damage(int dmg)
{
mHealth -= dmg;
if (mHealth < 0)
mHealth = 0;
}
// Getters/Setters==================================================================================
public final int getSpeedLevel() { return mSpeedLevel; }
public final boolean areMissilesEnabled() { return mMissilesEnabled; }
public final boolean areBombsEnabled() { return mBombEnabled; }
public final int getHealth() { return mHealth; }
public final void setHealth(int health) { mHealth = health; }
public final WeaponType getWeaponType() { return mWeaponType; }
public final GameLogic getGameLogic() { return mGameLogic; }
public final int getLives() { return mExtraLives; }
public final void setLives(int lives) { mExtraLives = lives; }
}