diff --git a/AndorsTrail/res/raw/conversationlist_mikhail.json b/AndorsTrail/res/raw/conversationlist_mikhail.json
index 1359ac8fe..37e7471c6 100644
--- a/AndorsTrail/res/raw/conversationlist_mikhail.json
+++ b/AndorsTrail/res/raw/conversationlist_mikhail.json
@@ -59,7 +59,7 @@
"id":"mikhail_start_select_default",
"replies":[
{
- "nextPhraseID":"mikhail_visited",
+ "nextPhraseID":"mikhail_default",
"requires":[
{
"requireType":"questProgress",
@@ -114,9 +114,73 @@
"id":"mikhail_default",
"message":"Anything else I can help you with?",
"replies":[
+ {
+ "text":"Do you have any more tasks for me?",
+ "nextPhraseID":"mikhail_all_tasks_done",
+ "requires":[
+ {
+ "requireType":"questProgress",
+ "requireID":"mikhail_bread",
+ "value":100
+ },
+ {
+ "requireType":"questProgress",
+ "requireID":"mikhail_rats",
+ "value":100
+ }
+ ]
+ },
+ {
+ "text":"Do you have any more tasks for me?",
+ "nextPhraseID":"mikhail_bread_done",
+ "requires":[
+ {
+ "requireType":"questProgress",
+ "requireID":"mikhail_bread",
+ "value":100
+ },
+ {
+ "requireType":"questProgress",
+ "requireID":"mikhail_rats",
+ "value":100,
+ "negate":true
+ }
+ ]
+ },
+ {
+ "text":"Do you have any more tasks for me?",
+ "nextPhraseID":"mikhail_rats_done",
+ "requires":[
+ {
+ "requireType":"questProgress",
+ "requireID":"mikhail_bread",
+ "value":100,
+ "negate":true
+ },
+ {
+ "requireType":"questProgress",
+ "requireID":"mikhail_rats",
+ "value":100
+ }
+ ]
+ },
{
"text":"Do you have any tasks for me?",
- "nextPhraseID":"mikhail_tasks"
+ "nextPhraseID":"mikhail_tasks",
+ "requires":[
+ {
+ "requireType":"questProgress",
+ "requireID":"mikhail_bread",
+ "value":100,
+ "negate":true
+ },
+ {
+ "requireType":"questProgress",
+ "requireID":"mikhail_rats",
+ "value":100,
+ "negate":true
+ }
+ ]
},
{
"text":"Is there anything else you can tell me about Andor?",
@@ -142,6 +206,44 @@
}
]
},
+ {
+ "id":"mikhail_bread_done",
+ "message":"Thanks for getting me the bread. There are still the rats.",
+ "replies":[
+ {
+ "text":"What about the rats?",
+ "nextPhraseID":"mikhail_rats_select"
+ },
+ {
+ "text":"Never mind, let's talk about the other things.",
+ "nextPhraseID":"mikhail_default"
+ }
+ ]
+ },
+ {
+ "id":"mikhail_rats_done",
+ "message":"Thanks for taking care of the rats. I'd still love some bread.",
+ "replies":[
+ {
+ "text":"What about the bread?",
+ "nextPhraseID":"mikhail_bread_select"
+ },
+ {
+ "text":"Never mind, let's talk about the other things.",
+ "nextPhraseID":"mikhail_default"
+ }
+ ]
+ },
+ {
+ "id":"mikhail_all_tasks_done",
+ "message":"Not for now. Thanks for taking care of the bread and rats.",
+ "replies":[
+ {
+ "text":"Never mind, let's talk about the other things.",
+ "nextPhraseID":"mikhail_default"
+ }
+ ]
+ },
{
"id":"mikhail_andor1",
"message":"As I said, Andor went out yesterday and hasn't been back since. I'm starting to worry about him. Please go look for your brother, he said he would only be out a short while.",
diff --git a/AndorsTrail/res/xml/crossglen.tmx b/AndorsTrail/res/xml/crossglen.tmx
index f31a4bc9c..17565708d 100644
--- a/AndorsTrail/res/xml/crossglen.tmx
+++ b/AndorsTrail/res/xml/crossglen.tmx
@@ -1,245 +1,274 @@
-
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java
index c7ea8c318..591453639 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/ConversationActivity.java
@@ -223,8 +223,10 @@ public final class ConversationActivity
} else {
conversation.nameColor = oldNPCNameColor;
}
- }else{
+ } else if (conversation.isReward) {
conversation.textColor = oldRewardColor;
+ } else {
+ conversation.textColor = oldPhraseColor;
}
numberOfNewMessage--;
}
@@ -240,12 +242,12 @@ public final class ConversationActivity
} else {
if (rb == null) return;
Reply r = (Reply) rb.getTag();
- addConversationStatement(player, rb.getText().toString(), playerPhraseColor);
+ addConversationStatement(player, rb.getText().toString(), playerPhraseColor, false);
conversationState.playerSelectedReply(getResources(), r);
}
}
- private void addConversationStatement(Actor actor, String text, int textColor) {
+ private void addConversationStatement(Actor actor, String text, int textColor, boolean isReward) {
ConversationStatement s = new ConversationStatement();
if (actor != null) {
s.iconID = actor.iconID;
@@ -257,6 +259,7 @@ public final class ConversationActivity
s.nameColor = actor == player ? playerNameColor : NPCNameColor;
s.textColor = textColor;
s.isPlayerActor = actor != null && actor == player;
+ s.isReward = isReward;
conversationHistory.add(s);
numberOfNewMessage++;
statementList.clearFocus();
@@ -280,6 +283,7 @@ public final class ConversationActivity
public int nameColor;
public int textColor;
public boolean isPlayerActor;
+ public boolean isReward;
public boolean hasActor() {
return iconID != NO_ICON;
@@ -296,6 +300,7 @@ public final class ConversationActivity
dest.writeInt(nameColor);
dest.writeInt(textColor);
dest.writeByte((byte) (isPlayerActor ? 1 : 0));
+ dest.writeByte((byte) (isReward ? 1 : 0));
}
@SuppressWarnings("unused")
@@ -309,6 +314,7 @@ public final class ConversationActivity
result.nameColor = in.readInt();
result.textColor = in.readInt();
result.isPlayerActor = in.readByte() == 1;
+ result.isReward = in.readByte() == 1;
return result;
}
@@ -375,7 +381,7 @@ public final class ConversationActivity
@Override
public void onTextPhraseReached(String message, Actor actor, String phraseID) {
- addConversationStatement(actor, message, NPCPhraseColor);
+ addConversationStatement(actor, message, NPCPhraseColor, false);
}
@Override
@@ -411,7 +417,7 @@ public final class ConversationActivity
}
private void addRewardMessage(String text) {
- addConversationStatement(null, text, rewardColor);
+ addConversationStatement(null, text, rewardColor, true);
}
@Override
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/DebugInterface.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/DebugInterface.java
index 63ea37a49..625f8c5e7 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/DebugInterface.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/activity/DebugInterface.java
@@ -7,18 +7,23 @@ import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.Toast;
+
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
import com.gpl.rpg.AndorsTrail.R;
import com.gpl.rpg.AndorsTrail.context.ControllerContext;
import com.gpl.rpg.AndorsTrail.context.WorldContext;
+import com.gpl.rpg.AndorsTrail.controller.Constants;
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
+import com.gpl.rpg.AndorsTrail.view.MainView;
public final class DebugInterface {
private final ControllerContext controllerContext;
private final MainActivity mainActivity;
private final Resources res;
private final WorldContext world;
+
+ private DebugButton[] buttons;
public DebugInterface(ControllerContext controllers, WorldContext world, MainActivity mainActivity) {
this.controllerContext = controllers;
@@ -30,8 +35,18 @@ public final class DebugInterface {
public void addDebugButtons() {
if (!AndorsTrailApplication.DEVELOPMENT_DEBUGBUTTONS) return;
- addDebugButtons(new DebugButton[] {
- new DebugButton("dmg", new OnClickListener() {
+ buttons = new DebugButton[] {
+ new DebugButton("dbg", new OnClickListener() {
+ boolean hidden = false;
+ @Override
+ public void onClick(View arg0) {
+ hidden = !hidden;
+ for (int i = 1; i < buttons.length; i++) {
+ buttons[i].b.setVisibility(hidden ? View.GONE : View.VISIBLE);
+ }
+ }
+ })
+ ,new DebugButton("dmg", new OnClickListener() {
@Override
public void onClick(View arg0) {
world.model.player.damagePotential.set(500, 500);
@@ -47,7 +62,7 @@ public final class DebugInterface {
showToast(mainActivity, "DEBUG: damagePotential=1", Toast.LENGTH_SHORT);
}
})*/
- ,new DebugButton("items", new OnClickListener() {
+ ,new DebugButton("itm", new OnClickListener() {
@Override
public void onClick(View arg0) {
for (ItemType item : world.itemTypes.UNITTEST_getAllItemTypes().values()) {
@@ -57,20 +72,14 @@ public final class DebugInterface {
showToast(mainActivity, "DEBUG: added items", Toast.LENGTH_SHORT);
}
})
- /*,new DebugButton("prim", new OnClickListener() {
- @Override
- public void onClick(View arg0) {
- controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "blackwater_mountain29", "south", 0, 0);
- }
- })*/
- /*,new DebugButton("exp+=10000", new OnClickListener() {
+ ,new DebugButton("xp", new OnClickListener() {
@Override
public void onClick(View arg0) {
controllerContext.actorStatsController.addExperience(10000);
showToast(mainActivity, "DEBUG: given 10000 exp", Toast.LENGTH_SHORT);
}
- })*/
- ,new DebugButton("reset", new OnClickListener() {
+ })
+ ,new DebugButton("rst", new OnClickListener() {
@Override
public void onClick(View arg0) {
for(PredefinedMap map : world.maps.getAllMaps()) {
@@ -89,13 +98,27 @@ public final class DebugInterface {
showToast(mainActivity, "DEBUG: hp set to max", Toast.LENGTH_SHORT);
}
})
- ,new DebugButton("skill", new OnClickListener() {
+ ,new DebugButton("skl", new OnClickListener() {
@Override
public void onClick(View arg0) {
world.model.player.availableSkillIncreases += 10;
showToast(mainActivity, "DEBUG: 10 skill points", Toast.LENGTH_SHORT);
}
})
+ ,new DebugButton("spd", new OnClickListener() {
+ boolean fast = Constants.MINIMUM_INPUT_INTERVAL == Constants.MINIMUM_INPUT_INTERVAL_FAST;
+ @Override
+ public void onClick(View arg0) {
+ fast = !fast;
+ if (fast) {
+ Constants.MINIMUM_INPUT_INTERVAL = Constants.MINIMUM_INPUT_INTERVAL_FAST;
+ } else {
+ Constants.MINIMUM_INPUT_INTERVAL = Constants.MINIMUM_INPUT_INTERVAL_STD;
+ }
+ MainView.SCROLL_DURATION = Constants.MINIMUM_INPUT_INTERVAL;
+ AndorsTrailApplication.getApplicationFromActivity(mainActivity).getControllerContext().movementController.resetMovementHandler();
+ }
+ })
/*
,new DebugButton("cg", new OnClickListener() {
@Override
@@ -127,6 +150,12 @@ public final class DebugInterface {
controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "fallhaven_ne", "clothes", 0, 0);
}
})
+ ,new DebugButton("prim", new OnClickListener() {
+ @Override
+ public void onClick(View arg0) {
+ controllerContext.movementController.placePlayerAsyncAt(MapObject.MapObjectType.newmap, "blackwater_mountain29", "south", 0, 0);
+ }
+ })
,new DebugButton("rc", new OnClickListener() {
@Override
public void onClick(View arg0) {
@@ -134,7 +163,8 @@ public final class DebugInterface {
}
})
*/
- });
+ };
+ addDebugButtons(buttons);
}
private void showToast(Context context, String msg, int duration) {
@@ -144,10 +174,18 @@ public final class DebugInterface {
private static class DebugButton {
public final String text;
public final OnClickListener listener;
+ public Button b = null;
public DebugButton(String text, OnClickListener listener) {
this.text = text;
this.listener = listener;
}
+ public void makeButton(Context c, int id) {
+ b = new Button(c);
+ b.setText(text);
+ b.setTextSize(10);//res.getDimension(R.dimen.actionbar_text));
+ b.setId(id);
+ b.setOnClickListener(listener);
+ }
}
private void addDebugButton(DebugButton button, int id, RelativeLayout layout) {
@@ -159,13 +197,9 @@ public final class DebugInterface {
else
lp.addRule(RelativeLayout.RIGHT_OF, id - 1);
lp.addRule(RelativeLayout.ABOVE, R.id.main_statusview);
- Button b = new Button(mainActivity);
- b.setText(button.text);
- b.setTextSize(10);//res.getDimension(R.dimen.actionbar_text));
- b.setId(id);
- b.setLayoutParams(lp);
- b.setOnClickListener(button.listener);
- layout.addView(b);
+ button.makeButton(mainActivity, id);
+ button.b.setLayoutParams(lp);
+ layout.addView(button.b);
}
private void addDebugButtons(DebugButton[] buttons) {
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Constants.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Constants.java
index 26775eb71..cdc03d491 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Constants.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/Constants.java
@@ -19,7 +19,10 @@ public final class Constants {
public static final int EXP_FACTOR_DAMAGERESISTANCE = 9;
public static final float EXP_FACTOR_SCALING = 0.7f;
public static final int FLEE_FAIL_CHANCE_PERCENT = 20;
- public static final long MINIMUM_INPUT_INTERVAL = AndorsTrailApplication.DEVELOPMENT_FASTSPEED ? 50 : 200;
+ public static final long MINIMUM_INPUT_INTERVAL_FAST = 50;
+ public static final long MINIMUM_INPUT_INTERVAL_STD = 200;
+ //TODO restore final modifier before release
+ public static long MINIMUM_INPUT_INTERVAL = AndorsTrailApplication.DEVELOPMENT_FASTSPEED ? MINIMUM_INPUT_INTERVAL_FAST : MINIMUM_INPUT_INTERVAL_STD;
public static final int MAX_MAP_WIDTH = 33;
public static final int MAX_MAP_HEIGHT = 33;
@@ -31,6 +34,7 @@ public final class Constants {
public static final int TICKS_PER_ROUND = ROUND_DURATION / TICK_DELAY;
public static final int TICKS_PER_FULLROUND = FULLROUND_DURATION / TICK_DELAY;
public static final int SPLATTER_DURATION_MS = 20000;
+ public static final int STATUS_TEXT_AUTOHIDE_DELAY = ROUND_DURATION;
public static final ConstRange monsterWaitTurns = new ConstRange(5,1);
public static final long MAP_UNVISITED_RESPAWN_DURATION_MS = 3 * 60 * 1000; // 3 min in milliseconds
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MapController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MapController.java
index 5771a1810..4491c199c 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MapController.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MapController.java
@@ -205,7 +205,10 @@ public final class MapController {
hasUpdated = true;
}
}
- map.lastSeenLayoutHash = tileMap.getCurrentLayoutHash();
+ if (map.lastSeenLayoutHash != tileMap.getCurrentLayoutHash()) {
+ map.lastSeenLayoutHash = tileMap.getCurrentLayoutHash();
+ hasUpdated = true;
+ }
return hasUpdated;
}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java
index 2759de0bb..117c5e188 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java
@@ -52,21 +52,23 @@ public final class MonsterMovementController implements EvaluateWalkable {
}
}
- public static boolean monsterCanMoveTo(final Monster movingMonster, final PredefinedMap map, final LayeredTileMap tilemap, final CoordRect p) {
+ public static boolean monsterCanMoveTo(final Monster movingMonster, final PredefinedMap map, final LayeredTileMap tilemap, final CoordRect p, boolean ignoreAreas) {
if (tilemap != null) {
if (!tilemap.isWalkable(p)) return false;
}
if (map.getMonsterAt(p, movingMonster) != null) return false;
- for (MapObject mObj : map.eventObjects) {
- if (mObj == null) continue;
- if (!mObj.isActive) continue;
- if (!mObj.position.intersects(p)) continue;
- switch (mObj.type) {
+ if (!ignoreAreas) {
+ for (MapObject mObj : map.eventObjects) {
+ if (mObj == null) continue;
+ if (!mObj.isActive) continue;
+ if (!mObj.position.intersects(p)) continue;
+ switch (mObj.type) {
case newmap:
case keyarea:
case rest:
return false;
+ }
}
}
return true;
@@ -82,7 +84,7 @@ public final class MonsterMovementController implements EvaluateWalkable {
} else {
determineMonsterNextPosition(m, area, world.model.player.position);
- if (!monsterCanMoveTo(m, map, tileMap, m.nextPosition)) {
+ if (!monsterCanMoveTo(m, map, tileMap, m.nextPosition, area.ignoreAreas)) {
cancelCurrentMonsterMovement(m);
return;
}
@@ -152,12 +154,12 @@ public final class MonsterMovementController implements EvaluateWalkable {
private final PathFinder pathfinder = new PathFinder(Constants.MAX_MAP_WIDTH, Constants.MAX_MAP_HEIGHT, this);
public boolean findPathFor(Monster m, Coord to) {
- return pathfinder.findPathBetween(m.rectPosition, to, m.nextPosition);
+ return pathfinder.findPathBetween(m.rectPosition, to, m.nextPosition, m);
}
@Override
- public boolean isWalkable(CoordRect r) {
- return monsterCanMoveTo(null, world.model.currentMap, world.model.currentTileMap, r);
+ public boolean isWalkable(CoordRect r, Monster m) {
+ return monsterCanMoveTo(null, world.model.currentMap, world.model.currentTileMap, r, m.area.ignoreAreas);
}
public void moveMonsterToNextPosition(final Monster m, final PredefinedMap map) {
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterSpawningController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterSpawningController.java
index 830c0437e..969bab4e1 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterSpawningController.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterSpawningController.java
@@ -51,20 +51,20 @@ public final class MonsterSpawningController {
}
public boolean TEST_spawnInArea(PredefinedMap map, LayeredTileMap tileMap, MonsterSpawnArea a, MonsterType type) { return spawnInArea(map, tileMap, a, type, null); }
private boolean spawnInArea(PredefinedMap map, LayeredTileMap tileMap, MonsterSpawnArea a, MonsterType type, Coord playerPosition) {
- Coord p = getRandomFreePosition(map, tileMap, a.area, type.tileSize, playerPosition);
+ Coord p = getRandomFreePosition(map, tileMap, a, type.tileSize, playerPosition);
if (p == null) return false;
Monster m = a.spawn(p, type);
monsterSpawnListeners.onMonsterSpawned(map, m);
return true;
}
- public static Coord getRandomFreePosition(PredefinedMap map, LayeredTileMap tileMap, CoordRect area, Size requiredSize, Coord playerPosition) {
+ public static Coord getRandomFreePosition(PredefinedMap map, LayeredTileMap tileMap, MonsterSpawnArea a, Size requiredSize, Coord playerPosition) {
CoordRect p = new CoordRect(requiredSize);
for(int i = 0; i < 100; ++i) {
p.topLeft.set(
- area.topLeft.x + Constants.rnd.nextInt(area.size.width)
- ,area.topLeft.y + Constants.rnd.nextInt(area.size.height));
- if (!MonsterMovementController.monsterCanMoveTo(null, map, tileMap, p)) continue;
+ a.area.topLeft.x + Constants.rnd.nextInt(a.area.size.width)
+ ,a.area.topLeft.y + Constants.rnd.nextInt(a.area.size.height));
+ if (!MonsterMovementController.monsterCanMoveTo(null, map, tileMap, p, a.ignoreAreas)) continue;
if (playerPosition != null && p.contains(playerPosition)) continue;
return p.topLeft;
}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java
index 1183f89c8..a67c2a1b3 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MovementController.java
@@ -10,7 +10,11 @@ import com.gpl.rpg.AndorsTrail.model.ModelContainer;
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
import com.gpl.rpg.AndorsTrail.model.actor.Player;
import com.gpl.rpg.AndorsTrail.model.item.Loot;
-import com.gpl.rpg.AndorsTrail.model.map.*;
+import com.gpl.rpg.AndorsTrail.model.map.LayeredTileMap;
+import com.gpl.rpg.AndorsTrail.model.map.MapObject;
+import com.gpl.rpg.AndorsTrail.model.map.MonsterSpawnArea;
+import com.gpl.rpg.AndorsTrail.model.map.PredefinedMap;
+import com.gpl.rpg.AndorsTrail.model.map.TMXMapTranslator;
import com.gpl.rpg.AndorsTrail.resource.tiles.TileCollection;
import com.gpl.rpg.AndorsTrail.util.Coord;
import com.gpl.rpg.AndorsTrail.util.L;
@@ -19,7 +23,8 @@ import com.gpl.rpg.AndorsTrail.util.TimedMessageTask;
public final class MovementController implements TimedMessageTask.Callback {
private final ControllerContext controllers;
private final WorldContext world;
- private final TimedMessageTask movementHandler;
+ //TODO restore final modifier before release
+ private TimedMessageTask movementHandler;
public final PlayerMovementListeners playerMovementListeners = new PlayerMovementListeners();
public MovementController(ControllerContext controllers, WorldContext world) {
@@ -27,6 +32,12 @@ public final class MovementController implements TimedMessageTask.Callback {
this.world = world;
this.movementHandler = new TimedMessageTask(this, Constants.MINIMUM_INPUT_INTERVAL, false);
}
+
+ //TODO remove this method before release
+ public void resetMovementHandler() {
+ this.movementHandler.stop();
+ this.movementHandler = new TimedMessageTask(this, Constants.MINIMUM_INPUT_INTERVAL, false);
+ }
public void placePlayerAsyncAt(final MapObject.MapObjectType objectType, final String mapName, final String placeName, final int offset_x, final int offset_y) {
@@ -272,7 +283,7 @@ public final class MovementController implements TimedMessageTask.Callback {
for (MonsterSpawnArea a : map.spawnAreas) {
for (Monster m : a.monsters) {
if (tileMap.isWalkable(m.rectPosition)) continue;
- Coord p = MonsterSpawningController.getRandomFreePosition(map, tileMap, a.area, m.tileSize, playerPosition);
+ Coord p = MonsterSpawningController.getRandomFreePosition(map, tileMap, a, m.tileSize, playerPosition);
if (p == null) continue;
m.position.set(p);
}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/PathFinder.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/PathFinder.java
index 94d551756..98ad9bd49 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/PathFinder.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/PathFinder.java
@@ -1,5 +1,6 @@
package com.gpl.rpg.AndorsTrail.controller;
+import com.gpl.rpg.AndorsTrail.model.actor.Monster;
import com.gpl.rpg.AndorsTrail.util.Coord;
import com.gpl.rpg.AndorsTrail.util.CoordRect;
@@ -21,10 +22,10 @@ public class PathFinder {
}
public interface EvaluateWalkable {
- public boolean isWalkable(CoordRect r);
+ public boolean isWalkable(CoordRect r, Monster m);
}
- public boolean findPathBetween(final CoordRect from, final Coord to, CoordRect nextStep) {
+ public boolean findPathBetween(final CoordRect from, final Coord to, CoordRect nextStep, Monster m) {
int iterations = 0;
if (from.contains(to)) return false;
@@ -44,19 +45,19 @@ public class PathFinder {
if (from.isAdjacentTo(p)) return true;
- p.x -= 1; visit(nextStep, measureDistanceTo);
- p.x += 2; visit(nextStep, measureDistanceTo);
- p.x -= 1; p.y -= 1; visit(nextStep, measureDistanceTo);
- p.y += 2; visit(nextStep, measureDistanceTo);
- p.x -= 1; visit(nextStep, measureDistanceTo);
- p.x += 2; visit(nextStep, measureDistanceTo);
- p.y -= 2; visit(nextStep, measureDistanceTo);
- p.x -= 2; visit(nextStep, measureDistanceTo);
+ p.x -= 1; visit(nextStep, measureDistanceTo, m);
+ p.x += 2; visit(nextStep, measureDistanceTo, m);
+ p.x -= 1; p.y -= 1; visit(nextStep, measureDistanceTo, m);
+ p.y += 2; visit(nextStep, measureDistanceTo, m);
+ p.x -= 1; visit(nextStep, measureDistanceTo, m);
+ p.x += 2; visit(nextStep, measureDistanceTo, m);
+ p.y -= 2; visit(nextStep, measureDistanceTo, m);
+ p.x -= 2; visit(nextStep, measureDistanceTo, m);
}
return false;
}
- private void visit(CoordRect r, Coord measureDistanceTo) {
+ private void visit(CoordRect r, Coord measureDistanceTo, Monster m) {
final int x = r.topLeft.x;
final int y = r.topLeft.y;
@@ -68,7 +69,7 @@ public class PathFinder {
final int i = (y * maxWidth) + x;
if (visited[i]) return;
visited[i] = true;
- if (!map.isWalkable(r)) return;
+ if (!map.isWalkable(r, m)) return;
int dx = (measureDistanceTo.x - x);
int dy = (measureDistanceTo.y - y);
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Monster.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Monster.java
index 39d549671..b69170768 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Monster.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/actor/Monster.java
@@ -6,6 +6,7 @@ import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
import com.gpl.rpg.AndorsTrail.model.item.DropList;
import com.gpl.rpg.AndorsTrail.model.item.ItemContainer;
import com.gpl.rpg.AndorsTrail.model.item.Loot;
+import com.gpl.rpg.AndorsTrail.model.map.MonsterSpawnArea;
import com.gpl.rpg.AndorsTrail.savegames.LegacySavegameFormatReaderForMonster;
import com.gpl.rpg.AndorsTrail.util.Coord;
import com.gpl.rpg.AndorsTrail.util.CoordRect;
@@ -25,10 +26,12 @@ public final class Monster extends Actor {
private ItemContainer shopItems = null;
private final MonsterType monsterType;
+ public final MonsterSpawnArea area;
- public Monster(MonsterType monsterType) {
+ public Monster(MonsterType monsterType, MonsterSpawnArea area) {
super(monsterType.tileSize, false, monsterType.isImmuneToCriticalHits());
this.monsterType = monsterType;
+ this.area = area;
this.iconID = monsterType.iconID;
this.nextPosition = new CoordRect(new Coord(), monsterType.tileSize);
resetStatsToBaseTraits();
@@ -95,20 +98,20 @@ public final class Monster extends Actor {
// ====== PARCELABLE ===================================================================
- public static Monster newFromParcel(DataInputStream src, WorldContext world, int fileversion) throws IOException {
+ public static Monster newFromParcel(DataInputStream src, WorldContext world, int fileversion, MonsterSpawnArea area) throws IOException {
String monsterTypeId = src.readUTF();
if (fileversion < 20) {
monsterTypeId = monsterTypeId.replace(' ', '_').replace("\\'", "").toLowerCase();
}
MonsterType monsterType = world.monsterTypes.getMonsterType(monsterTypeId);
- if (fileversion < 25) return LegacySavegameFormatReaderForMonster.newFromParcel_pre_v25(src, fileversion, monsterType);
+ if (fileversion < 25) return LegacySavegameFormatReaderForMonster.newFromParcel_pre_v25(src, fileversion, monsterType, area);
- return new Monster(src, world, fileversion, monsterType);
+ return new Monster(src, world, fileversion, monsterType, area);
}
- private Monster(DataInputStream src, WorldContext world, int fileversion, MonsterType monsterType) throws IOException {
- this(monsterType);
+ private Monster(DataInputStream src, WorldContext world, int fileversion, MonsterType monsterType, MonsterSpawnArea area) throws IOException {
+ this(monsterType, area);
boolean readCombatTraits = true;
if (fileversion >= 25) readCombatTraits = src.readBoolean();
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/MapSection.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/MapSection.java
index fa95a1d6e..3fa84fd2d 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/MapSection.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/MapSection.java
@@ -7,6 +7,7 @@ public final class MapSection {
public final MapLayer layerGround;
public final MapLayer layerObjects;
public final MapLayer layerAbove;
+ public final MapLayer layerTop;
public final boolean[][] isWalkable;
private final byte[] layoutHash;
@@ -14,12 +15,14 @@ public final class MapSection {
MapLayer layerGround
, MapLayer layerObjects
, MapLayer layerAbove
+ , MapLayer layerTop
, boolean[][] isWalkable
, byte[] layoutHash
) {
this.layerGround = layerGround;
this.layerObjects = layerObjects;
this.layerAbove = layerAbove;
+ this.layerTop = layerTop;
this.isWalkable = isWalkable;
this.layoutHash = layoutHash;
}
@@ -28,6 +31,7 @@ public final class MapSection {
replaceTileLayerSection(layerGround, replaceLayersWith.layerGround, replacementArea);
replaceTileLayerSection(layerObjects, replaceLayersWith.layerObjects, replacementArea);
replaceTileLayerSection(layerAbove, replaceLayersWith.layerAbove, replacementArea);
+ replaceTileLayerSection(layerTop, replaceLayersWith.layerTop, replacementArea);
if (replaceLayersWith.isWalkable != null) {
final int dy = replacementArea.topLeft.y;
final int height = replacementArea.size.height;
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/MonsterSpawnArea.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/MonsterSpawnArea.java
index cbde9931b..7279bb45d 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/MonsterSpawnArea.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/MonsterSpawnArea.java
@@ -21,6 +21,7 @@ public final class MonsterSpawnArea {
public final String[] monsterTypeIDs;
public final ArrayList monsters = new ArrayList();
public final boolean isUnique; // unique == non-respawnable
+ public final boolean ignoreAreas; //Can spawn on other game objects area.
private final String group;
public boolean isSpawning;
public final boolean isSpawningForNewGame;
@@ -32,6 +33,7 @@ public final class MonsterSpawnArea {
, String areaID
, String[] monsterTypeIDs
, boolean isUnique
+ , boolean ignoreAreas
, String group
, boolean isSpawningForNewGame
) {
@@ -41,6 +43,7 @@ public final class MonsterSpawnArea {
this.areaID = areaID;
this.monsterTypeIDs = monsterTypeIDs;
this.isUnique = isUnique;
+ this.ignoreAreas = ignoreAreas;
this.group = group;
this.isSpawningForNewGame = isSpawningForNewGame;
this.isSpawning = isSpawningForNewGame;
@@ -79,7 +82,7 @@ public final class MonsterSpawnArea {
spawn(p, context.monsterTypes.getMonsterType(monsterTypeID));
}
public Monster spawn(Coord p, MonsterType type) {
- Monster m = new Monster(type);
+ Monster m = new Monster(type, this);
m.position.set(p);
monsters.add(m);
quantity.current++;
@@ -125,7 +128,7 @@ public final class MonsterSpawnArea {
if (fileversion >= 41) isSpawning = src.readBoolean();
quantity.current = src.readInt();
for(int i = 0; i < quantity.current; ++i) {
- monsters.add(Monster.newFromParcel(src, world, fileversion));
+ monsters.add(Monster.newFromParcel(src, world, fileversion, this));
}
}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java
index aed27b394..ff5c54064 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java
@@ -92,6 +92,7 @@ public final class TMXMapTranslator {
mapObjects.add(MapObject.createMapChangeArea(position, object.name, map, place, group.name));
} else if (object.type.equalsIgnoreCase("spawn")) {
boolean isActiveForNewGame = true;
+ boolean ignoreAreas = false;
int maxQuantity = 1;
int spawnChance = 10;
String spawnGroup = object.name;
@@ -108,6 +109,8 @@ public final class TMXMapTranslator {
spawnChance = Integer.parseInt(p.value);
} else if (p.name.equalsIgnoreCase("active")) {
isActiveForNewGame = Boolean.parseBoolean(p.value);
+ } else if (p.name.equalsIgnoreCase("ignoreAreas")) {
+ ignoreAreas = Boolean.parseBoolean(p.value);
} else if (p.name.equalsIgnoreCase("spawngroup")) {
spawnGroup = p.value;
} else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
@@ -135,6 +138,7 @@ public final class TMXMapTranslator {
,object.name
,monsterTypeIDs
,isUnique
+ ,ignoreAreas
,group.name
,isActiveForNewGame
);
@@ -239,9 +243,10 @@ public final class TMXMapTranslator {
private static final String LAYERNAME_GROUND = "ground";
private static final String LAYERNAME_OBJECTS = "objects";
private static final String LAYERNAME_ABOVE = "above";
+ private static final String LAYERNAME_TOP = "top";
private static final String LAYERNAME_WALKABLE = "walkable";
private static final String PROPNAME_FILTER = "colorfilter";
- private static final SetOfLayerNames defaultLayerNames = new SetOfLayerNames(LAYERNAME_GROUND, LAYERNAME_OBJECTS, LAYERNAME_ABOVE, LAYERNAME_WALKABLE);
+ private static final SetOfLayerNames defaultLayerNames = new SetOfLayerNames(LAYERNAME_GROUND, LAYERNAME_OBJECTS, LAYERNAME_ABOVE, LAYERNAME_TOP, LAYERNAME_WALKABLE);
private static LayeredTileMap transformMap(TMXLayerMap map, TileCache tileCache) {
final Size mapSize = new Size(map.width, map.height);
@@ -286,6 +291,7 @@ public final class TMXMapTranslator {
if (prop.name.equalsIgnoreCase(LAYERNAME_GROUND)) layerNames.groundLayerName = prop.value;
else if (prop.name.equalsIgnoreCase(LAYERNAME_OBJECTS)) layerNames.objectsLayerName = prop.value;
else if (prop.name.equalsIgnoreCase(LAYERNAME_ABOVE)) layerNames.aboveLayersName = prop.value;
+ else if (prop.name.equalsIgnoreCase(LAYERNAME_TOP)) layerNames.topLayersName = prop.value;
else if (prop.name.equalsIgnoreCase(LAYERNAME_WALKABLE)) layerNames.walkableLayersName = prop.value;
else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
if (!requirementPropertiesNames.contains(prop.name))
@@ -327,9 +333,10 @@ public final class TMXMapTranslator {
final MapLayer layerGround = transformMapLayer(layersPerLayerName, layerNames.groundLayerName, srcMap, tileCache, area, usedTileIDs);
final MapLayer layerObjects = transformMapLayer(layersPerLayerName, layerNames.objectsLayerName, srcMap, tileCache, area, usedTileIDs);
final MapLayer layerAbove = transformMapLayer(layersPerLayerName, layerNames.aboveLayersName, srcMap, tileCache, area, usedTileIDs);
+ final MapLayer layerTop = transformMapLayer(layersPerLayerName, layerNames.topLayersName, srcMap, tileCache, area, usedTileIDs);
boolean[][] isWalkable = transformWalkableMapLayer(findLayer(layersPerLayerName, layerNames.walkableLayersName, srcMap.name), area);
byte[] layoutHash = calculateLayoutHash(srcMap, layersPerLayerName, layerNames);
- return new MapSection(layerGround, layerObjects, layerAbove, isWalkable, layoutHash);
+ return new MapSection(layerGround, layerObjects, layerAbove, layerTop, isWalkable, layoutHash);
}
private static TMXLayer findLayer(HashMap layersPerLayerName, String layerName, String mapName) {
@@ -430,17 +437,20 @@ public final class TMXMapTranslator {
public String groundLayerName;
public String objectsLayerName;
public String aboveLayersName;
+ public String topLayersName;
public String walkableLayersName;
public SetOfLayerNames() {
this.groundLayerName = null;
this.objectsLayerName = null;
this.aboveLayersName = null;
+ this.topLayersName = null;
this.walkableLayersName = null;
}
- public SetOfLayerNames(String groundLayerName, String objectsLayerName, String aboveLayersName, String walkableLayersName) {
+ public SetOfLayerNames(String groundLayerName, String objectsLayerName, String aboveLayersName, String topLayersName, String walkableLayersName) {
this.groundLayerName = groundLayerName;
this.objectsLayerName = objectsLayerName;
this.aboveLayersName = aboveLayersName;
+ this.topLayersName = topLayersName;
this.walkableLayersName = walkableLayersName;
}
}
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/savegames/LegacySavegameFormatReaderForMonster.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/savegames/LegacySavegameFormatReaderForMonster.java
index 2e34a8c4d..2b88477f8 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/savegames/LegacySavegameFormatReaderForMonster.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/savegames/LegacySavegameFormatReaderForMonster.java
@@ -2,14 +2,15 @@ package com.gpl.rpg.AndorsTrail.savegames;
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
import com.gpl.rpg.AndorsTrail.model.actor.MonsterType;
+import com.gpl.rpg.AndorsTrail.model.map.MonsterSpawnArea;
import com.gpl.rpg.AndorsTrail.util.Coord;
import java.io.DataInputStream;
import java.io.IOException;
public final class LegacySavegameFormatReaderForMonster {
- public static Monster newFromParcel_pre_v25(DataInputStream src, int fileversion, MonsterType monsterType) throws IOException {
- Monster m = new Monster(monsterType);
+ public static Monster newFromParcel_pre_v25(DataInputStream src, int fileversion, MonsterType monsterType, MonsterSpawnArea area) throws IOException {
+ Monster m = new Monster(monsterType, area);
m.position.set(new Coord(src, fileversion));
m.ap.current = src.readInt();
m.health.current = src.readInt();
diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java
index 58b8dc3f4..13be68be7 100644
--- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java
+++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/view/MainView.java
@@ -101,7 +101,8 @@ public final class MainView extends SurfaceView
private boolean scrolling = false;
private Coord scrollVector;
private long scrollStartTime;
- private final static long SCROLL_DURATION = Constants.MINIMUM_INPUT_INTERVAL;
+ //TODO restore private final modifiers before release
+ public static long SCROLL_DURATION = Constants.MINIMUM_INPUT_INTERVAL;
public MainView(Context context, AttributeSet attr) {
@@ -481,9 +482,8 @@ public final class MainView extends SurfaceView
}
private void doDrawRect_Above(Canvas canvas, CoordRect area) {
- if (!tryDrawMapBitmap(canvas, area, aboveBitmap)) {
- tryDrawMapLayer(canvas, area, currentTileMap.currentLayout.layerAbove);
- }
+ tryDrawMapLayer(canvas, area, currentTileMap.currentLayout.layerAbove);
+ tryDrawMapLayer(canvas, area, currentTileMap.currentLayout.layerTop);
if (model.uiSelections.selectedPosition != null) {
if (model.uiSelections.selectedMonster != null) {