Пример #1
0
        public void render(Engine engine)
        {
            if (init)
            {
                loadMapImg();
                init = false;
            }
            con.setBackgroundColor(TCODColor.black);
            con.clear();
            renderBar(1, 1, Globals.BWIDTH, "HP", engine.player.destruct.hp, engine.player.destruct.maxHP, TCODColor.lightRed, TCODColor.darkerRed);
            renderCyl(engine);
            con.print(Globals.WIDTH - 18, 1, " Revolver ");
            img.blit2x(TCODConsole.root, 0, 0);

            int y = 1;
            float colorChanger = 0.4f;
            foreach (Message message in log)
            {
                con.setForegroundColor(message.color.Multiply(colorChanger));
                con.print(Globals.MSGX, y, message.text);
                y++;
                if(colorChanger < 1.0f) {
                    colorChanger += 0.3f;
                }
            }
            TCODConsole.blit(con, 0, 0, Globals.WIDTH, Globals.PANEL, TCODConsole.root, 0, Globals.HEIGHT - Globals.PANEL);
        }
Пример #2
0
        static void Main()
        {
            SaveState saved = load();
            Engine engine;
            State gameState;

            if (saved != null)
            {
                gameState = new State(saved);
                engine = new Engine(gameState, true, new State());
            }
            else
            {
                gameState = new State();
                engine = new Engine(gameState);
            }

            while (!TCODConsole.isWindowClosed())
            {

                engine.update();
                engine.render();
                if (engine.gStatus == Engine.Status.LOSE || engine.gStatus == Engine.Status.WIN)
                {
                    break;
                }
                TCODConsole.flush();
            }

            engine.saveClose();
        }
Пример #3
0
 public void follow(Engine engine, int x, int y)
 {
     if (this.x == engine.player.x && this.y == engine.player.y)
     {
         return;
     }
     if (engine.player.x - x != 0)
     {
         this.x = x;
         this.y = engine.player.y;
     }
     if (engine.player.y != y)
     {
         this.y = y;
         this.x = engine.player.x;
     }
 }
Пример #4
0
        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;
        }
Пример #5
0
        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;
        }
Пример #6
0
 public MonsterDestructible(float maxHP, float def, string deadname, Engine engine)
     : base(maxHP, def, deadname, engine)
 {
 }
Пример #7
0
 public override void update(TCODKey key, Engine engine, Actor owner)
 {
     throw new NotImplementedException();
 }
Пример #8
0
 public abstract void update(Actor owner, Engine engine);
Пример #9
0
 public abstract void update(TCODKey key, Engine engine, Actor owner);
Пример #10
0
 public void handleOtherKeys(Actor player, char keycode, Engine engine)
 {
     switch (keycode)
     {
         case 'g':
             {
                 bool found = false;
                 foreach (Actor actor in engine.actors)
                 {
                     if (actor.pick != null && actor.x == player.x && actor.y == player.y)
                     {
                         if (actor.pick.pick(actor, player, engine))
                         {
                             found = true;
                             engine.gui.message(TCODColor.silver, "You pick up {0}", actor.name);
                             break;
                         }
                         else if (!found)
                         {
                             found = true;
                             engine.gui.message(TCODColor.red, "Your inventory is full!");
                         }
                     }
                 }
                 if (!found)
                 {
                     engine.gui.message(TCODColor.lightGrey, "There's nothing here to find.");
                 }
             }
             break;
         case 'i':
             {
                 Actor item = inventory(player);
                 if (item != null)
                 {
                     item.pick.use(item, player, engine);
                     engine.gStatus = Engine.Status.NEWT;
                 }
             }
             break;
         case 'd':
             {
                 Actor actor = inventory(player);
                 if(actor != null)
                 {
                     actor.pick.drop(actor, player, engine);
                     engine.gStatus = Engine.Status.NEWT;
                 }
             }
             break;
         case 's':
             {
                 if (engine.gameState.curAmmo >= 1)
                 {
                     engine.gameState.curAmmo--;
                     engine.player.gun.use(engine.player.gun, engine.player, engine);
                 }
                 else
                 {
                     engine.gui.message(TCODColor.azure, "No beans...no ammo either.");
                 }
             }
             break;
         default: break;
     }
 }
Пример #11
0
 public void update(TCODKey key, Engine engine)
 {
     if (ai != null) ai.update(key, engine, this);
 }
Пример #12
0
        public override void update(TCODKey key, Engine engine, Actor owner)
        {
            if (owner.destruct != null && owner.destruct.isDead())
            {
                return;
            }

            int dx = 0, dy = 0;
            switch (key.KeyCode)
            {
                case TCODKeyCode.Up: dy = -1; break;
                case TCODKeyCode.Down: dy = 1; break;
                case TCODKeyCode.Left: dx = -1; break;
                case TCODKeyCode.Right: dx = 1; break;
                case TCODKeyCode.Escape:
                    {
                        engine.saveClose();
                        break;
                    }
                case TCODKeyCode.Char: handleOtherKeys(owner, key.Character, engine); break;
                default: break;
            }

            if (dx != 0 || dy != 0)
            {
                engine.gStatus = Engine.Status.NEWT;
                if (moveAttack(owner, owner.x + dx, owner.y + dy, engine))
                {
                    engine.map.computeView();
                }
            }
        }
Пример #13
0
 public override void update(Actor owner, Engine engine)
 {
     throw new NotImplementedException();
 }
Пример #14
0
        public bool moveAttack(Actor owner, int tarx, int tary, Engine engine)
        {
            if (engine.map.isWall(tarx, tary)) return false;
            foreach (Actor actor in engine.actors)
                {
                    if (actor.destruct != null && !actor.destruct.isDead() && actor.x == tarx && actor.y == tary)
                    {
                        owner.attacker.attack(owner, actor, engine);
                        return false;
                    }
                    if (actor.name == "girl" && actor.x == tarx && actor.y == tary)
                    {
                        actor.pick.use(actor, actor);
                    }
                    else if (((actor.destruct != null && actor.destruct.isDead()) || actor.pick != null && actor.name != "door" && actor.name != "trigger") && actor.x == tarx && actor.y == tary)
                    {
                        engine.gui.message(TCODColor.lightGrey, "{0}...", actor.name);
                    }
                    else if (actor.portal != null && actor.x == tarx && actor.y == tary)
                    {
                        changingLevel = true;
                        actor.portal.use(owner, actor);
                        engine.gui.message(TCODColor.purple, "Onwards...");
                        break;
                    }
                    else if (actor.name == "door" && actor.x == tarx && actor.y == tary)
                    {
                        actor.pick.use(actor, actor);
                    }
                    else if (actor.name == "trigger" && actor.x == tarx && actor.y == tary)
                    {
                        actor.pick.use(actor, actor, engine);
                    }
                    else if (actor.blocks && actor.x == tarx && actor.y == tary)
                    {
                        return false;
                    }
                }

            if (!changingLevel)
            {
                owner.x = tarx;
                owner.y = tary;
                return true;

            }

            changingLevel = false;
            return true;
        }
Пример #15
0
 public grenade(float range, float dmg, Engine engine)
 {
     this.range = range;
     this.dmg = dmg;
     this.engine = engine;
 }
Пример #16
0
 public ammo(Engine engine)
 {
     this.engine = engine;
 }
Пример #17
0
        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;
        }
Пример #18
0
 public override bool use(Actor owner, Actor wearer, Engine engine)
 {
     if (engine.gameState.curAmmo == 6)
     {
         engine.gui.message(TCODColor.celadon, "We'll hold onto this for later. The cylinder is full.");
         return false;
     }
     else
     {
         engine.gameState.curAmmo++;
         engine.gui.message(TCODColor.celadon, "The round falls into the cylinder with a metallic click..");
         return base.use(owner, wearer);
     }
 }
Пример #19
0
        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);
            }
        }
Пример #20
0
 public void attack(Actor owner, Actor target, Engine engine)
 {
     if (target.destruct != null && !target.destruct.isDead())
     {
         if (atkpower - target.destruct.def > 0)
         {
             TCODColor color = (target == engine.player) ? TCODColor.red : TCODColor.lightFlame;
             engine.gui.message(color , "{0} attacks {1} for {2} hit points", owner.name, target.name, (atkpower - target.destruct.def).ToString());
         }
         else
         {
             engine.gui.message(TCODColor.grey, "{0} attacks {1} but it has no effect!", owner.name, target.name);
         }
         target.destruct.takeDamage(target, atkpower);
     }
     else
     {
         // Miss, resist, etc
         engine.gui.message(TCODColor.lightGrey, "{0} attacks {1} in vain!", owner.name, target.name);
     }
 }
Пример #21
0
 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);
     }
 }
Пример #22
0
        public override void update(Actor owner, Engine engine)
        {
            int dx = TCODRandom.getInstance().getInt(-1, 1);
            int dy = TCODRandom.getInstance().getInt(-1, 1);

            if (dx != 0 || dy != 0)
            {
                int destx = owner.x + dx;
                int desty = owner.y + dy;

                if (engine.map.canWalk(destx, desty))
                {
                    owner.x = destx;
                    owner.y = desty;
                }
                else
                {
                    Actor actor = engine.getActor(destx, desty);
                    if (actor != null)
                    {
                        owner.attacker.attack(owner, actor, engine);
                    }
                }
            }

            turnCount--;
            if (turnCount == 0)
            {
                owner.ai = oldAI;
            }
        }
Пример #23
0
 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);
     }
 }
Пример #24
0
 public Confuser(int turnCount, float range, Engine engine)
 {
     this.turnCount = turnCount;
     this.range = range;
     this.engine = engine;
 }
Пример #25
0
 public virtual bool use(Actor owner, Actor wearer, Engine engine)
 {
     return use(owner, wearer);
 }
Пример #26
0
 public Destructible(float maxHP, float def, string deadname, Engine engine)
 {
     this.hp = maxHP;
     this.maxHP = maxHP;
     this.def = def;
     this.deadname = deadname;
     this.engine = engine;
 }
Пример #27
0
 public void update(Engine engine)
 {
     if (ai != null) ai.update(this, engine);
     if (pick != null)
     {
         if (pick is Girl)
         {
             Girl girl = pick as Girl;
             if (girl.follow == true)
             {
                 follow(engine, playerOldX, playerOldy);
                 playerOldy = engine.player.y;
                 playerOldX = engine.player.x;
             }
         }
     }
 }
Пример #28
0
 public Girl(Engine engine)
 {
     this.engine = engine;
     this.player = engine.player;
 }
Пример #29
0
        public Map(int width, int height, Engine engine)
        {
            this.tiles = new Tile[width * height];
            this.tmap = new TCODMap(width, height);
            this.gameState = engine.gameState;

            this.rooms = new List<Room>();

            this.width = width;
            this.height = height;
            this.engine = engine;

            reGenMap(gameState.levellist[gameState.curLevel].theLayout, false, true);
        }
Пример #30
0
 public GUI(Engine engine)
 {
     this.engine = engine;
     this.con = new TCODConsole(Globals.WIDTH, Globals.PANEL);
     this.img = new TCODImage("assets/levels/map" + (engine.gameState.curLevel + 1) + ".png");
 }