mirror of
https://github.com/AndorsTrailRelease/andors-trail.git
synced 2026-02-13 21:28:10 +01:00
Version 0.6.3 . Fixed FC issues, health when levelup. Merged from local r29.
git-svn-id: https://andors-trail.googlecode.com/svn/trunk@6 08aca716-68be-ccc6-4d58-36f5abd142ac
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.gpl.rpg.AndorsTrail"
|
||||
android:versionCode="7"
|
||||
android:versionName="0.6.1"
|
||||
android:versionCode="9"
|
||||
android:versionName="0.6.3"
|
||||
android:installLocation="auto"
|
||||
>
|
||||
<uses-sdk
|
||||
@@ -33,6 +33,7 @@
|
||||
<activity android:name=".activity.ConversationActivity" android:theme="@android:style/Theme.Dialog" />
|
||||
<activity android:name=".activity.ShopActivity" />
|
||||
<activity android:name=".activity.AboutActivity" />
|
||||
<activity android:name=".activity.LoadingActivity" />
|
||||
</application>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
|
||||
@@ -202,6 +202,7 @@
|
||||
You are however of course free to explore Crossglen village as much as you like.\n
|
||||
This inital release is intended as a bug-hunt before we start adding content.\n
|
||||
Please visit the homepage to get more info or to contribute to the project (see "about").\n
|
||||
Thanks for all the feedback! This version should hopefully solve the FCs.\n
|
||||
</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -16,7 +16,7 @@ public final class AndorsTrailApplication extends Application {
|
||||
public static final boolean DEVELOPMENT_DEBUGBUTTONS = false;
|
||||
public static final boolean DEVELOPMENT_VALIDATEDATA = false;
|
||||
public static final boolean DEVELOPMENT_DEBUGMESSAGES = false;
|
||||
public static final int CURRENT_VERSION = 5;
|
||||
public static final int CURRENT_VERSION = 9;
|
||||
|
||||
public final WorldContext world = new WorldContext();
|
||||
public WorldSetup setup = new WorldSetup(world, this);
|
||||
|
||||
@@ -120,6 +120,7 @@ public final class WorldSetup {
|
||||
FileOutputStream fos = androidContext.openFileOutput(FILENAME_SAVEGAME, Context.MODE_PRIVATE);
|
||||
DataOutputStream dest = new DataOutputStream(fos);
|
||||
final int flags = 0;
|
||||
dest.writeInt(AndorsTrailApplication.CURRENT_VERSION);
|
||||
world.maps.writeToParcel(dest, flags);
|
||||
world.model.writeToParcel(dest, flags);
|
||||
dest.close();
|
||||
@@ -132,8 +133,10 @@ public final class WorldSetup {
|
||||
try {
|
||||
FileInputStream fos = androidContext.openFileInput(FILENAME_SAVEGAME);
|
||||
DataInputStream src = new DataInputStream(fos);
|
||||
world.maps.readFromParcel(src, world);
|
||||
world.model = new ModelContainer(src, world);
|
||||
int fileversion = src.readInt();
|
||||
if (fileversion == 11) fileversion = 5;
|
||||
world.maps.readFromParcel(src, world, fileversion);
|
||||
world.model = new ModelContainer(src, world, fileversion);
|
||||
src.close();
|
||||
fos.close();
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -113,6 +113,7 @@ public final class LevelUpActivity extends Activity {
|
||||
switch (selectionID) {
|
||||
case SELECT_HEALTH:
|
||||
player.health.max += Controller.LEVELUP_EFFECT_HEALTH;
|
||||
player.traits.maxHP += Controller.LEVELUP_EFFECT_HEALTH;
|
||||
player.health.current += Controller.LEVELUP_EFFECT_HEALTH;
|
||||
break;
|
||||
case SELECT_ATK_CH:
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.gpl.rpg.AndorsTrail.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.Window;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup.OnSceneLoadedListener;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
|
||||
public class LoadingActivity extends Activity implements OnSceneLoadedListener {
|
||||
|
||||
private static final int DIALOG_LOADING = 1;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
L.log("LoadingActivity::onCreate");
|
||||
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
|
||||
showDialog(DIALOG_LOADING);
|
||||
app.setup.startCharacterSetup(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSceneLoaded() {
|
||||
L.log("LoadingActivity::onSceneLoaded");
|
||||
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
app.setup.createNewCharacter = false;
|
||||
removeDialog(DIALOG_LOADING);
|
||||
|
||||
startActivity(new Intent(this, MainActivity.class));
|
||||
this.finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(final int id) {
|
||||
switch(id) {
|
||||
case DIALOG_LOADING:
|
||||
ProgressDialog dialog = new ProgressDialog(this);
|
||||
dialog.setMessage(getResources().getText(R.string.dialog_loading_message));
|
||||
dialog.setIndeterminate(true);
|
||||
dialog.setCancelable(false);
|
||||
return dialog;
|
||||
}
|
||||
return super.onCreateDialog(id);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import com.gpl.rpg.AndorsTrail.Dialogs;
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.R;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup;
|
||||
import com.gpl.rpg.AndorsTrail.WorldSetup.OnSceneLoadedListener;
|
||||
import com.gpl.rpg.AndorsTrail.context.ViewContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.ModelContainer;
|
||||
@@ -18,8 +17,6 @@ import com.gpl.rpg.AndorsTrail.view.MainView;
|
||||
import com.gpl.rpg.AndorsTrail.view.StatusView;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
@@ -34,10 +31,8 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class MainActivity extends Activity implements OnSceneLoadedListener {
|
||||
public class MainActivity extends Activity {
|
||||
|
||||
private static final int DIALOG_LOADING = 1;
|
||||
|
||||
public static final int INTENTREQUEST_HEROINFO = 1;
|
||||
public static final int INTENTREQUEST_MONSTERENCOUNTER = 2;
|
||||
public static final int INTENTREQUEST_ITEMINFO = 3;
|
||||
@@ -60,47 +55,15 @@ public class MainActivity extends Activity implements OnSceneLoadedListener {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
L.log("onCreate");
|
||||
//Debug.startMethodTracing(ICICLE_KEY);
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
this.world = app.world;
|
||||
|
||||
//Debug.startMethodTracing(ICICLE_KEY);
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
showDialog(DIALOG_LOADING);
|
||||
app.setup.startCharacterSetup(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
switch (requestCode) {
|
||||
case INTENTREQUEST_HEROINFO:
|
||||
statusview.update();
|
||||
combatview.updatePlayerAP(world.model.player.ap);
|
||||
break;
|
||||
case INTENTREQUEST_MONSTERENCOUNTER:
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
view.combatController.enterCombat();
|
||||
} else {
|
||||
view.combatController.exitCombat();
|
||||
}
|
||||
break;
|
||||
case INTENTREQUEST_CONVERSATION:
|
||||
statusview.update();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSceneLoaded() {
|
||||
L.log("onSceneLoaded");
|
||||
|
||||
AndorsTrailApplication app = AndorsTrailApplication.getApplicationFromActivity(this);
|
||||
this.view = new ViewContext(app, this);
|
||||
this.view = new ViewContext(app, this);
|
||||
app.currentView = new WeakReference<ViewContext>(this.view);
|
||||
app.setup.createNewCharacter = false;
|
||||
|
||||
|
||||
setContentView(R.layout.main);
|
||||
mainview = (MainView) findViewById(R.id.main_mainview);
|
||||
statusview = (StatusView) findViewById(R.id.main_statusview);
|
||||
@@ -121,8 +84,6 @@ public class MainActivity extends Activity implements OnSceneLoadedListener {
|
||||
}
|
||||
|
||||
view.controller.resume();
|
||||
|
||||
removeDialog(DIALOG_LOADING);
|
||||
|
||||
if (AndorsTrailApplication.DEVELOPMENT_DEBUGBUTTONS) {
|
||||
addDebugButtons(new DebugButton[] {
|
||||
@@ -166,6 +127,27 @@ public class MainActivity extends Activity implements OnSceneLoadedListener {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
switch (requestCode) {
|
||||
case INTENTREQUEST_HEROINFO:
|
||||
statusview.update();
|
||||
combatview.updatePlayerAP(world.model.player.ap);
|
||||
break;
|
||||
case INTENTREQUEST_MONSTERENCOUNTER:
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
view.combatController.enterCombat();
|
||||
} else {
|
||||
view.combatController.exitCombat(false);
|
||||
}
|
||||
break;
|
||||
case INTENTREQUEST_CONVERSATION:
|
||||
statusview.update();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private class DebugButton {
|
||||
public final String text;
|
||||
@@ -236,19 +218,6 @@ public class MainActivity extends Activity implements OnSceneLoadedListener {
|
||||
view.controller.resume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(final int id) {
|
||||
switch(id) {
|
||||
case DIALOG_LOADING:
|
||||
ProgressDialog dialog = new ProgressDialog(this);
|
||||
dialog.setMessage(getResources().getText(R.string.dialog_loading_message));
|
||||
dialog.setIndeterminate(true);
|
||||
dialog.setCancelable(false);
|
||||
return dialog;
|
||||
}
|
||||
return super.onCreateDialog(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
menu.add(R.string.exit_to_menu)
|
||||
|
||||
@@ -130,7 +130,7 @@ public class StartScreenActivity extends Activity {
|
||||
final WorldSetup setup = AndorsTrailApplication.getApplicationFromActivity(this).setup;
|
||||
setup.createNewCharacter = createNewCharacter;
|
||||
setup.newHeroName = name;
|
||||
startActivity(new Intent(this, MainActivity.class));
|
||||
startActivity(new Intent(this, LoadingActivity.class));
|
||||
}
|
||||
|
||||
private void createNewGame() {
|
||||
|
||||
@@ -46,27 +46,27 @@ public final class CombatController {
|
||||
context.mainActivity.clearMessages();
|
||||
newPlayerTurn();
|
||||
}
|
||||
public void exitCombat() {
|
||||
public void exitCombat(boolean displayLootDialog) {
|
||||
setCombatSelection(null, null);
|
||||
context.mainActivity.combatview.setVisibility(View.GONE);
|
||||
model.uiSelections.isInCombat = false;
|
||||
context.mainActivity.clearMessages();
|
||||
currentActiveMonster = null;
|
||||
if (!killedMonsters.isEmpty()) {
|
||||
lootMonsters(killedMonsters);
|
||||
lootMonsters(killedMonsters, displayLootDialog);
|
||||
killedMonsters.clear();
|
||||
}
|
||||
context.controller.queueAnotherTick();
|
||||
}
|
||||
|
||||
private void lootMonsters(ArrayList<Monster> killedMonsters) {
|
||||
private void lootMonsters(ArrayList<Monster> killedMonsters, boolean displayLootDialog) {
|
||||
Loot loot = model.currentMap.getBagOrCreateAt(killedMonsters.get(0).position);
|
||||
for(Monster m : killedMonsters) {
|
||||
m.createLoot(loot);
|
||||
model.statistics.addMonsterKill(m.monsterType);
|
||||
}
|
||||
if (loot.isEmpty()) return;
|
||||
Dialogs.showMonsterLoot(context.mainActivity, context, loot);
|
||||
if (displayLootDialog) Dialogs.showMonsterLoot(context.mainActivity, context, loot);
|
||||
ItemController.consumeLoot(loot, model.player);
|
||||
context.mainActivity.statusview.update();
|
||||
}
|
||||
@@ -134,7 +134,7 @@ public final class CombatController {
|
||||
} else if (world.model.uiSelections.selectedPosition != null) {
|
||||
executeMove();
|
||||
} else if (canExitCombat()) {
|
||||
exitCombat();
|
||||
exitCombat(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ public final class CombatController {
|
||||
killedMonsters.add(target);
|
||||
Monster nextMonster = getAdjacentMonster();
|
||||
if (nextMonster == null) {
|
||||
exitCombat();
|
||||
exitCombat(true);
|
||||
} else {
|
||||
setCombatSelection(nextMonster, nextMonster.position);
|
||||
}
|
||||
@@ -262,7 +262,7 @@ public final class CombatController {
|
||||
message(r.getString(R.string.combat_result_monsterhit, monsterName, attack.damage));
|
||||
}
|
||||
if (attack.targetDied) {
|
||||
exitCombat();
|
||||
exitCombat(false);
|
||||
context.controller.handlePlayerDeath();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ public final class Controller {
|
||||
}
|
||||
|
||||
public void handlePlayerDeath() {
|
||||
view.effectController.waitForCurrentEffect();
|
||||
final Player player = model.player;
|
||||
int lostExp = player.levelExperience.current / (100 / PERCENT_EXP_LOST_WHEN_DIED);
|
||||
player.addExperience(-lostExp);
|
||||
|
||||
@@ -91,6 +91,7 @@ public final class EffectController {
|
||||
|
||||
private void setCurrentTile(int currentFrame) {
|
||||
if (currentFrame > effect.lastFrame) currentFrame = effect.lastFrame;
|
||||
if (currentFrame < 0) currentFrame = 0;
|
||||
int newTileID = effect.frameIconIDs[currentFrame];
|
||||
final boolean changed = newTileID != this.currentTileID;
|
||||
this.currentTileID = newTileID;
|
||||
|
||||
@@ -42,12 +42,12 @@ public class CombatTraits {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public CombatTraits(DataInputStream src) throws IOException {
|
||||
public CombatTraits(DataInputStream src, int fileversion) throws IOException {
|
||||
this.attackCost = src.readInt();
|
||||
this.attackChance = src.readInt();
|
||||
this.criticalChance = src.readInt();
|
||||
this.criticalMultiplier = src.readInt();
|
||||
this.damagePotential = new Range(src);
|
||||
this.damagePotential = new Range(src, fileversion);
|
||||
this.blockChance = src.readInt();
|
||||
this.damageResistance = src.readInt();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public final class GameStatistics {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public GameStatistics(DataInputStream src, WorldContext world) throws IOException {
|
||||
public GameStatistics(DataInputStream src, WorldContext world, int fileversion) throws IOException {
|
||||
this.deaths = src.readInt();
|
||||
final int size = src.readInt();
|
||||
for(int i = 0; i < size; ++i) {
|
||||
|
||||
@@ -20,13 +20,14 @@ public final class InterfaceData {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public InterfaceData(DataInputStream src, WorldContext world) throws IOException {
|
||||
public InterfaceData(DataInputStream src, WorldContext world, int fileversion) throws IOException {
|
||||
this.isTicking = src.readBoolean();
|
||||
this.isInCombat = src.readBoolean();
|
||||
final boolean hasSelectedPosition = src.readBoolean();
|
||||
if (hasSelectedPosition) {
|
||||
this.selectedPosition = new Coord(src);
|
||||
this.selectedMonster = world.model.currentMap.getMonsterAt(selectedPosition);
|
||||
this.selectedPosition = new Coord(src, fileversion);
|
||||
} else {
|
||||
this.selectedPosition = null;
|
||||
}
|
||||
this.selectedTabHeroInfo = src.readUTF();
|
||||
}
|
||||
|
||||
@@ -67,11 +67,14 @@ public final class ModelContainer {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public ModelContainer(DataInputStream src, WorldContext world) throws IOException {
|
||||
this.player = new Player(src, world);
|
||||
public ModelContainer(DataInputStream src, WorldContext world, int fileversion) throws IOException {
|
||||
this.player = new Player(src, world, fileversion);
|
||||
this.currentMap = world.maps.findPredefinedMap(src.readUTF());
|
||||
this.uiSelections = new InterfaceData(src, world);
|
||||
this.statistics = new GameStatistics(src, world);
|
||||
this.uiSelections = new InterfaceData(src, world, fileversion);
|
||||
if (uiSelections.selectedPosition != null) {
|
||||
this.uiSelections.selectedMonster = currentMap.getMonsterAt(uiSelections.selectedPosition);
|
||||
}
|
||||
this.statistics = new GameStatistics(src, world, fileversion);
|
||||
}
|
||||
|
||||
public void writeToParcel(DataOutputStream dest, int flags) throws IOException {
|
||||
|
||||
@@ -42,11 +42,11 @@ public class Actor {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public Actor(DataInputStream src, WorldContext world) throws IOException {
|
||||
this.traits = new ActorTraits(src, world);
|
||||
this.ap = new Range(src);
|
||||
this.health = new Range(src);
|
||||
this.position = new Coord(src);
|
||||
public Actor(DataInputStream src, WorldContext world, int fileversion) throws IOException {
|
||||
this.traits = new ActorTraits(src, world, fileversion);
|
||||
this.ap = new Range(src, fileversion);
|
||||
this.health = new Range(src, fileversion);
|
||||
this.position = new Coord(src, fileversion);
|
||||
this.rectPosition = new CoordRect(position, traits.tileSize);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,15 +40,15 @@ public class ActorTraits extends CombatTraits {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public ActorTraits(DataInputStream src, WorldContext world) throws IOException {
|
||||
super(src);
|
||||
public ActorTraits(DataInputStream src, WorldContext world, int fileversion) throws IOException {
|
||||
super(src, fileversion);
|
||||
this.iconID = src.readInt();
|
||||
this.tileSize = new Size(src);
|
||||
this.tileSize = new Size(src, fileversion);
|
||||
this.maxAP = src.readInt();
|
||||
this.maxHP = src.readInt();
|
||||
this.name = src.readUTF();
|
||||
this.moveCost = src.readInt();
|
||||
this.baseCombatTraits = new CombatTraits(src);
|
||||
this.baseCombatTraits = new CombatTraits(src, fileversion);
|
||||
}
|
||||
|
||||
public void writeToParcel(DataOutputStream dest, int flags) throws IOException {
|
||||
|
||||
@@ -32,9 +32,9 @@ public final class Monster extends Actor {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public static Monster readFromParcel(DataInputStream src, WorldContext world) throws IOException {
|
||||
public static Monster readFromParcel(DataInputStream src, WorldContext world, int fileversion) throws IOException {
|
||||
MonsterType monsterType = world.monsterTypes.getMonsterType(src.readUTF());
|
||||
Coord position = new Coord(src);
|
||||
Coord position = new Coord(src, fileversion);
|
||||
Monster m = new Monster(monsterType, position);
|
||||
m.ap.current = src.readInt();
|
||||
m.health.current = src.readInt();
|
||||
|
||||
@@ -21,6 +21,9 @@ public final class MonsterTypeCollection {
|
||||
for (MonsterType t : monsterTypes) {
|
||||
if (t.name.equalsIgnoreCase(name)) return t;
|
||||
}
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("WARNING: Cannot find MonsterType for name \"" + name + "\".");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,15 +118,15 @@ public final class Player extends Actor {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public Player(DataInputStream src, WorldContext world) throws IOException {
|
||||
super(src, world);
|
||||
this.lastPosition = new Coord(src);
|
||||
this.nextPosition = new Coord(src);
|
||||
public Player(DataInputStream src, WorldContext world, int fileversion) throws IOException {
|
||||
super(src, world, fileversion);
|
||||
this.lastPosition = new Coord(src, fileversion);
|
||||
this.nextPosition = new Coord(src, fileversion);
|
||||
this.level = src.readInt();
|
||||
this.totalExperience = src.readInt();
|
||||
this.levelExperience = new Range();
|
||||
this.recalculateLevelExperience();
|
||||
this.inventory = new Inventory(src, world);
|
||||
this.inventory = new Inventory(src, world, fileversion);
|
||||
this.keys.clear();
|
||||
final int size1 = src.readInt();
|
||||
for(int i = 0; i < size1; ++i) {
|
||||
|
||||
@@ -61,8 +61,8 @@ public final class Inventory extends ItemContainer {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public Inventory(DataInputStream src, WorldContext world) throws IOException {
|
||||
super(src, world);
|
||||
public Inventory(DataInputStream src, WorldContext world, int fileversion) throws IOException {
|
||||
super(src, world, fileversion);
|
||||
gold = src.readInt();
|
||||
final int size = src.readInt();
|
||||
for(int i = 0; i < size; ++i) {
|
||||
|
||||
@@ -23,7 +23,7 @@ public class ItemContainer {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public ItemEntry(DataInputStream src, WorldContext world) throws IOException {
|
||||
public ItemEntry(DataInputStream src, WorldContext world, int fileversion) throws IOException {
|
||||
this.itemType = world.itemTypes.getItemTypeByTag(src.readUTF());
|
||||
this.quantity = src.readInt();
|
||||
}
|
||||
@@ -86,10 +86,10 @@ public class ItemContainer {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public ItemContainer(DataInputStream src, WorldContext world) throws IOException {
|
||||
public ItemContainer(DataInputStream src, WorldContext world, int fileversion) throws IOException {
|
||||
final int size = src.readInt();
|
||||
for(int i = 0; i < size; ++i) {
|
||||
items.add(new ItemEntry(src, world));
|
||||
items.add(new ItemEntry(src, world, fileversion));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,11 @@ public final class Loot {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public Loot(DataInputStream src, WorldContext world) throws IOException {
|
||||
public Loot(DataInputStream src, WorldContext world, int fileversion) throws IOException {
|
||||
this.exp = src.readInt();
|
||||
this.gold = src.readInt();
|
||||
this.items = new ItemContainer(src, world);
|
||||
this.position = new Coord(src);
|
||||
this.items = new ItemContainer(src, world, fileversion);
|
||||
this.position = new Coord(src, fileversion);
|
||||
}
|
||||
|
||||
public void writeToParcel(DataOutputStream dest, int flags) throws IOException {
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.ModelContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
@@ -13,6 +14,7 @@ import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
import com.gpl.rpg.AndorsTrail.util.Coord;
|
||||
import com.gpl.rpg.AndorsTrail.util.CoordRect;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
import com.gpl.rpg.AndorsTrail.util.Size;
|
||||
|
||||
public final class LayeredWorldMap {
|
||||
@@ -70,6 +72,12 @@ public final class LayeredWorldMap {
|
||||
if (y >= size.height) return true;
|
||||
return false;
|
||||
}
|
||||
public final boolean isOutside(final CoordRect area) {
|
||||
if (isOutside(area.topLeft)) return true;
|
||||
if (area.topLeft.x + area.size.width > size.width) return true;
|
||||
if (area.topLeft.y + area.size.height > size.height) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public MapObject findEventObject(int objectType, String name) {
|
||||
for (MapObject o : eventObjects) {
|
||||
@@ -151,6 +159,12 @@ public final class LayeredWorldMap {
|
||||
if (b != null) return b;
|
||||
b = new Loot();
|
||||
b.position.set(position);
|
||||
if (isOutside(position)) {
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("WARNING: trying to place bag outside map. Map is " + size.toString() + ", bag tried to place at " + position.toString());
|
||||
}
|
||||
return b;
|
||||
}
|
||||
groundBags.add(b);
|
||||
return b;
|
||||
}
|
||||
@@ -172,19 +186,19 @@ public final class LayeredWorldMap {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public void readFromParcel(DataInputStream src, WorldContext world) throws IOException {
|
||||
public void readFromParcel(DataInputStream src, WorldContext world, int fileversion) throws IOException {
|
||||
final int size1 = src.readInt();
|
||||
for(int i = 0; i < size1; ++i) {
|
||||
this.spawnAreas[i].readFromParcel(src, world);
|
||||
this.spawnAreas[i].readFromParcel(src, world, fileversion);
|
||||
}
|
||||
|
||||
/*
|
||||
if (fileversion <= 5) return;
|
||||
|
||||
groundBags.clear();
|
||||
final int size2 = src.readInt();
|
||||
for(int i = 0; i < size2; ++i) {
|
||||
groundBags.add(new Loot(src, world));
|
||||
groundBags.add(new Loot(src, world, fileversion));
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void writeToParcel(DataOutputStream dest, int flags) throws IOException {
|
||||
@@ -193,11 +207,9 @@ public final class LayeredWorldMap {
|
||||
a.writeToParcel(dest, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
dest.writeInt(groundBags.size());
|
||||
for(Loot l : groundBags) {
|
||||
l.writeToParcel(dest, flags);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.gpl.rpg.AndorsTrail.AndorsTrailApplication;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.util.L;
|
||||
|
||||
public final class MapCollection {
|
||||
public final ArrayList<LayeredWorldMap> predefinedMaps = new ArrayList<LayeredWorldMap>();
|
||||
@@ -16,6 +18,9 @@ public final class MapCollection {
|
||||
for (LayeredWorldMap m : predefinedMaps) {
|
||||
if (m.name.equals(name)) return m;
|
||||
}
|
||||
if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) {
|
||||
L.log("WARNING: Cannot find LayeredWorldMap for name \"" + name + "\".");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -28,10 +33,15 @@ public final class MapCollection {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public void readFromParcel(DataInputStream src, WorldContext world) throws IOException {
|
||||
final int size = src.readInt();
|
||||
public void readFromParcel(DataInputStream src, WorldContext world, int fileversion) throws IOException {
|
||||
int size;
|
||||
if (fileversion == 5) {
|
||||
size = 11;
|
||||
} else {
|
||||
size = src.readInt();
|
||||
}
|
||||
for(int i = 0; i < size; ++i) {
|
||||
predefinedMaps.get(i).readFromParcel(src, world);
|
||||
predefinedMaps.get(i).readFromParcel(src, world, fileversion);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,11 +80,11 @@ public final class MonsterSpawnArea {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public void readFromParcel(DataInputStream src, WorldContext world) throws IOException {
|
||||
public void readFromParcel(DataInputStream src, WorldContext world, int fileversion) throws IOException {
|
||||
monsters.clear();
|
||||
quantity.current = src.readInt();
|
||||
for(int i = 0; i < quantity.current; ++i) {
|
||||
monsters.add(Monster.readFromParcel(src, world));
|
||||
monsters.add(Monster.readFromParcel(src, world, fileversion));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public final class Coord {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public Coord(DataInputStream src) throws IOException {
|
||||
public Coord(DataInputStream src, int fileversion) throws IOException {
|
||||
this.x = src.readInt();
|
||||
this.y = src.readInt();
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public final class Range {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public Range(DataInputStream src) throws IOException {
|
||||
public Range(DataInputStream src, int fileversion) throws IOException {
|
||||
this.max = src.readInt();
|
||||
this.current = src.readInt();
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public final class Size {
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
public Size(DataInputStream src) throws IOException {
|
||||
public Size(DataInputStream src, int fileversion) throws IOException {
|
||||
this.width = src.readInt();
|
||||
this.height = src.readInt();
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public final class CombatView extends FrameLayout {
|
||||
@Override
|
||||
public void onClick(View arg0) {
|
||||
if (c.canExitCombat()) {
|
||||
c.exitCombat();
|
||||
c.exitCombat(true);
|
||||
} else {
|
||||
((MainActivity) context).message(getResources().getString(R.string.combat_cannotexitcombat));
|
||||
}
|
||||
|
||||
@@ -207,6 +207,9 @@ public final class MainView extends SurfaceView implements SurfaceHolder.Callbac
|
||||
}
|
||||
private void redrawArea_(final CoordRect area) {
|
||||
if (!hasSurface) return;
|
||||
final LayeredWorldMap currentMap = model.currentMap;
|
||||
boolean b = currentMap.isOutside(area);
|
||||
if (b) return;
|
||||
|
||||
calculateRedrawRect(area);
|
||||
Canvas c = null;
|
||||
@@ -229,6 +232,8 @@ public final class MainView extends SurfaceView implements SurfaceHolder.Callbac
|
||||
private final Rect redrawRect = new Rect();
|
||||
public void redrawAreaWithEffect(final CoordRect area, final EffectAnimation effect) {
|
||||
if (!hasSurface) return;
|
||||
final LayeredWorldMap currentMap = model.currentMap;
|
||||
if (currentMap.isOutside(area)) return;
|
||||
|
||||
calculateRedrawRect(area);
|
||||
Canvas c = null;
|
||||
|
||||
Reference in New Issue
Block a user