Work in progress on moving ui dependencies away from model.

This commit is contained in:
Oskar Wiksten
2013-01-12 20:29:19 +01:00
parent e3ea3342c5
commit 32e9a92fef
5 changed files with 19 additions and 15 deletions

View File

@@ -147,11 +147,12 @@ public final class WorldSetup {
}
private void createNewWorld() {
Context ctx = androidContext.get();
world.model = new ModelContainer();
world.model.player.initializeNewPlayer(world.itemTypes, world.dropLists, newHeroName);
view.actorStatsController.recalculatePlayerStats(world.model.player);
view.movementController.respawnPlayer();
view.movementController.respawnPlayer(ctx.getResources());
view.controller.lotsOfTimePassed();
}

View File

@@ -1,6 +1,6 @@
package com.gpl.rpg.AndorsTrail.controller;
import java.util.HashSet;
import java.util.ArrayList;
import android.os.Handler;
import android.os.Message;
@@ -34,7 +34,7 @@ public final class CombatController implements VisualEffectCompletedCallback {
public final CombatTurnListeners combatTurnListeners = new CombatTurnListeners();
private Monster currentActiveMonster = null;
private final HashSet<Loot> killedMonsterBags = new HashSet<Loot>();
private final ArrayList<Loot> killedMonsterBags = new ArrayList<Loot>();
private int totalExpThisFight = 0;
public CombatController(ViewContext view, WorldContext world) {
@@ -442,7 +442,7 @@ public final class CombatController implements VisualEffectCompletedCallback {
}
damage -= target.getDamageResistance();
if (damage < 0) damage = 0;
view.actorStatsController.removeActorHealth(world.model.player, damage);
view.actorStatsController.removeActorHealth(target, damage);
applyAttackHitStatusEffects(attacker, target);

View File

@@ -31,7 +31,7 @@ public final class Controller {
if (o.map == null || o.place == null) return;
int offset_x = position.x - o.position.topLeft.x;
int offset_y = position.y - o.position.topLeft.y;
view.movementController.placePlayerAt(MapObject.MAPEVENT_NEWMAP, o.map, o.place, offset_x, offset_y);
view.movementController.placePlayerAsyncAt(MapObject.MAPEVENT_NEWMAP, o.map, o.place, offset_x, offset_y);
break;
case MapObject.MAPEVENT_REST:
steppedOnRestArea(o);
@@ -69,7 +69,7 @@ public final class Controller {
if (lostExp < 0) lostExp = 0;
view.actorStatsController.addExperience(-lostExp);
world.model.statistics.addPlayerDeath(lostExp);
view.movementController.respawnPlayer();
view.movementController.respawnPlayerAsync();
lotsOfTimePassed();
worldEventListeners.onPlayerDied(lostExp);
}

View File

@@ -33,7 +33,7 @@ public final class MovementController implements TimedMessageTask.Callback {
this.movementHandler = new TimedMessageTask(this, Constants.MINIMUM_INPUT_INTERVAL, false);
}
public void placePlayerAt(final int objectType, final String mapName, final String placeName, final int offset_x, final int offset_y) {
public void placePlayerAsyncAt(final int objectType, final String mapName, final String placeName, final int offset_x, final int offset_y) {
AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
@Override
@@ -48,7 +48,6 @@ public final class MovementController implements TimedMessageTask.Callback {
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
playerMovementListeners.onPlayerEnteredNewMap(world.model.currentMap, world.model.player.position);
stopMovement();
view.gameRoundController.resume();
}
@@ -85,6 +84,8 @@ public final class MovementController implements TimedMessageTask.Callback {
refreshMonsterAggressiveness(newMap, model.player);
view.effectController.updateSplatters(newMap);
playerMovementListeners.onPlayerEnteredNewMap(world.model.currentMap, world.model.player.position);
}
private void playerVisitsMapFirstTime(PredefinedMap m) {
@@ -231,8 +232,11 @@ public final class MovementController implements TimedMessageTask.Callback {
}
}
public void respawnPlayer() {
placePlayerAt(MapObject.MAPEVENT_REST, world.model.player.getSpawnMap(), world.model.player.getSpawnPlace(), 0, 0);
public void respawnPlayer(Resources res) {
placePlayerAt(res, MapObject.MAPEVENT_REST, world.model.player.getSpawnMap(), world.model.player.getSpawnPlace(), 0, 0);
}
public void respawnPlayerAsync() {
placePlayerAsyncAt(MapObject.MAPEVENT_REST, world.model.player.getSpawnMap(), world.model.player.getSpawnPlace(), 0, 0);
}
public static void moveBlockedActors(final WorldContext world) {

View File

@@ -170,7 +170,6 @@ public final class MainView extends SurfaceView
private static final int REDRAW_ALL_PLAYER_MOVED = 3;
private static final int REDRAW_AREA_MONSTER_MOVED = 4;
private static final int REDRAW_AREA_MONSTER_KILLED = 10;
private static final int REDRAW_AREA_EFFECT_STARTING = 5;
private static final int REDRAW_AREA_EFFECT_COMPLETED = 6;
private static final int REDRAW_AREA_MONSTER_SPAWNED = 11;
private static final int REDRAW_TILE_SELECTION_REMOVED = 7;
@@ -178,14 +177,14 @@ public final class MainView extends SurfaceView
private static final int REDRAW_TILE_BAG = 9;
private static final int REDRAW_TILE_SPLATTER = 12;
public void redrawAll(int why) {
private void redrawAll(int why) {
redrawArea_(mapViewArea);
}
public void redrawTile(final Coord p, int why) {
private void redrawTile(final Coord p, int why) {
p1x1.topLeft.set(p);
redrawArea_(p1x1);
}
public void redrawArea(final CoordRect area, int why) {
private void redrawArea(final CoordRect area, int why) {
redrawArea_(area);
}
private void redrawArea_(CoordRect area) {
@@ -220,7 +219,7 @@ public final class MainView extends SurfaceView
return true;
}
private final Rect redrawRect = new Rect();
public void redrawAreaWithEffect(final VisualEffectAnimation effect, int tileID, int textYOffset) {
private void redrawAreaWithEffect(final VisualEffectAnimation effect, int tileID, int textYOffset) {
CoordRect area = effect.area;
if (!hasSurface) return;
if (shouldRedrawEverythingForVisualEffect()) area = mapViewArea;