public static void deerAI(Monster monster, Quinoa quinoa) { if (monster.readyForCommand()) { MonsterActionManager.setMoveCommand(monster, EnumUtil.RandomEnumValue<Direction>()); } }
public CaveGenerator(int width, int height, String name, double fillPercentage, int smoothness, Quinoa quinoa) { header = new RegionHeader(name); region = new Region(width, height); header.setRegion(region); entrance = new RegionExit(width / 2, height / 2, 0, 0, "", ExitDecorator.UP_STAIR); exit = new RegionExit(width / 2, (height / 2) + 1, 0, 0, "", ExitDecorator.DOWN_STAIR); header.getExits().Add(entrance); header.getExits().Add(exit); region.setLightingModel(LightingModel.CAVE); this.quinoa = quinoa; this.fillPercentage = fillPercentage; this.smoothness = smoothness; chambers = new List<Chamber>(); //fill with solid rock for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { region.setTerrain(x, y, new Terrain()); region.getTerrain(x, y).setCode(TerrainCode.ROCK); } } }
public MenuScreen(Quinoa quinoa) { dtm = new DrawManager(); this.quinoa = quinoa; this.savedGameExists = File.Exists(QuinoaActions.SAVED_GAME_FILENAME); quinoa.reset(); }
private IScreen screen; //currently displayed screen #endregion Fields #region Constructors public formQuinoaWindow() { InitializeComponent(); this.Text = (Quinoa.PROGRAM_NAME + " " + Quinoa.VERISON); this.Size = new Size(UI_PIXEL_WIDTH, UI_PIXEL_HEIGHT); this.quinoa = null; graphicsManager = new GraphicsManager(); }
248549595, 310686993, 388358742, 485448428, 606810535, 758513168, 948141460, 1185176826, 1481471032, 1851838791}; //times 1.25 #endregion Fields #region Methods public static void activate(Monster monster, int x, int y, Region region, Quinoa quinoa) { if(TerrainManager.hasParameter(region.getTerrain(x, y), TerrainParameter.HAS_DOOR)) { DoorCode doorCode = (DoorCode)Enum.Parse(typeof(DoorCode), (TerrainManager.getParameter(region.getTerrain(x, y), TerrainParameter.HAS_DOOR))); if(doorCode == DoorCode.CLOSED) { region.getTerrain(x, y).getParameters().Add(TerrainParameter.HAS_DOOR, EnumUtil.EnumName<DoorCode>(DoorCode.OPEN)); if(isPlayer(monster)) { quinoa.getMessageManager().addMessage("The door opens."); } } else if(doorCode == DoorCode.OPEN) { region.getTerrain(x, y).getParameters().Add(TerrainParameter.HAS_DOOR, EnumUtil.EnumName<DoorCode>(DoorCode.CLOSED)); if(isPlayer(monster)) { quinoa.getMessageManager().addMessage("The door closes."); } } } else if(TerrainManager.hasParameter(region.getTerrain(x, y), TerrainParameter.HAS_FLOODGATE)) { DoorCode doorCode = (DoorCode)Enum.Parse(typeof(DoorCode), (TerrainManager.getParameter(region.getTerrain(x, y), TerrainParameter.HAS_FLOODGATE))); if(doorCode == DoorCode.CLOSED) { region.getTerrain(x, y).getParameters().Add(TerrainParameter.HAS_FLOODGATE, EnumUtil.EnumName<DoorCode>(DoorCode.OPEN)); if(isPlayer(monster)) { quinoa.getMessageManager().addMessage("The floodgate opens."); } } else if(doorCode == DoorCode.OPEN) { region.getTerrain(x, y).getParameters().Add(TerrainParameter.HAS_FLOODGATE, EnumUtil.EnumName<DoorCode>(DoorCode.CLOSED)); if(isPlayer(monster)) { quinoa.getMessageManager().addMessage("The floodgate closes."); } } } else { if(isPlayer(monster)) { quinoa.getMessageManager().addMessage("Nothing to do there."); } } }
public TownGenerator(int width, int height, String name, int wiggle, double radius, double treeDensity, OverworldCell overworldCell, Quinoa quinoa) { header = new RegionHeader(name); region = new Region(width, height); header.setRegion(region); header.setName(NameMaker.makeTrivialPlaceName()); this.wiggle = wiggle; this.radius = radius; this.treeDensity = treeDensity; this.quinoa = quinoa; this.overworldCell = overworldCell; }
public ForestGenerator(int width, int height, String name, double treeDensity, Quinoa quinoa) { header = new RegionHeader(name); region = new Region(width, height); header.setRegion(region); region.setLightingModel(LightingModel.ABOVE_GROUND); this.quinoa = quinoa; this.treeDensity = treeDensity; //fill the forest with grass for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { region.setTerrain(x, y, new Terrain()); region.getTerrain(x, y).setCode(TerrainCode.GRASS); } } }
public static Item containsItem(ItemClass itemClass, int x, int y, Quinoa quinoa) { foreach(Item tempItem in quinoa.getCurrentRegionHeader().getRegion().getItems()) { if(tempItem.itemClass == itemClass && tempItem.x == x && tempItem.y == y) { return tempItem; } } return null; }
public static void burn(Terrain terrain, int x, int y, Quinoa quinoa) { bool dropAsh = false; //Look for items on this squares and remove them foreach(Item tempItem in quinoa.getCurrentRegionHeader().getRegion().getItems()) { if(tempItem.x == x && tempItem.y == y) { switch(tempItem.itemClass) { case ItemClass.LOG: dropAsh=true; break; default: dropAsh= false; break; } tempItem.RemoveObject(); } } //Examine terrain features if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_TREE)) { terrain.getParameters().Remove(TerrainParameter.HAS_TREE); if(RandomNumber.RandomDouble() < 0.125) { dropAsh = true; } } if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_DOOR)) { terrain.getParameters().Remove(TerrainParameter.HAS_DOOR); } if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_SIGN)) { terrain.getParameters().Remove(TerrainParameter.HAS_SIGN); } if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_MUSHROOM_SPORES)) { terrain.getParameters().Remove(TerrainParameter.HAS_MUSHROOM_SPORES); } if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_CLOVER)) { terrain.getParameters().Remove(TerrainParameter.HAS_CLOVER); } switch(terrain.getCode()) { case TerrainCode.GRASS: if(RandomNumber.RandomDouble() < 0.98) { terrain.setCode(TerrainCode.FERTILE_LAND); terrain.getParameters().Add(TerrainParameter.GROW_COUNTER, TerrainManager.GRASS_GROW_COUNT+""); if(RandomNumber.RandomDouble() < 0.001) { int cloverCount = (int)(RandomNumber.RandomDouble() * (TerrainManager.CLOVER_GROW_COUNT / 4)) + TerrainManager.CLOVER_GROW_COUNT; terrain.getParameters().Add(TerrainParameter.HAS_CLOVER, cloverCount+""); } else { if(RandomNumber.RandomDouble() < 0.001) { MushroomSporeCode msc = EnumUtil.RandomEnumValue<MushroomSporeCode>(); terrain.getParameters().Add(TerrainParameter.HAS_MUSHROOM_SPORES, EnumUtil.EnumName<MushroomSporeCode>(msc)); } } } else { terrain.setCode(TerrainCode.DIRT); } break; default: //Do nothing, does not burn break; } if(dropAsh) { Item ash = new Item(); ash.itemClass = ItemClass.ASH; ash.setPosition(x, y); quinoa.getCurrentRegionHeader().getRegion().getItems().Add(ash); } }
public static bool wetable(Terrain terrain, int x, int y, Quinoa quinoa) { if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_DOOR)) { DoorCode doorCode = (DoorCode)Enum.Parse(typeof(DoorCode),TerrainManager.getParameter(terrain, TerrainParameter.HAS_DOOR)); return (doorCode == DoorCode.OPEN); } if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_FLOODGATE)) { DoorCode doorCode = (DoorCode)Enum.Parse(typeof(DoorCode), TerrainManager.getParameter(terrain, TerrainParameter.HAS_FLOODGATE)); if(doorCode == DoorCode.OPEN) { return true; } else { return false; } } switch(terrain.getCode()) { case TerrainCode.PATH: case TerrainCode.DIRT: case TerrainCode.GRASS: case TerrainCode.STONE_FLOOR: case TerrainCode.FERTILE_LAND: case TerrainCode.STREAM_BED: return true; case TerrainCode.STONE_WALL: case TerrainCode.ROCK: default: return false; } }
public static void executePickupCommand(Monster monster, MonsterCommand command, Quinoa quinoa) { bool pickedUpAtLeastOneItem = false; Region region = quinoa.getCurrentRegionHeader().getRegion(); foreach(Item tempItem in region.getItems()) { if(tempItem.x == monster.x && tempItem.y == monster.y && !tempItem.ShouldBeRemoved) { if(monster.inventory.stackItem(tempItem)) { //Item stacked on current item tempItem.RemoveObject(); pickedUpAtLeastOneItem = true; if(isPlayer(monster)) { quinoa.getMessageManager().addMessage("Got " + EnumUtil.EnumName<ItemClass>(tempItem.itemClass) + "."); } } else { if(!monster.inventory.Full) { monster.inventory.addItem((Item)tempItem.CopyObject()); tempItem.RemoveObject(); pickedUpAtLeastOneItem = true; if(isPlayer(monster)) { quinoa.getMessageManager().addMessage("Got " + EnumUtil.EnumName<ItemClass>(tempItem.itemClass) + "."); } } else { if(isPlayer(monster)) { quinoa.getMessageManager().addMessage("Can't carry any more."); pickedUpAtLeastOneItem = true; } } } } } if(!pickedUpAtLeastOneItem) { if(isPlayer(monster)) { quinoa.getMessageManager().addMessage("Nothing to pick up there."); } } }
private int width; //Width of the current region #endregion Fields #region Constructors public LightMap(Quinoa quinoa) { this.quinoa = quinoa; }
public static void mine(Terrain terrain, int x, int y, Quinoa quinoa) { switch(terrain.getCode()) { case TerrainCode.ROCK: terrain.setCode(TerrainCode.STONE_FLOOR); if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_MINERALS)) { int mineralCode = Int32.Parse(TerrainManager.getParameter(terrain, TerrainParameter.HAS_MINERALS)); switch(mineralCode) { case 1: if(RandomNumber.RandomDouble() > 0.5) { Item gem = new Item(); gem.itemClass = ItemClass.AMETHYST; gem.setPosition(x, y); quinoa.getCurrentRegionHeader().getRegion().getItems().Add(gem); } else { //do nothing } break; case 2: if(RandomNumber.RandomDouble() > 0.5) { Item gem = new Item(); gem.itemClass = ItemClass.SAPPHIRE; gem.setPosition(x, y); quinoa.getCurrentRegionHeader().getRegion().getItems().Add(gem); } else { Item gem = new Item(); gem.itemClass = ItemClass.EMERALD; gem.setPosition(x, y); quinoa.getCurrentRegionHeader().getRegion().getItems().Add(gem); } break; case 3: if(RandomNumber.RandomDouble() > 0.33) { Item gem = new Item(); gem.itemClass = ItemClass.RUBY; gem.setPosition(x, y); quinoa.getCurrentRegionHeader().getRegion().getItems().Add(gem); } else { Item gem = new Item(); gem.itemClass = ItemClass.DIAMOND; gem.setPosition(x, y); quinoa.getCurrentRegionHeader().getRegion().getItems().Add(gem); } break; } } break; case TerrainCode.STONE_FLOOR: terrain.setCode(TerrainCode.STREAM_BED); break; case TerrainCode.STREAM_BED: if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_DRAIN)) { terrain.getParameters().Remove(TerrainParameter.HAS_DRAIN); } else { terrain.getParameters().Add(TerrainParameter.HAS_DRAIN, TerrainManager.DRAIN_RATE+""); } break; default: //do nothing break; } }
public static int fuelsFire(Terrain terrain, int x, int y, Quinoa quinoa) { if(containsItem(ItemClass.LOG, x, y, quinoa) != null) { return 10; } if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_TREE)) { return 2; } if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_DOOR)) { return 1; } if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_SIGN)) { return 1; } switch(terrain.getCode()) { default: return 0; } }
public void addCaveBranch(RegionHeader topLevel, int topX, int topY, int depth, Quinoa quinoa) { CaveGenerator lastGen = null; for(int deep=0; deep < depth; deep++) { int width = 80 + (int)(RandomNumber.RandomDouble() * 40); int height = 80 + (int)(RandomNumber.RandomDouble() * 40); int chamberCount = 3 + (int)(RandomNumber.RandomDouble() * 4); int smoothness = (int)(RandomNumber.RandomDouble() * 2); double fillPercentage = 0.45 + (RandomNumber.RandomDouble() * 0.20); CaveGenerator caveGen = new CaveGenerator(width, height, topLevel.getId() + "-cave" + deep, fillPercentage, smoothness, quinoa); caveGen.addChamber(new Chamber(5,5,caveGen.region.getWidth() - 10,caveGen.region.getHeight() - 10, ChamberType.OPEN)); for(int i=0; i < chamberCount; i++) { int caveX = 5 + (int)(RandomNumber.RandomDouble() * (caveGen.region.getWidth() - 41)); int caveY = 5 + (int)(RandomNumber.RandomDouble() * (caveGen.region.getHeight() - 41)); ChamberType type = ChamberType.NULL; if(RandomNumber.RandomDouble() < 0.20) { type = ChamberType.MUSHROOM; } else { type = ChamberType.FLOODED; } caveGen.addChamber(new Chamber(caveX,caveY,(int)(RandomNumber.RandomDouble() * 20) + 10,(int)(RandomNumber.RandomDouble() * 20) + 10, type)); } caveGen.smoothWater(); caveGen.placeExits(); caveGen.addTorches(); caveGen.addMinerals(deep+1); if(deep == depth - 1) { caveGen.addTreasure(); this.caveBottomIDs.Add(caveGen.header.getId()); } caveGen.header.setName("Cave (level " + (deep + 1) + ")"); caveGen.header.setRegion(caveGen.region); caveGen.header.storeRegion(true); if(deep == 0) { caveGen.getEntrance().setDx(topX); caveGen.getEntrance().setDy(topY+1); caveGen.getEntrance().setDestinationRegionID(topLevel.getId()); topLevel.getExits().Add(new RegionExit(topX,topY,caveGen.getEntrance().getX(),caveGen.getEntrance().getY()+1,caveGen.header.getId(), ExitDecorator.CAVE)); } else { caveGen.getEntrance().setDx(lastGen.exit.getX()); caveGen.getEntrance().setDy(lastGen.exit.getY()+1); caveGen.getEntrance().setDestinationRegionID(lastGen.header.getId()); lastGen.exit.setDx(caveGen.entrance.getX()); lastGen.exit.setDy(caveGen.entrance.getY()+1); lastGen.exit.setDestinationRegionID(caveGen.header.getId()); if(deep == depth-1) { caveGen.header.setName("Cave (bottom level)"); caveGen.header.getExits().Remove(caveGen.exit); } } quinoa.getMap().addRegionHeader(caveGen.header); lastGen = caveGen; } }
/** * Create a path finder * * @param heuristic The heuristic used to determine the search order of the map * @param map The map to be searched * @param maxSearchDistance The maximum depth we'll search before giving up * @param allowDiagMovement True if the search should try diagonal movement */ public PathFinder(Quinoa quinoa, IHeuristic heuristic) { this.heuristic = heuristic; this.quinoa = quinoa; }
public static void monsterKilled(Monster killer, Monster victim, Quinoa quinoa) { String playerFeedback="The " + EnumUtil.EnumName<MonsterCode>(victim.monsterCode) + " is gone."; //Give experience MonsterActionManager.giveExperience(killer, victim.stats.getExperienceGiven(), quinoa); //Drop items foreach(Item tempItem in victim.inventory.getItems()) { Item newItem = (Item)tempItem.CopyObject(); newItem.setPosition(victim.x, victim.y); newItem.itemState = ItemState.GROUND; quinoa.getCurrentRegionHeader().getRegion().getItems().Add(newItem); } //Any monster specific items switch(victim.monsterCode) { case MonsterCode.HUMAN: break; case MonsterCode.GHOST: playerFeedback = "The " + EnumUtil.EnumName<MonsterCode>(victim.monsterCode) + " fades away..."; break; case MonsterCode.SPONGE: playerFeedback = "The " + EnumUtil.EnumName<MonsterCode>(victim.monsterCode) + " crumbles."; break; case MonsterCode.SLIME: for(int i=0; i < 2; i++) { Monster newMon = new Monster(); newMon.monsterCode = MonsterCode.SMALL_SLIME; MonsterActionManager.initialize(newMon); newMon.setPosition(victim.x + RandomNumber.RandomInteger(5) - 2, victim.y + RandomNumber.RandomInteger(5) - 2); quinoa.getActions().addMonster(newMon); } playerFeedback = "The " + EnumUtil.EnumName<MonsterCode>(victim.monsterCode) + " splits!"; break; case MonsterCode.SMALL_SLIME: for(int i=0; i < 2; i++) { Monster newMon = new Monster(); newMon.monsterCode = MonsterCode.TINY_SLIME; MonsterActionManager.initialize(newMon); newMon.setPosition(victim.x + RandomNumber.RandomInteger(7) - 4, victim.y + RandomNumber.RandomInteger(7) - 4); quinoa.getActions().addMonster(newMon); } playerFeedback = "The " + EnumUtil.EnumName<MonsterCode>(victim.monsterCode) + " splits!"; break; case MonsterCode.TINY_SLIME: playerFeedback = "The " + EnumUtil.EnumName<MonsterCode>(victim.monsterCode) + " evaporates!"; break; case MonsterCode.DEER: case MonsterCode.PIG: playerFeedback = "The " + EnumUtil.EnumName<MonsterCode>(victim.monsterCode) + " collapses."; break; default: break; } //Inform plyer if(killer.ID.Equals(MonsterActionManager.PLAYER_ID)) { quinoa.getMessageManager().addMessage(playerFeedback); } }
public static void leaveWaterTrail(Monster monster, Quinoa quinoa, double strength) { Terrain terrain = quinoa.getCurrentRegionHeader().getRegion().getTerrain(monster.x, monster.y); //leave water trails if (RandomNumber.RandomDouble() > (1.0 - strength)) { if(TerrainManager.wetable(terrain, monster.x, monster.y, quinoa)) { if(terrain.getWater() < 3) { terrain.setWater(terrain.getWater()+1); } } } }
public static void giveExperience(Monster monster, int amount, Quinoa quinoa) { monster.stats.setExperience(monster.stats.getExperience() + amount); //check for level up int startLevel = monster.stats.getLevel(); int endLevel = monster.stats.getLevel(); for(int i=0; i < xpLevels.Length; i++) { if(monster.stats.getExperience() >= xpLevels[i]) { endLevel = (i + 1); } } if(endLevel > startLevel && startLevel != MonsterStats.MAX_LEVEL) { monster.stats.setLevel(endLevel); monster.stats.setAvailableStatPoints(monster.stats.getAvailableStatPoints() + ((endLevel - startLevel) * MonsterStats.STAT_POINTS_PER_LEVEL )); monster.stats.setCurrentHealth(monster.stats.getMaxHP()); if(isPlayer(monster)) { quinoa.getMessageManager().addMessage("Level up!"); quinoa.getUI().getScreen().displayDialog(); } } }
public static void executeItemVerbCommand(Monster monster, MonsterCommand command, Quinoa quinoa) { Item item = monster.inventory.getItem(command.getParameter("itemID")); ItemVerb verb = (ItemVerb)Enum.Parse(typeof(ItemVerb), command.getParameter("verb")); Region region = quinoa.getCurrentRegionHeader().getRegion(); int x = Int32.Parse(command.getParameter("x")); int y = Int32.Parse(command.getParameter("y")); bool removeItem=false; if(item != null) { switch(verb) { case ItemVerb.EAT: foreach(ItemAttribute attribute in item.attributes) { if(attribute.type == ItemAttributeType.NUTRITION) { double nutrition = Double.Parse(attribute.parameter); monster.stats.setCurrentHunger(monster.stats.getCurrentHunger() - nutrition); if(monster.stats.getCurrentHunger() < 0) { monster.stats.setCurrentHunger(0.0); } if(isPlayer(monster)) { quinoa.getMessageManager().addMessage("Ate " + EnumUtil.EnumName<ItemClass>(item.itemClass) + "."); } } if(attribute.type == ItemAttributeType.HEALS) { double points = Double.Parse(attribute.parameter); monster.stats.setCurrentHealth(monster.stats.getCurrentHealth() + points); if(monster.stats.getCurrentHealth() > monster.stats.getMaxHP()) { monster.stats.setCurrentHealth(monster.stats.getMaxHP()); } if(isPlayer(monster)) { if(points >= 0) { quinoa.getMessageManager().addMessage("You feel better."); } else { quinoa.getMessageManager().addMessage("You feel worse."); } } } } removeItem = true; break; case ItemVerb.PLACE: removeItem = MonsterActionManager.place(monster, item, x, y, region, quinoa); break; case ItemVerb.USE: removeItem = use(monster, item, x, y, region, quinoa); break; } if(removeItem) { if(item.stackSize > 1) { item.stackSize = item.stackSize - 1; } else { item.RemoveObject(); } } } else { //Non-item verbs switch(verb) { case ItemVerb.ACTIVATE: MonsterActionManager.activate(monster, x, y, region, quinoa); break; case ItemVerb.TALK: if(isPlayer(monster)) { quinoa.getActions().talk(x, y); quinoa.getActions().showDialog(); } break; case ItemVerb.LOOK: if(isPlayer(monster)) { quinoa.getActions().look(x, y); quinoa.getActions().showDialog(); } break; case ItemVerb.TRADE: if(isPlayer(monster)) { quinoa.getActions().trade(x, y); } break; case ItemVerb.SLEEP: Item terrainItem = region.getItem(x, y); if(terrainItem != null) { foreach(ItemAttribute ia in terrainItem.attributes) { if(ia.type == ItemAttributeType.SLEEPS_FOR) { int hours = Int32.Parse(ia.parameter.Split(new char[]{' '})[0]); monster.setPosition(x, y); monster.sleeping = Quinoa.TICKS_PER_SECOND * 60 * 60 * hours; break; } } } if(TerrainManager.hasParameter(region.getTerrain(x, y), TerrainParameter.HAS_BED)) { int hours = 4; monster.setPosition(x, y); monster.sleeping = Quinoa.TICKS_PER_SECOND * 60 * 60 * hours; } else { if(isPlayer(monster)) { quinoa.getMessageManager().addMessage("You can't sleep there."); } } break; } } }
public static void executeUnequipCommand(Monster monster, MonsterCommand command, Quinoa quinoa) { String itemID = command.getParameter("itemID"); Item itemToEquip = monster.inventory.getItem(itemID); //Find the slot that the item is equiped in ItemSlot equipSlot = ItemSlot.NULL; foreach (ItemSlot tempSlot in Enum.GetValues(typeof(ItemSlot)).Cast<ItemSlot>()) { Item testItem = monster.inventory.getItem(tempSlot); if(testItem != null && testItem.ID.Equals(itemID)) { equipSlot = tempSlot; } } if(equipSlot != ItemSlot.NULL) { if(!monster.inventory.Full) { Item newItem = (Item)itemToEquip.CopyObject(); monster.inventory.equipItem(null, equipSlot); if(!monster.inventory.stackItem(newItem)) { monster.inventory.addItem(newItem); } if(isPlayer(monster)) { quinoa.getMessageManager().addMessage("Unequiped " + EnumUtil.EnumName<ItemClass>(newItem.itemClass) + "."); } } else { if(isPlayer(monster)) { quinoa.getMessageManager().addMessage("No space to unequip that."); } } } }
public static void dig(Terrain terrain, int x, int y, Quinoa quinoa) { //check for graves if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_GRAVE)) { GraveCode gc = (GraveCode)Enum.Parse(typeof(GraveCode), TerrainManager.getParameter(terrain, TerrainParameter.HAS_GRAVE)); if(gc == GraveCode.NORMAL && RandomNumber.RandomDouble() < TerrainManager.GRAVE_ROB_CHANCE) { Item reward = ItemManager.getTreasure(RandomNumber.RandomDouble()); reward.setPosition(x, y); quinoa.getCurrentRegionHeader().getRegion().getItems().Add(reward); } //open the grave terrain.getParameters().Add(TerrainParameter.HAS_GRAVE, EnumUtil.EnumName<GraveCode>(GraveCode.BROKEN)); //drop bones Item bones = new Item(); bones.itemClass = ItemClass.BONES; bones.setPosition(x, y); bones.itemState = ItemState.GROUND; quinoa.getCurrentRegionHeader().getRegion().getItems().Add(bones); return; } switch(terrain.getCode()) { case TerrainCode.GRASS: terrain.setCode(TerrainCode.DIRT); break; case TerrainCode.DIRT: terrain.setCode(TerrainCode.STONE_FLOOR); break; case TerrainCode.STREAM_BED: if(!TerrainManager.hasParameter(terrain, TerrainParameter.HAS_DRAIN)) { if(!TerrainManager.hasParameter(terrain, TerrainParameter.HAS_SPRING)) { terrain.getParameters().Add(TerrainParameter.HAS_SPRING, TerrainManager.SPRING_RATE+""); } else { terrain.getParameters().Remove(TerrainParameter.HAS_SPRING); } } break; default: //Do nothing, can not dig break; } }
public static bool flammable(Terrain terrain, int x, int y, Quinoa quinoa) { //See if the area is wet if(terrain.getWater() > 0) { return false; } if(containsItem(ItemClass.LOG, x, y, quinoa) != null) { return true; } switch(terrain.getCode()) { case TerrainCode.PATH: case TerrainCode.DIRT: case TerrainCode.STONE_WALL: case TerrainCode.STONE_FLOOR: case TerrainCode.FERTILE_LAND: case TerrainCode.ROCK: case TerrainCode.STREAM_BED: default: return false; case TerrainCode.GRASS: return true; } }
public void initializePlayer(Quinoa quinoa) { quinoa.setPlayer(new Monster()); quinoa.getPlayer().monsterCode = MonsterCode.HUMAN; quinoa.getPlayer().ID = MonsterActionManager.PLAYER_ID; quinoa.getPlayer().setPosition(50, 50); Item boots = new Item(); boots.itemClass = ItemClass.BOOTS; quinoa.getPlayer().inventory.addItem(boots); Item jacket = new Item(); jacket.itemClass = ItemClass.JACKET; quinoa.getPlayer().inventory.addItem(jacket); Item axe = new Item(); axe.itemClass = ItemClass.AXE; quinoa.getPlayer().inventory.addItem(axe); Item pickaxe = new Item(); pickaxe.itemClass = ItemClass.PICKAXE; quinoa.getPlayer().inventory.addItem(pickaxe); Item flapjacks = new Item(); flapjacks.itemClass = ItemClass.FLAPJACKS; flapjacks.stackSize = 4; quinoa.getPlayer().inventory.addItem(flapjacks); Item lantern = new Item(); lantern.itemClass = ItemClass.LANTERN; quinoa.getPlayer().inventory.addItem(lantern); Item hat = new Item(); hat.itemClass = ItemClass.HAT; quinoa.getPlayer().inventory.addItem(hat); Item torch = new Item(); torch.itemClass = ItemClass.TORCH; torch.stackSize = 25; quinoa.getPlayer().inventory.addItem(torch); Item bucket = new Item(); bucket.itemClass = ItemClass.BUCKET; quinoa.getPlayer().inventory.addItem(bucket); Item shovel = new Item(); shovel.itemClass = ItemClass.SHOVEL; quinoa.getPlayer().inventory.addItem(shovel); Item tent = new Item(); tent.itemClass = ItemClass.TENT; quinoa.getPlayer().inventory.addItem(tent); Item ash = new Item(); ash.itemClass = ItemClass.ASH; ash.stackSize = 35; quinoa.getPlayer().inventory.addItem(ash); Item corn = new Item(); corn.itemClass = ItemClass.CORN; corn.stackSize = corn.maxStackSize; quinoa.getPlayer().inventory.addItem(corn); Item cornSeed = new Item(); cornSeed.itemClass = ItemClass.CORN_SEED; cornSeed.stackSize = 10; quinoa.getPlayer().inventory.addItem(cornSeed); Item pumpkin = new Item(); pumpkin.itemClass = ItemClass.PUMPKIN; pumpkin.stackSize = 1; quinoa.getPlayer().inventory.addItem(pumpkin); Item pumpkinSeed = new Item(); pumpkinSeed.itemClass = ItemClass.PUMPKIN_SEED; pumpkinSeed.stackSize = 10; quinoa.getPlayer().inventory.addItem(pumpkinSeed); Item floodgate = new Item(); floodgate.itemClass = ItemClass.FLOODGATE; floodgate.stackSize = floodgate.maxStackSize; quinoa.getPlayer().inventory.addItem(floodgate); Item mop = new Item(); mop.itemClass = ItemClass.MOP; mop.stackSize = mop.maxStackSize; quinoa.getPlayer().inventory.addItem(mop); }
//Grow crops on this tile public static void growCrops(Terrain terrain, int x, int y, Quinoa quinoa) { if(TerrainManager.hasParameter(terrain, TerrainParameter.HAS_SEED)) { if(quinoa.getLightMap().getCalc(x, y) >= TerrainManager.PLANT_LIGHT_LEVEL_MIN) { SeedType seedType = (SeedType)Enum.Parse(typeof(SeedType), TerrainManager.getParameter(terrain, TerrainParameter.HAS_SEED)); switch(seedType) { case SeedType.CORN: terrain.getParameters().Remove(TerrainParameter.HAS_SEED); terrain.getParameters().Add(TerrainParameter.GROW_COUNTER, TerrainManager.GRASS_GROW_COUNT+""); if(quinoa.getCurrentRegionHeader().getRegion().getItem(x, y) == null) { if(RandomNumber.RandomDouble() < 0.50) { Item cornSeed = new Item(); cornSeed.itemClass = ItemClass.CORN_SEED; cornSeed.stackSize = RandomNumber.RandomInteger(9) + 1; cornSeed.setPosition(x, y); quinoa.getCurrentRegionHeader().getRegion().getItems().Add(cornSeed); } Item corn = new Item(); corn.itemClass = ItemClass.CORN; corn.stackSize = RandomNumber.RandomInteger(3) + 1; corn.setPosition(x, y); quinoa.getCurrentRegionHeader().getRegion().getItems().Add(corn); } break; case SeedType.PUMPKIN: //reset the counter terrain.getParameters().Add(TerrainParameter.GROW_COUNTER, (TerrainManager.PUMPKIN_GROW_COUNT / 2)+""); //chance to produce a pumpkin if(quinoa.getCurrentRegionHeader().getRegion().getItem(x, y) == null) { if(RandomNumber.RandomDouble() < TerrainManager.PUMPKIN_PRODUCTION_RATE) { Item pumpkinSeed = new Item(); pumpkinSeed.itemClass = ItemClass.PUMPKIN_SEED; pumpkinSeed.stackSize = RandomNumber.RandomInteger(3) + 1; pumpkinSeed.setPosition(x, y); quinoa.getCurrentRegionHeader().getRegion().getItems().Add(pumpkinSeed); Item pumpkin = new Item(); pumpkin.itemClass = ItemClass.PUMPKIN; pumpkin.stackSize = 1; pumpkin.setPosition(x, y); quinoa.getCurrentRegionHeader().getRegion().getItems().Add(pumpkin); } } break; } } } else { //no seeds, just grow grass terrain.getParameters().Remove(TerrainParameter.GROW_COUNTER); terrain.setCode(TerrainCode.GRASS); if (RandomNumber.RandomDouble() < TerrainManager.TREE_REGROWTH_RATE) { terrain.getParameters().Add(TerrainParameter.HAS_TREE, EnumUtil.EnumName<TreeCode>(TerrainManager.getRandomTree())); } } }
public void placeBrother(Quinoa quinoa) { String caveID = caveBottomIDs[RandomNumber.RandomInteger(caveBottomIDs.Count)]; RegionHeader header = quinoa.getMap().getRegionHeaderByID(caveID); header.recallRegion(); Position pos = new Position(); List<Position> tempPos = MapGenerator.getTerrainPositions(TerrainCode.STONE_FLOOR, header.getRegion(), false); if (tempPos.Count > 0) { pos = tempPos[RandomNumber.RandomInteger(tempPos.Count)]; } Monster monster = new Monster(); monster.monsterCode = MonsterCode.HUMAN; MonsterActionManager.initialize(monster); monster.role = MonsterRole.BROTHER; monster.setPosition(pos.x, pos.y); Item lantern = new Item(); lantern.itemClass = ItemClass.LANTERN; monster.inventory.equipItem(lantern, ItemSlot.BELT_1); header.getRegion().getMonsters().Add(monster); header.storeRegion(true); }
public static void step(Terrain terrain, int x, int y, Region region, Quinoa quinoa) { //moss is destroyed if stepped upon if(TerrainManager.hasParameter(region.getTerrain(x, y), TerrainParameter.HAS_MOSS)) { region.getTerrain(x, y).getParameters().Remove(TerrainParameter.HAS_MOSS); if(RandomNumber.RandomDouble() < MOSS_DROP_RATE) { Item moss = new Item(); moss.itemClass = ItemClass.MOSS; moss.setPosition(x, y); moss.itemState = ItemState.GROUND; region.getItems().Add(moss); } } }
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 override void generate(Quinoa quinoa) { //Fill the overworld cell array int owWidth = quinoa.getMap().getOverworldWidth(); int owHeight = quinoa.getMap().getOverworldHeight(); OverworldCell[,] owc = quinoa.getMap().getOverworldCells(); for(int x=0; x < owWidth; x++) { for(int y=0; y < owHeight; y++) { owc[x,y] = new OverworldCell(); } } //choose a random spot to be town, set as cross int townX = owWidth / 2 + ((int)(RandomNumber.RandomDouble() * 3) - 1); int townY = owHeight / 2 + ((int)(RandomNumber.RandomDouble() * 3) - 1); owc[townX,townY].cellType = CellType.MAIN_TOWN; owc[townX,townY].nExit = true; owc[townX,townY].eExit = true; owc[townX,townY].sExit = true; owc[townX,townY].wExit = true; //generate paths recursively this.addPathBranch(townX-1, townY, owWidth, owHeight, owc, 0, 2, 7); this.addPathBranch(townX+1, townY, owWidth, owHeight, owc, 0, 2, 7); this.addPathBranch(townX, townY-1, owWidth, owHeight, owc, 0, 2, 7); this.addPathBranch(townX, townY+1, owWidth, owHeight, owc, 0, 2, 7); //generate regions for each overworld cell for(int x=0; x < owWidth; x++) { for(int y=0; y < owHeight; y++) { if(owc[x,y].cellType == CellType.MAIN_TOWN) { TownGenerator townGen = new TownGenerator(100, 100, "main", 3, 0.75, 0.01, owc[x,y], quinoa); townGen.generate(); owc[x,y].header = townGen.header; townGen.header.storeRegion(true); this.addCaveBranch(townGen.header, 14, 14, 3 + (int)(RandomNumber.RandomDouble() * 3), quinoa); quinoa.getMap().addRegionHeader(owc[x,y].header); } else if(owc[x,y].cellType == CellType.TOWN) { TownGenerator townGen = new TownGenerator(100, 100, "town" + RandomNumber.RandomUUID().ToString(), 3, 0.75, 0.01, owc[x,y], quinoa); townGen.generate(); owc[x,y].header = townGen.header; townGen.header.storeRegion(true); quinoa.getMap().addRegionHeader(owc[x,y].header); } else if(owc[x,y].cellType == CellType.FOREST) { String forestName = "forest" + RandomNumber.RandomUUID().ToString(); int depthCount = 0; int depthTotal = 0; if(owc[x,y].nExit) { depthCount++; depthTotal = depthTotal + owc[x,y-1].depth; } if(owc[x,y].eExit) { depthCount++; depthTotal = depthTotal + owc[x + 1,y].depth; } if(owc[x,y].sExit) { depthCount++; depthTotal = depthTotal + owc[x,y+1].depth; } if(owc[x,y].wExit) { depthCount++; depthTotal = depthTotal + owc[x-1,y].depth; } depthTotal = depthTotal + owc[x,y].depth; depthCount = depthCount + 1; double treeDensity = 0.01 + ((depthTotal / depthCount) * 0.02); if(treeDensity > 0.55) { treeDensity = 0.55; } ForestGenerator forGen = new ForestGenerator(100, 100, forestName, treeDensity, quinoa); double waterDensity = 0.15 + (RandomNumber.RandomDouble() * 0.35); if(waterDensity > 0.65) { waterDensity = 0.65; } forGen.addWater(waterDensity, 4); forGen.generate(owc[x,y].nExit, owc[x,y].eExit, owc[x,y].sExit, owc[x,y].wExit); forGen.addSprings(); forGen.header.setName("Forest"); owc[x,y].header = forGen.header; //add cave branches if only one exit is present int exitCount = 0; if(owc[x,y].nExit) {exitCount++;} if(owc[x,y].eExit) {exitCount++;} if(owc[x,y].sExit) {exitCount++;} if(owc[x,y].wExit) {exitCount++;} if(exitCount == 1 && RandomNumber.RandomDouble() < 0.50) { this.addCaveBranch(owc[x,y].header, owc[x,y].header.getRegion().getWidth() / 2, owc[x,y].header.getRegion().getHeight() / 2, 2 + (int)(RandomNumber.RandomDouble() * (depthTotal / depthCount)), quinoa); } forGen.header.storeRegion(true); quinoa.getMap().addRegionHeader(owc[x,y].header); } } } //connect exits for(int x=0; x < owWidth; x++) { for(int y=0; y < owHeight; y++) { if(owc[x,y].header != null) { if(owc[x,y].nExit && y > 0) { this.connectExits(owc[x,y], owc[x,y-1], Direction.N); } if(owc[x,y].sExit && y < owHeight-1) { this.connectExits(owc[x,y], owc[x,y+1], Direction.S); } if(owc[x,y].eExit && x < owWidth-1) { this.connectExits(owc[x,y], owc[x+1,y], Direction.E); } if(owc[x,y].wExit && x > 0) { this.connectExits(owc[x,y], owc[x-1,y], Direction.W); } } } } //place the brother this.placeBrother(quinoa); this.initializePlayer(quinoa); }
public static void executeMoveCommand(Monster monster, MonsterCommand command, Quinoa quinoa) { Region region = quinoa.getCurrentRegionHeader().getRegion(); Direction direction = (Direction) Enum.Parse(typeof(Direction), command.getParameter("direction")); monster.facing = direction; int newX = monster.x; int newY = monster.y; switch(direction) { case Direction.N: newY--; break; case Direction.NE: newY--; newX++; break; case Direction.NW: newY--; newX--; break; case Direction.S: newY++; break; case Direction.SE: newY++; newX++; break; case Direction.SW: newY++; newX--; break; case Direction.E: newX++; break; case Direction.W: newX--; break; } if(newX >= 0 && newX < region.getWidth() && newY >= 0 && newY < region.getHeight()) { Terrain tmpTerrain = region.getTerrain(newX, newY); if (TerrainManager.allowsMonsterToPass(tmpTerrain, monster) && quinoa.getMonster(newX, newY) == null) { monster.setPosition(newX, newY); TerrainManager.step(region.getTerrain(newX, newY), newX, newY, region, quinoa); } else { //Do nothing } } else { //out of bounds, but do not inform the player } }