Exemplo n.º 1
0
 public Level(bool random, Tile[] layout)
 {
     this.random = random;
     this.layout = layout;
     this.startx = 0;
     this.starty = 0;
     this.endx = 0;
     this.endy = 0;
     this.actors = null;
 }
Exemplo n.º 2
0
 public Tile[] saveAndLoad(bool forward)
 {
     Tile[] prevLvl = new Tile[width*height];
     tiles.CopyTo(prevLvl, 0);
     return gameState.changeLvl(forward, prevLvl, engine, entx, enty, exx, exy);
 }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
 public void loadMap(Tile[] nextLvl, bool forward)
 {
     engine.gui.loadMapImg();
     if (nextLvl == null)
     {
         genMap();
         return;
     }
     reGenMap(nextLvl, forward);
     return;
 }