public bool add(Actor item) { if (size <= 0 || inventory.Count() >= size) { return false; } this.inventory.Insert(0, item); return true; }
public void reGenMap(Tile[] level, bool forward, bool loaded = false) { if (gameState.curLevel == 0 || gameState.curLevel == 1) { engine.player.x = gameState.levellist[gameState.curLevel].startx; engine.player.y = gameState.levellist[gameState.curLevel].starty; Actor nextLevel = new Actor(gameState.levellist[gameState.curLevel].endx, gameState.levellist[gameState.curLevel].endy, '>', "stairs", TCODColor.sea); nextLevel.portal = new Portal(this, true, false); engine.actors.Add(nextLevel); } else if (gameState.curLevel == 4) { engine.player.x = gameState.levellist[gameState.curLevel].startx; engine.player.y = gameState.levellist[gameState.curLevel].starty; Actor theend = new Actor(gameState.levellist[gameState.curLevel].endx, gameState.levellist[gameState.curLevel].endy, '>', "stairs", TCODColor.sea); theend.portal = new Portal(this, false, true); engine.actors.Add(theend); } else if (forward) { engine.player.x = gameState.levellist[gameState.curLevel].startx - 1; engine.player.y = gameState.levellist[gameState.curLevel].starty; Actor nextLevel = new Actor(gameState.levellist[gameState.curLevel].endx, gameState.levellist[gameState.curLevel].endy, '>', "stairs", TCODColor.sea); nextLevel.portal = new Portal(this, true, false); engine.actors.Add(nextLevel); Actor prevLevel = new Actor(gameState.levellist[gameState.curLevel].startx, gameState.levellist[gameState.curLevel].starty, '>', "stairs", TCODColor.sea); prevLevel.portal = new Portal(this, false, false); engine.actors.Add(prevLevel); } else if (loaded) { engine.player.x = gameState.levellist[gameState.curLevel].startx - 1; engine.player.y = gameState.levellist[gameState.curLevel].starty; Actor prevLevel = new Actor(gameState.levellist[gameState.curLevel].startx, gameState.levellist[gameState.curLevel].starty, '>', "stairs", TCODColor.sea); prevLevel.portal = new Portal(this, false, false); engine.actors.Add(prevLevel); Actor nextLevel = new Actor(gameState.levellist[gameState.curLevel].endx, gameState.levellist[gameState.curLevel].endy, '>', "stairs", TCODColor.sea); engine.actors.Add(nextLevel); if (gameState.curLevel == 4) { nextLevel.portal = new Portal(this, false, true); } else { nextLevel.portal = new Portal(this, false, false); } } else { engine.player.x = gameState.levellist[gameState.curLevel].endx - 1; engine.player.y = gameState.levellist[gameState.curLevel].endy; Actor nextLevel = new Actor(gameState.levellist[gameState.curLevel].endx, gameState.levellist[gameState.curLevel].endy, '>', "stairs", TCODColor.sea); nextLevel.portal = new Portal(this, true, false); engine.actors.Add(nextLevel); Actor prevLevel = new Actor(gameState.levellist[gameState.curLevel].startx, gameState.levellist[gameState.curLevel].starty, '>', "stairs", TCODColor.sea); prevLevel.portal = new Portal(this, false, false); engine.actors.Add(prevLevel); } tiles = level; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (tiles[x + y * width].canWalk == true) { tmap.setProperties(x, y, true, true); } if (tiles[x + y * width].prop != '0') { renderProp(x, y, tiles[x + y * width].prop); } } } foreach (ActorStore actordata in gameState.levellist[gameState.curLevel].actors) { if(actordata.name == "thug" || actordata.name == "gangster") { // IN ELEGANT -- FIX IF CAN if (actordata.dead == true) { Actor mon = new Actor(actordata.x, actordata.y, '%', "dead body", TCODColor.red); mon.blocks = false; engine.actors.Add(mon); } else { if (actordata.name == "thug") { Actor mon = new Actor(actordata.x, actordata.y, 't', "thug", TCODColor.darkBlue); mon.destruct = new MonsterDestructible(10, 0, "dead thug", engine); mon.attacker = new Attacker(3); mon.ai = new MonsterAI(); engine.actors.Add(mon); } else { Actor mon = new Actor(actordata.x, actordata.y, 'g', "gangster", TCODColor.darkCrimson); mon.destruct = new MonsterDestructible(10, 0, "dead gangster", engine); mon.attacker = new Attacker(3); mon.ai = new MonsterAI(); engine.actors.Add(mon); } } } else if(actordata.name == "bandage") { Actor healthpot = new Actor(actordata.x, actordata.y, '!', "bandage", TCODColor.violet); healthpot.blocks = false; healthpot.pick = new Healer(4); engine.actors.Add(healthpot); } else if (actordata.name == "rock") { Actor confuse = new Actor(actordata.x, actordata.y, '#', "rock", TCODColor.darkBlue); confuse.blocks = false; confuse.pick = new Confuser(10, 10, engine); engine.actors.Add(confuse); } else if (actordata.name == "ammo"){ Actor light = new Actor(actordata.x, actordata.y, '#', "ammo", TCODColor.darkYellow); light.blocks = false; light.pick = new ammo(engine); engine.actors.Add(light); } else if (actordata.name == "grenade") { Actor fire = new Actor(actordata.x, actordata.y, '#', "grenade", TCODColor.darkRed); fire.blocks = false; fire.pick = new grenade(5, 10, engine); engine.actors.Add(fire); } else if (actordata.name == "girl") { Actor girl = new Actor(actordata.x, actordata.y, (char)TCODSpecialCharacter.Female, "girl", TCODColor.red); girl.pick = new Girl(engine); girl.blocks = false; engine.actors.Add(girl); } } return; }
private void placeItems(Room room) { int numItems = TCODRandom.getInstance().getInt(0, Globals.MAX_ITEMS); float random = TCODRandom.getInstance().getFloat(0.0f, 1.0f); for (int i = 0; i < numItems; i++) { random = TCODRandom.getInstance().getFloat(0.0f, 1.0f); int x = TCODRandom.getInstance().getInt(room.x1+1, room.x2-1); int y = TCODRandom.getInstance().getInt(room.y1+1, room.y2-1); if (random < .5) { Actor healthpot = new Actor(x, y, '!', "bandage", TCODColor.violet); healthpot.blocks = false; healthpot.pick = new Healer(4); engine.actors.Add(healthpot); } else if (random >= .5 && random < .6) { Actor confuse = new Actor(x, y, '#', "rock", TCODColor.darkBlue); confuse.blocks = false; confuse.pick = new Confuser(10, 10, engine); engine.actors.Add(confuse); } else if (random >= .6 && random < .9){ Actor gun = new Actor(x, y, '#', "ammo", TCODColor.darkYellow); gun.blocks = false; gun.pick = new ammo(engine); engine.actors.Add(gun); } else { Actor fire = new Actor(x, y, '#', "grenade", TCODColor.darkRed); fire.blocks = false; fire.pick = new grenade(5, 10, engine); engine.actors.Add(fire); } } }
public Engine(State gameState, bool fromload = false, State newState = null) { TCODConsole.initRoot(Globals.WIDTH, Globals.HEIGHT, "roguelike", false); this.fromload = fromload; menu = new Menu(); menu.clear(); menu.add(Menu.MenuCode.NEW_GAME, "New Game"); if (fromload) { menu.add(Menu.MenuCode.CONTINUE, "Continue"); } menu.add(Menu.MenuCode.EXIT, "Exit"); Menu.MenuCode selection = menu.pick(); if (selection == Menu.MenuCode.EXIT) { Environment.Exit(0); } else if (selection == Menu.MenuCode.NEW_GAME) { try { File.Delete(Globals.SAVE); } catch (IOException e) { System.Diagnostics.Debug.WriteLine(e.Message); } fromload = false; if (newState == null) { this.gameState = gameState; } else { this.gameState = newState; } } else { this.gameState = gameState; } this.gStatus = Status.START; player = new Actor(40, 25, 64, "player", TCODColor.white); player.destruct = new PlayerDestructible(30, 2, "your corpse", this); player.ai = new PlayerAI(); player.attacker = new Attacker(5); player.contain = new Container(20); if (fromload) { player.destruct.hp = gameState.curhp; loadInv(); } actors.Add(player); fovRadius = 10; map = new Map(Globals.WIDTH, Globals.HEIGHT-Globals.PANEL, this); this.gui = new GUI(this); }
public void wingame() { foreach (Actor actor in actors) { if (actor.pick != null) { if (actor.pick is Girl) { Girl girl = actor.pick as Girl; if (girl.follow == true) { Actor endgame = new Actor(0, 0, ' ', "", TCODColor.red); endgame.pick = new Trigger(')'); endgame.pick.use(endgame, endgame); gStatus = Status.WIN; } } } } }
public virtual bool use(Actor owner, Actor wearer) { if (wearer.contain != null) { wearer.contain.remove(owner); return true; } return false; }
public override bool use(Actor actor, Actor owner, Engine engine) { if (!used) { string message = ""; TCODConsole con = new TCODConsole(Globals.INV_WIDTH, Globals.INV_HEIGHT); con.setForegroundColor(new TCODColor(200, 200, 150)); con.printFrame(0, 0, Globals.INV_WIDTH, Globals.INV_HEIGHT, true, TCODBackgroundFlag.Default, "Story"); if (triggernum == '(') { message = Globals.story[engine.gameState.curLevel, 9]; } else if (triggernum == ')') { message = Globals.story[engine.gameState.curLevel, 10]; } else { message = Globals.story[engine.gameState.curLevel, (int)Char.GetNumericValue(triggernum) - 1]; } if (message.Length > 41) { string sub1 = message.Substring(0, 41); string sub2 = message.Substring(41, message.Length - 41); if (sub2.Length > 41) { string sub3 = sub2.Substring(0, 41); sub2 = sub2.Substring(41, sub2.Length - 41); con.print(3, 3, sub1); con.print(3, 4, sub3); con.print(3, 5, sub2); } else { con.print(3, 3, sub1); con.print(3, 4, sub2); } } else { con.print(3, 3, message); } con.print(13, 15, "Press Enter to Continue"); TCODConsole.blit(con, 0, 0, Globals.INV_WIDTH, Globals.INV_HEIGHT, TCODConsole.root, Globals.WIDTH / 2 - Globals.INV_WIDTH / 2, Globals.HEIGHT / 2 - Globals.INV_HEIGHT / 2); TCODConsole.flush(); while(true) { TCODKey key = TCODConsole.checkForKeypress(); if(key.KeyCode == TCODKeyCode.Enter){ break; } } used = true; return used; } return false; }
public override bool use(Actor owner, Actor wearer) { //engine.gStatus = Engine.Status.WIN; follow = true; return false; }
public override bool use(Actor owner, Actor wearer) { dmgArray.Clear(); dmgArray.TrimExcess(); engine.gui.message(TCODColor.flame, "U/D/L/R to target tile for the fireball, enter to select, or esc to cancel."); int x = 0, y = 0; if (!engine.pickTile(ref x, ref y)) { return false; } engine.gui.message(TCODColor.cyan, String.Format("The fireball explodes, burning everything within {0} tiles!", range)); foreach (Actor mon in engine.actors) { if (mon.destruct != null && !mon.destruct.isDead() && mon.getDist(x, y) <= range) { engine.gui.message(TCODColor.orange, String.Format("The {0} burns for {1} points of damage.", mon.name, dmg)); dmgArray.Add(mon); } } foreach (Actor mon in dmgArray) { mon.destruct.takeDamage(mon, dmg); } return pbase.use(owner, wearer); }
public override bool use(Actor actor, Actor owner) { if (!used) { actor.ch = '/'; used = true; return used; } return false; }
public Girl(Engine engine) { this.engine = engine; this.player = engine.player; }
public float takeDamage(Actor owner, float dmg) { dmg -= def; if (dmg > 0) { hp -= dmg; if (hp <= 0) { die(owner); } } else { dmg = 0; } return dmg; }
public virtual void die(Actor owner) { owner.ch = '%'; owner.col = TCODColor.darkRed; owner.blocks = false; engine.sendToBack(owner); }
public void remove(Actor item) { if (inventory.Contains(item)) { inventory.Remove(item); } }
public bool pick(Actor owner, Actor wearer, Engine engine) { if (wearer.contain != null && wearer.contain.add(owner)) { engine.actors.Remove(owner); return true; } return false; }
public bool use(Gun owner, Actor wearer, Engine engine) { int x = 0, y = 0; engine.gui.message(TCODColor.lightBlue, "Picking a target...a dangerous game."); if (!engine.pickTile(ref x, ref y)) { return false; } foreach (Actor mon in engine.actors) { if (mon.destruct != null && !mon.destruct.isDead() && mon.x == x && mon.y == y) { engine.gui.message(TCODColor.lightBlue, "A gun shot strikes {0} for {1} pt of dmg", mon.name, dmg.ToString()); dmgdMon = mon; } } if (dmgdMon != null) { dmgdMon.destruct.takeDamage(dmgdMon, dmg); } else { engine.gui.message(TCODColor.lightBlue, "A miss. No good."); } return true; }
public virtual bool use(Actor owner, Actor wearer, Engine engine) { return use(owner, wearer); }
public override bool use(Actor owner, Actor wearer) { if (wearer.destruct != null) { float amountHealed = wearer.destruct.heal(amount); if (amountHealed > 0) { return base.use(owner, wearer); } } return false; }
public override bool use(Actor actor, Actor owner) { if (!last) { map.changeLevel(forward); return true; } map.endgame(); return true; }
public void moveAttack(Actor owner, int px, int py, Engine engine) { int dx = px - owner.x; int dy = py - owner.y; int stepdx = (dx > 0) ? 1 : -1; int stepdy = (dy > 0) ? 1 : -1; double dist = Math.Sqrt(dx * dx + dy * dy); if (dist >= 2) { dx = (int)Math.Round(dx / dist); dy = (int)Math.Round(dy / dist); if (engine.map.canWalk(owner.x + dx, owner.y + dy)) { owner.x += dx; owner.y += dy; } else if (engine.map.canWalk(owner.x+stepdx, owner.y)){ owner.x += stepdx; } else if (engine.map.canWalk(owner.x, owner.y+stepdy)){ owner.y += stepdy; } } else if (owner.attacker != null) { owner.attacker.attack(owner, engine.player, engine); } }
public void loadInv() { foreach (String item in gameState.inventory) { if (item == "bandage") { Actor healthpot = new Actor(0, 0, '!', "bandage", TCODColor.violet); healthpot.blocks = false; healthpot.pick = new Healer(4); player.contain.inventory.Add(healthpot); } else if (item == "rock") { Actor confuse = new Actor(0, 0, '#', "rock", TCODColor.darkBlue); confuse.blocks = false; confuse.pick = new Confuser(10, 10, this); player.contain.inventory.Add(confuse); } else if (item == "ammo"){ Actor light = new Actor(0, 0, '#', "ammo", TCODColor.darkYellow); light.blocks = false; light.pick = new ammo(this); player.contain.inventory.Add(light); } else if (item == "grenade") { Actor fire = new Actor(0, 0, '#', "Fire grenade", TCODColor.darkRed); fire.blocks = false; fire.pick = new grenade(5, 10, this); player.contain.inventory.Add(fire); } } }
public override void update(TCODKey key, Engine engine, Actor owner) { throw new NotImplementedException(); }
public void sendToBack(Actor actor) { actors.Remove(actor); actors.Insert(0, actor); }
public override void update(Actor owner, Engine engine) { if (owner.destruct != null && owner.destruct.isDead()) { return; } if (engine.map.isInView(owner.x, owner.y)) { moves = Globals.TRACKING; } else { moves--; } if (moves > 0) { moveAttack(owner, engine.player.x, engine.player.y, engine); } }
public void genMap() { int numRooms = 0; int newx, newy, prevx, prevy; bool failed = false; for (var i = 0; i < Globals.ROOMS; i++) { failed = false; int w = TCODRandom.getInstance().getInt(Globals.MIN_SIZE, Globals.MAX_SIZE); int h = TCODRandom.getInstance().getInt(Globals.MIN_SIZE, Globals.MAX_SIZE); int x = TCODRandom.getInstance().getInt(0, width - w - 1); int y = TCODRandom.getInstance().getInt(0, height - h - 1); Room newRoom = new Room(x, y, w, h); foreach (Room otherroom in rooms) { if (newRoom.intersect(otherroom)) { failed = true; break; } } if (!failed) { createRoom(newRoom); newx = newRoom.centerx; newy = newRoom.centery; if (numRooms == 0) { engine.player.x = newx; engine.player.y = newy; } else { prevx = rooms[numRooms - 1].centerx; prevy = rooms[numRooms - 1].centery; if (TCODRandom.getInstance().getInt(0, 1) == 1) { hTunnel(prevx, newx, prevy); vTunnel(prevy, newy, newx); } else { vTunnel(prevy, newy, prevx); hTunnel(prevx, newx, newy); } } placeThings(newRoom); rooms.Add(newRoom); numRooms++; lastx = newRoom.centerx; lasty = newRoom.centery; } } entx = engine.player.x+1; enty = engine.player.y; exx = lastx+1; exy = lasty; Actor nextLevel = new Actor(exx, exy, '>', "stairs", TCODColor.sea); nextLevel.portal = new Portal(this, true, false); engine.actors.Add(nextLevel); if(gameState.curLevel != 0) { Actor prevLevel = new Actor(entx, enty, '>', "stairs", TCODColor.sea); prevLevel.portal = new Portal(this, false, false); engine.actors.Add(prevLevel); } }
public override void die(Actor owner) { engine.gui.message(TCODColor.red, "{0} is dead!", owner.name); base.die(owner); }
public void renderProp(int x, int y, char prop) { if (prop == '#') { Actor theprop = new Actor(x, y, '#', "desk", new TCODColor(102, 66, 37)); theprop.blocks = true; engine.actors.Add(theprop); } else if (prop == '%') { Actor theprop = new Actor(x, y, '%', "a body", TCODColor.desaturatedRed); theprop.blocks = false; engine.actors.Add(theprop); } else if (prop == '+') { Actor door = new Actor(x, y, '+', "door", new TCODColor(102, 66, 37)); door.blocks = false; door.pick = new Door(); tmap.setProperties(x, y, false, true); engine.actors.Add(door); } else if (prop == '!') { Actor healthpot = new Actor(x, y, '!', "bandage", TCODColor.violet); healthpot.blocks = false; healthpot.pick = new Healer(4); engine.actors.Add(healthpot); } else if (prop == 'a') { Actor gun = new Actor(x, y, '#', "ammo", TCODColor.darkYellow); gun.blocks = false; gun.pick = new ammo(engine); engine.actors.Add(gun); } else if (prop == 'o') { Actor confuse = new Actor(x, y, '#', "rock", TCODColor.darkBlue); confuse.blocks = false; confuse.pick = new Confuser(10, 10, engine); engine.actors.Add(confuse); } else if (prop == 'G') { Actor gren = new Actor(x, y, '#', "grenade", TCODColor.red); gren.blocks = false; gren.pick = new grenade(5, 10, engine); engine.actors.Add(gren); } else if (Char.IsNumber(prop) || prop == '(' || prop == ')') { Actor story = new Actor(x, y, ' ', "trigger", new TCODColor(102, 66, 37)); story.blocks = false; story.pick = new Trigger(prop); engine.actors.Add(story); } }
public void drop(Actor owner, Actor wearer, Engine engine) { if (wearer.contain != null) { wearer.contain.remove(owner); engine.actors.Insert(0, owner); owner.x = wearer.x; owner.y = wearer.y; engine.gui.message(TCODColor.lightChartreuse, "{0} drops a {1}", wearer.name, owner.name); } }
private void placeMonsters(Room room) { int monsters = TCODRandom.getInstance().getInt(0, Globals.MAX_MON); for (var i = 0; i < monsters; i++) { int mx = TCODRandom.getInstance().getInt(room.x1+1, room.x2-1); int my = TCODRandom.getInstance().getInt(room.y1+1, room.y2-1); if (TCODRandom.getInstance().getInt(0, 100) < 80) { Actor mon = new Actor(mx, my, 't', "thug", TCODColor.darkCyan); mon.destruct = new MonsterDestructible(10, 0, "dead thug", engine); mon.attacker = new Attacker(3); mon.ai = new MonsterAI(); engine.actors.Add(mon); } else { Actor mon = new Actor(mx, my, 'g', "gangster", TCODColor.darkCrimson); mon.destruct = new MonsterDestructible(10, 0, "dead gangster", engine); mon.attacker = new Attacker(3); mon.ai = new MonsterAI(); engine.actors.Add(mon); } } }
public override bool use(Actor owner, Actor wearer) { int x = 0, y = 0; if(!engine.pickTile(ref x, ref y, range)) { return false; } Actor actor = engine.getActor(x, y); if(actor == null) { return false; } ConfusedMonAI confusedAI = new ConfusedMonAI(turnCount, actor.ai); actor.ai = confusedAI; engine.gui.message(TCODColor.lightGreen, "{0} looks to be concussed and confused", actor.name); return base.use(owner, wearer); }