mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-01-19 01:55:04 +01:00
NPCs can now be removed from maps with conversations. A destination Phrase ID of "R" will remove the NPC.
git-svn-id: https://andors-trail.googlecode.com/svn/trunk@62 08aca716-68be-ccc6-4d58-36f5abd142ac
This commit is contained in:
@@ -33,7 +33,6 @@ import com.gpl.rpg.AndorsTrail.conversation.ConversationCollection;
|
||||
import com.gpl.rpg.AndorsTrail.conversation.Phrase;
|
||||
import com.gpl.rpg.AndorsTrail.conversation.Phrase.Reply;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.ActorTraits;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.MonsterType;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.Loot;
|
||||
@@ -41,6 +40,7 @@ import com.gpl.rpg.AndorsTrail.resource.TileStore;
|
||||
|
||||
public final class ConversationActivity extends Activity {
|
||||
public static final int ACTIVITYRESULT_ATTACK = Activity.RESULT_FIRST_USER + 1;
|
||||
public static final int ACTIVITYRESULT_REMOVE = Activity.RESULT_FIRST_USER + 2;
|
||||
private static final int playerConversationColor = Color.argb(255, 0xbb, 0x22, 0x22);
|
||||
private static final int NPCConversationColor = Color.argb(255, 0xbb, 0xbb, 0x22);
|
||||
|
||||
@@ -125,14 +125,7 @@ public final class ConversationActivity extends Activity {
|
||||
}
|
||||
|
||||
|
||||
private void markMonsterAsAgressive() {
|
||||
Monster m = world.model.currentMap.getMonsterAt(world.model.player.nextPosition);
|
||||
assert (m != null);
|
||||
assert (m.monsterType.id == monsterType.id);
|
||||
m.forceAggressive = true;
|
||||
}
|
||||
|
||||
public void setPhrase(String phraseID) {
|
||||
public void setPhrase(String phraseID) {
|
||||
this.phraseID = phraseID;
|
||||
if (phraseID.equalsIgnoreCase(ConversationCollection.PHRASE_CLOSE)) {
|
||||
ConversationActivity.this.finish();
|
||||
@@ -145,8 +138,11 @@ public final class ConversationActivity extends Activity {
|
||||
startActivityForResult(intent, MainActivity.INTENTREQUEST_SHOP);
|
||||
return;
|
||||
} else if (phraseID.equalsIgnoreCase(ConversationCollection.PHRASE_ATTACK)) {
|
||||
markMonsterAsAgressive();
|
||||
ConversationActivity.this.setResult(ACTIVITYRESULT_ATTACK);
|
||||
ConversationActivity.this.setResult(ACTIVITYRESULT_ATTACK);
|
||||
ConversationActivity.this.finish();
|
||||
return;
|
||||
} else if (phraseID.equalsIgnoreCase(ConversationCollection.PHRASE_REMOVE)) {
|
||||
ConversationActivity.this.setResult(ACTIVITYRESULT_REMOVE);
|
||||
ConversationActivity.this.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -151,12 +151,16 @@ public final class MainActivity extends Activity {
|
||||
if (resultCode == ConversationActivity.ACTIVITYRESULT_ATTACK) {
|
||||
final Coord p = world.model.player.nextPosition;
|
||||
Monster m = world.model.currentMap.getMonsterAt(p);
|
||||
if (m != null) {
|
||||
view.combatController.setCombatSelection(m, p);
|
||||
view.combatController.enterCombat(CombatController.BEGIN_TURN_PLAYER);
|
||||
} else {
|
||||
//Shouldn't happen.
|
||||
}
|
||||
if (m == null) return; //Shouldn't happen.
|
||||
m.forceAggressive = true;
|
||||
view.combatController.setCombatSelection(m, p);
|
||||
view.combatController.enterCombat(CombatController.BEGIN_TURN_PLAYER);
|
||||
} else if (resultCode == ConversationActivity.ACTIVITYRESULT_REMOVE) {
|
||||
final Coord p = world.model.player.nextPosition;
|
||||
Monster m = world.model.currentMap.getMonsterAt(p);
|
||||
if (m == null) return;
|
||||
world.model.currentMap.remove(m);
|
||||
redrawAll(MainView.REDRAW_ALL_MONSTER_KILLED);
|
||||
}
|
||||
break;
|
||||
case INTENTREQUEST_PREFERENCES:
|
||||
|
||||
@@ -22,6 +22,7 @@ public final class ConversationCollection {
|
||||
public static final String PHRASE_CLOSE = "X";
|
||||
public static final String PHRASE_SHOP = "S";
|
||||
public static final String PHRASE_ATTACK = "F";
|
||||
public static final String PHRASE_REMOVE = "R";
|
||||
public static final String REPLY_NEXT = "N";
|
||||
|
||||
private final HashMap<String, Phrase> phrases = new HashMap<String, Phrase>();
|
||||
@@ -30,6 +31,7 @@ public final class ConversationCollection {
|
||||
if (id.equals(PHRASE_CLOSE)) return true;
|
||||
else if (id.equals(PHRASE_SHOP)) return true;
|
||||
else if (id.equals(PHRASE_ATTACK)) return true;
|
||||
else if (id.equals(PHRASE_REMOVE)) return true;
|
||||
else if (phrases.containsKey(id)) return true;
|
||||
else return false;
|
||||
}
|
||||
@@ -180,6 +182,7 @@ public final class ConversationCollection {
|
||||
requiredPhrases.remove(PHRASE_ATTACK);
|
||||
requiredPhrases.remove(PHRASE_CLOSE);
|
||||
requiredPhrases.remove(PHRASE_SHOP);
|
||||
requiredPhrases.remove(PHRASE_REMOVE);
|
||||
|
||||
// Verify that all supplied phrases are required.
|
||||
for (Entry<String, Phrase> e : phrases.entrySet()) {
|
||||
@@ -238,6 +241,7 @@ public final class ConversationCollection {
|
||||
if (phraseID.equals(PHRASE_SHOP)) return true;
|
||||
if (phraseID.equals(PHRASE_ATTACK)) return false;
|
||||
if (phraseID.equals(PHRASE_CLOSE)) return false;
|
||||
if (phraseID.equals(PHRASE_REMOVE)) return false;
|
||||
if (visited.contains(phraseID)) return false;
|
||||
visited.add(phraseID);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user