No. I mean like this:
Code: Select all
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Inventory.java: heroicon.setImageResource(HeroCollection.getHeroLargeSprite(player.iconID));
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/activity/fragment/HeroinfoActivity_Stats.java: tv.setCompoundDrawablesWithIntrinsicBounds(HeroCollection.getHeroLargeSprite(player.iconID), 0, 0, 0);
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/activity/HeroinfoActivity.java: world.tileManager.setImageViewTileForPlayer(getResources(), iv, world.model.player.iconID);
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java: result.setBitmap(tileID_placeholder_hero, preloadedTiles.getBitmap(world.model.player.iconID));
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java: public void setImageViewTile(Resources res, TextView textView, Player player) { setImageViewTileForPlayer(res, textView, player.iconID); }
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/resource/tiles/TileManager.java: public void setImageViewTile(Resources res, ImageView imageView, Player player) { setImageViewTileForPlayer(res, imageView, player.iconID); }
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/savegames/Savegames.java: displayInfo, world.model.player.iconID,
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/view/MainView.java: drawFromMapPosition(canvas, area, playerPosition, model.player.iconID);
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/view/MainView.java: tiles.drawTile(canvas, model.player.iconID, x, y, mPaint);
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/view/StatusView.java:// new BitmapDrawable(res, world.tileManager.preloadedTiles.getBitmap(player.iconID))
AndorsTrail/app/src/main/java/com/gpl/rpg/AndorsTrail/view/StatusView.java: world.tileManager.setImageViewTileWithOverlay(res, heroImage, TileManager.iconID_moveselect, world.tileManager.preloadedTiles.getBitmap(player.iconID), true);
Polymorphism is an object-oriented-programming (O.O.P.) abstraction concept embraced by Java, C++ and most other O.O.P. languages (some would say with negative consequences, but Android leaves little, if any, choice other than to use Java).
In A.T., the Player class inherits from (or "extends") a base class called Actor:
Code: Select all
…
public final class Player extends Actor {
…
Code: Select all
…
public final class Monster extends Actor {
…
The Introduction to Computer Science example for this is often a chess program. One may create an abstract base (or "parent") class Piece with members color, row and column and a function move(int row, int column). One may then derive child classes Rook, Knight, Bishop, Queen, King and Pawn from Piece, with different logic for each's move() function.
The collection of live pieces may then be stored, all together, as an array of Piece objects, instead of separately storing each player's various pieces. When the program executes an array member's move() function, the language maps it to the appropriate move() for the child class of that piece.
That is what we have in some places in A.T., e.g., in ActorStatsListeners.java:
Code: Select all
…
@Override
public void onActorHealthChanged(Actor actor) {
callAllListeners(this.onActorHealthChanged, actor);
}
…
But, in the A.T. code that uses the iconID, we are passing around Player and Monster references, not Actor references, even though iconID is a property of Actor, inherited by its descendants Player and Monster. See, e.g., doDrawRect_Objects() in MainView.java:
Code: Select all
…
if (!model.player.hasVFXRunning) {
drawFromMapPosition(canvas, area, playerPosition, model.player.iconID);
} else if (area.contains(playerPosition)) {
int vfxElapsedTime = (int) (System.currentTimeMillis() - model.player.vfxStartTime);
if (vfxElapsedTime > model.player.vfxDuration) vfxElapsedTime = model.player.vfxDuration;
int x = ((model.player.position.x - mapViewArea.topLeft.x) * tileSize * vfxElapsedTime + ((model.player.lastPosition.x - mapViewArea.topLeft.x) * tileSize * (model.player.vfxDuration - vfxElapsedTime))) / model.player.vfxDuration;
int y = ((model.player.position.y - mapViewArea.topLeft.y) * tileSize * vfxElapsedTime + ((model.player.lastPosition.y - mapViewArea.topLeft.y) * tileSize * (model.player.vfxDuration - vfxElapsedTime))) / model.player.vfxDuration;
tiles.drawTile(canvas, model.player.iconID, x, y, mPaint);
}
…
It will be best and likely wise to test it in a beta,
— /s/ Judoka.