public AdventureScreen(Quinoa quinoa) { dtm = new DrawManager(); this.quinoa = quinoa; this.tileOffsetX = 0; this.tileOffsetY = 0; this.targetX = 0; this.targetY = 0; this.targetMaxDistance = 1; this.inventoryTargetX = 0; this.inventoryTargetY = 0; this.tradeTargetX = 0; this.tradeTargetY = 0; this.characterIndex = 0; this.targetY = 0; this.mapSelectAction = MapSelectAction.VERB; this.mode = AdventureScreenMode.MAP; this.lastHungerStatus = ""; this.verb = ItemVerb.NULL; this.verbItem = null; this.verbIndex = 0; this.tradeMonster = null; this.tradePageIsPlayer = true; this.regionCycleCounter = Quinoa.REGION_CYCLE_FREQUENCY; }
public void doUseItem(Item item) { if(item != null) { List<ItemVerb> itemVerbs = ItemManager.getVerbs(item); if(itemVerbs.Count == 0) { //do nothing } else if(itemVerbs.Count == 1) { verbIndex = 0; verb = itemVerbs[verbIndex]; verbItem = item; targetMaxDistance = ItemManager.verbDistance(verb); if(targetMaxDistance > 0) { this.mapSelectAction = MapSelectAction.VERB; this.setMapSelectMaxDistance(targetMaxDistance); this.setMode(AdventureScreenMode.MAP_SELECT); quinoa.getUI().refresh(); } else { MonsterActionManager.setItemVerbCommand(quinoa.getPlayer(), verbItem, verb, 0, 0); this.setMode(AdventureScreenMode.MAP); quinoa.getUI().refresh(); quinoa.cycle(); } } else if(itemVerbs.Count > 1) { verbItem = item; this.setMode(AdventureScreenMode.VERB_PICK); quinoa.getUI().refresh(); } } }
public void setMode(AdventureScreenMode newMode) { switch(newMode) { case AdventureScreenMode.MAP: this.mode = AdventureScreenMode.MAP; quinoa.getUI().refresh(); break; case AdventureScreenMode.HELP: this.mode = AdventureScreenMode.HELP; quinoa.getUI().refresh(); break; case AdventureScreenMode.DIALOG: this.mode = AdventureScreenMode.DIALOG; quinoa.getUI().refresh(); break; case AdventureScreenMode.MAP_SELECT: targetX = quinoa.getPlayer().x; targetY = quinoa.getPlayer().y; switch(quinoa.getPlayer().facing) { case Direction.N: if(targetY > 0) { targetY--; } break; case Direction.S: if(targetY < quinoa.getCurrentRegionHeader().getRegion().getHeight() - 2) { targetY++; } break; case Direction.W: if(targetX > 0) { targetX--; } break; case Direction.E: if(targetX < quinoa.getCurrentRegionHeader().getRegion().getWidth() - 2) { targetX++; } break; } this.mode = AdventureScreenMode.MAP_SELECT; quinoa.getMessageManager().addMessage("Press " + charToStr(ENTER_KEY) + " to select an area."); quinoa.getUI().refresh(); break; case AdventureScreenMode.INVENTORY: this.mode = AdventureScreenMode.INVENTORY; this.inventoryTargetX = 0; this.inventoryTargetY = 0; quinoa.getUI().refresh(); break; case AdventureScreenMode.CHARACTER: this.mode = AdventureScreenMode.CHARACTER; quinoa.getUI().refresh(); break; case AdventureScreenMode.VERB_PICK: this.mode = AdventureScreenMode.VERB_PICK; quinoa.getMessageManager().addMessage("Press " + charToStr(ENTER_KEY) + " select an action."); this.verb = ItemVerb.NULL; this.verbIndex = 0; quinoa.getUI().refresh(); break; case AdventureScreenMode.TRADE: this.tradeTargetX = 0; this.tradeTargetY = 0; this.tradePageIsPlayer = true; quinoa.getMessageManager().addMessage("Press " + charToStr(ENTER_KEY) + " to sell or buy the selected item."); quinoa.getMessageManager().addMessage("Press " + charToStr(EXIT_KEY) + " to stop trading."); this.mode = AdventureScreenMode.TRADE; quinoa.getUI().refresh(); break; } }
public void processKeyVerbPick(char key, bool shift, bool alt) { if(key == AdventureScreen.ENTER_KEY) { List<ItemVerb> itemVerbs = ItemManager.getVerbs(verbItem); verb = itemVerbs[verbIndex]; this.targetMaxDistance = ItemManager.verbDistance(verb); if(targetMaxDistance > 0) { this.mapSelectAction = MapSelectAction.VERB; this.setMapSelectMaxDistance(targetMaxDistance); this.setMode(AdventureScreenMode.MAP_SELECT); quinoa.getUI().refresh(); } else { MonsterActionManager.setItemVerbCommand(quinoa.getPlayer(), verbItem, verb, quinoa.getPlayer().x, quinoa.getPlayer().y); this.setMode(AdventureScreenMode.MAP); quinoa.getUI().refresh(); quinoa.cycle(); } } else if (key == AdventureScreen.UP_KEY) { if(verbIndex > 0) { verbIndex--; } quinoa.getUI().refresh(); } else if (key == AdventureScreen.DOWN_KEY) { List<ItemVerb> itemVerbs = ItemManager.getVerbs(verbItem); if(verbIndex < itemVerbs.Count - 1) { verbIndex++; } quinoa.getUI().refresh(); } }
public static int verbDistance(ItemVerb verb) { switch (verb) { case ItemVerb.EAT: case ItemVerb.SLEEP: return 0; case ItemVerb.USE: case ItemVerb.ACTIVATE: case ItemVerb.PLACE: return 1; case ItemVerb.TRADE: return 2; case ItemVerb.TALK: return 5; case ItemVerb.LOOK: return 10; } return 0; }
public static void setItemVerbCommand(Monster monster, Item item, ItemVerb verb, int x, int y) { MonsterCommand newCommand = new MonsterCommand(); newCommand.commandCode = MonsterCommandCode.ITEM_VERB; newCommand.counter = MonsterActionManager.getSpeed(monster); if(item != null) { newCommand.addParameter("itemID", item.ID); } else { newCommand.addParameter("itemID", ""); } newCommand.addParameter("verb", EnumUtil.EnumName<ItemVerb>(verb)); newCommand.addParameter("x", x+""); newCommand.addParameter("y", y+""); monster.setCommand(newCommand); }