Skip to content

Commit

Permalink
Add a new ghost type: the king of ghosts
Browse files Browse the repository at this point in the history
  • Loading branch information
vbarthel-fr committed Aug 25, 2013
1 parent bc2f66b commit 5236f7d
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ protected void onKill() {
public void spawn() {
super.spawn();
if (mGameInformation.getCurrentTargetsNumber() < mGameInformation.getMaxTargetOnTheField()) {
final int randomDraw = MathUtils.randomize(0,100);
final int randomDraw = MathUtils.randomize(0, 100);
final float[] pos = mGameInformation.getCurrentPosition();
int ghostType;
if(randomDraw < 60) {
if (randomDraw < 60) {
ghostType = DisplayableItemFactory.TYPE_EASY_GHOST;
}else if (randomDraw < 75){
} else if (randomDraw < 75) {
ghostType = DisplayableItemFactory.TYPE_HIDDEN_GHOST;
}else if (randomDraw < 90){
} else if (randomDraw < 90) {
ghostType = DisplayableItemFactory.TYPE_BABY_GHOST;
} else {
} else if (randomDraw < 99) {
ghostType = DisplayableItemFactory.TYPE_GHOST_WITH_HELMET;
} else {
ghostType = DisplayableItemFactory.TYPE_KING_GHOST;
}
mGameInformation.addTargetableItem(DisplayableItemFactory.createGhostWithRandomCoordinates(
ghostType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ public static BestiaryEntry createBestiaryEntry(int ghostType) {
bestiaryEntry.setTitleResourceId(R.string.bestiary_baby_ghost_title);
break;

case DisplayableItemFactory.TYPE_HIDDEN_GHOST:
case DisplayableItemFactory.TYPE_HIDDEN_GHOST:
bestiaryEntry.setTargetableItem(DisplayableItemFactory.createHiddenGhost());
bestiaryEntry.setImageResourceId(R.drawable.hidden_ghost);
bestiaryEntry.setTitleResourceId(R.string.bestiary_hidden_ghost_title);
break;

case DisplayableItemFactory.TYPE_KING_GHOST:
bestiaryEntry.setTargetableItem(DisplayableItemFactory.createKingGhost());
bestiaryEntry.setImageResourceId(R.drawable.king_ghost);
bestiaryEntry.setTitleResourceId(R.string.bestiary_king_ghost_title);
break;

default:
bestiaryEntry.setTargetableItem(DisplayableItemFactory.createEasyGhost());
bestiaryEntry.setImageResourceId(R.drawable.ghost);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class DisplayableItemFactory {
public final static int TYPE_BABY_GHOST = 0x00000003;
public final static int TYPE_GHOST_WITH_HELMET = 0x00000004;
public final static int TYPE_HIDDEN_GHOST = 0x00000005;
public final static int TYPE_KING_GHOST = 0x00000006;

private static final int DEFAULT_X_MIN_IN_DEGREE = -170;
private static final int DEFAULT_X_MAX_IN_DEGREE = 170;
Expand All @@ -18,18 +19,21 @@ public class DisplayableItemFactory {
public final static int HEALTH_BABY_GHOST = 1;
public final static int HEALTH_GHOST_WITH_HELMET = 5;
public final static int HEALTH_HIDDEN_GHOST = 1;
public final static int HEALTH_KING_GHOST = 1;

//Base Point
public final static int BASE_POINT_EAST_GHOST = 1;
public final static int BASE_POINT_BABY_GHOST = 2;
public final static int BASE_POINT_GHOST_WITH_HELMET = 10;
public final static int BASE_POINT_HIDDEN_GHOST = 2;
public final static int BASE_POINT_KING_GHOST = 0;

//Exp Point
public final static int EXP_POINT_EASY_GHOST = 2;
public final static int EXP_POINT_BABY_GHOST = 4;
public final static int EXP_POINT_GHOST_WITH_HELMET = 10;
public final static int EXP_POINT_HIDDEN_GHOST = 5;
public final static int EXP_POINT_KING_GHOST = 0;


public static TargetableItem createGhostWithRandomCoordinates(int ghostType) {
Expand All @@ -52,8 +56,11 @@ public static TargetableItem createGhostWithRandomCoordinates(int ghostType, int
case TYPE_HIDDEN_GHOST:
targetableItem = createHiddenGhost();
break;
}

case TYPE_KING_GHOST:
targetableItem = createKingGhost();
break;
}
targetableItem.setRandomCoordinates(xMin, xMax, yMin, yMax);
return targetableItem;
}
Expand Down Expand Up @@ -87,6 +94,13 @@ public static TargetableItem createHiddenGhost() {
EXP_POINT_HIDDEN_GHOST);
}

public static TargetableItem createKingGhost() {
return createTargetableItem(TYPE_KING_GHOST,
HEALTH_KING_GHOST,
BASE_POINT_KING_GHOST,
EXP_POINT_KING_GHOST);
}


private static TargetableItem createTargetableItem(int type, int health, int basePoint, int expPoint) {
TargetableItem targetableItem = new TargetableItem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class GameView extends View {
private final Bitmap mTargetedBabyGhostBitmap;
private final Bitmap[] mGhostWithHelmetBitmaps;
private final Bitmap[] mGhostWithHelmetTargetedBitmaps;
private final Bitmap mKingGhost;
private final Bitmap mTargetedKingGhost;
private final Bitmap mHiddenGhost;
private final String mComboString;
private final String mScoreString;
Expand Down Expand Up @@ -76,6 +78,8 @@ public GameView(Context context, GameInformation model) {
};

mHiddenGhost = BitmapFactory.decodeResource(res, R.drawable.hidden_ghost);
mKingGhost = BitmapFactory.decodeResource(res, R.drawable.king_ghost);
mTargetedKingGhost = BitmapFactory.decodeResource(res, R.drawable.targeted_king_ghost);

mComboString = res.getString(R.string.in_game_combo_counter);
mScoreString = res.getString(R.string.in_game_score);
Expand Down Expand Up @@ -234,6 +238,9 @@ private void drawDisplayableItems(Canvas canvas) {
case DisplayableItemFactory.TYPE_HIDDEN_GHOST:
renderHiddenGhost(canvas, (TargetableItem) i, currentPos);
break;
case DisplayableItemFactory.TYPE_KING_GHOST:
renderKingGhost(canvas, (TargetableItem) i, currentPos);
break;
case DisplayableItemFactory.TYPE_BULLET_HOLE:
renderBulletHole(canvas, i);
break;
Expand Down Expand Up @@ -277,6 +284,10 @@ private void renderHiddenGhost(Canvas canvas, TargetableItem hiddenGhost, float[
renderGhost(canvas, hiddenGhost, currentPos, mHiddenGhost, mGhostTargetedBitmap);
}

private void renderKingGhost(Canvas canvas, TargetableItem kingGhost, float[] currentPos) {
renderGhost(canvas, kingGhost, currentPos, mKingGhost, mTargetedKingGhost);
}

private void renderGhost(Canvas canvas, TargetableItem ghost, float[] currentPos, Bitmap ghostBitmap, Bitmap targetedGhostBitmap) {
if (!ghost.isAlive()) {
//Ghost dead
Expand Down Expand Up @@ -369,6 +380,9 @@ public void animateDyingGhost(TargetableItem ghost) {
case DisplayableItemFactory.TYPE_GHOST_WITH_HELMET:
bitmap = mGhostWithHelmetTargetedBitmaps[4];
break;
case DisplayableItemFactory.TYPE_KING_GHOST:
bitmap = mTargetedKingGhost;
break;
default:
bitmap = mGhostTargetedBitmap;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import fr.tvbarthel.games.chasewhisply.R;
import fr.tvbarthel.games.chasewhisply.model.BestiaryEntry;
import fr.tvbarthel.games.chasewhisply.ui.BestiaryEntryAdapter;
import fr.tvbarthel.games.chasewhisply.model.BestiaryEntryFactory;
import fr.tvbarthel.games.chasewhisply.model.DisplayableItemFactory;
import fr.tvbarthel.games.chasewhisply.ui.BestiaryEntryAdapter;

public class BestiaryFragment extends Fragment {
private ListView mBestiaryListView;
Expand All @@ -30,7 +30,8 @@ public void onActivityCreated(Bundle savedInstanceState) {
BestiaryEntryFactory.createBestiaryEntry(DisplayableItemFactory.TYPE_EASY_GHOST),
BestiaryEntryFactory.createBestiaryEntry(DisplayableItemFactory.TYPE_BABY_GHOST),
BestiaryEntryFactory.createBestiaryEntry(DisplayableItemFactory.TYPE_GHOST_WITH_HELMET),
BestiaryEntryFactory.createBestiaryEntry(DisplayableItemFactory.TYPE_HIDDEN_GHOST)
BestiaryEntryFactory.createBestiaryEntry(DisplayableItemFactory.TYPE_HIDDEN_GHOST),
BestiaryEntryFactory.createBestiaryEntry(DisplayableItemFactory.TYPE_KING_GHOST)
}));
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ChaseWhisply/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,5 @@
<string name="bestiary_ghost_with_helmet_title">Fantôme Renforcé</string>
<string name="bestiary_baby_ghost_title">Bébé Fantôme</string>
<string name="bestiary_hidden_ghost_title">Fantôme Caché</string>
<string name="bestiary_king_ghost_title">Roi des Fantômes</string>
</resources>
1 change: 1 addition & 0 deletions ChaseWhisply/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,6 @@
<string name="bestiary_ghost_with_helmet_title">Reinforced Ghost</string>
<string name="bestiary_baby_ghost_title">Baby Ghost</string>
<string name="bestiary_hidden_ghost_title">Hidden Ghost</string>
<string name="bestiary_king_ghost_title">King of Ghosts</string>

</resources>

0 comments on commit 5236f7d

Please sign in to comment.