Exemple #1
0
        public void GoUpDownStair()
        {
            if (GC.PC.ActualStamina < 1)
            {
                Game.topTextArea.AddMessage(Game.Lang[StringName.TIRED_TEXT]);
                return;
            }
            MapTile tile;
            StairWay stair = new StairWay();
            StairWay newStair = new StairWay();
            Level lvl = new Level();
            Point newPos = new Point();
            bool stairs = false;
            string lvlname;

            tile = GC.CurrentMap.getMapTile(GC.PC.getX(),GC.PC.getY());
            //check if stairs are on same tile as player
            foreach (Object o in tile._objects)
            {
                if (o.getType() == ObjectType.O_STAIRWAY)
                {
                    stairs = true;
                    stair = o as StairWay;
                }
            }
            if (!stairs)
            {
                if (dir.Key == ConsoleKey.OemPeriod)
                {
                    topTextArea.AddMessage("There is no stairs leading downwards");
                }
                else if (dir.Key == ConsoleKey.OemComma)
                {
                    topTextArea.AddMessage("There is no stairs leading upwards");
                }
                
            }
            else
            {
                //check if we selected proper key
                if (dir.Key == ConsoleKey.OemPeriod && stair.Type != StairWaysType.DOWN)
                {
                    topTextArea.AddMessage("There is no stairs leading downwards");
                    return;
                }
                if (dir.Key == ConsoleKey.OemComma && stair.Type != StairWaysType.UP)
                {
                    topTextArea.AddMessage("There is no stairs leading upwards");
                    return;
                }
                //remove player from current location
                tile.removeObject(GC.PC);
                //get position of stairs on next level
                //get name of next level
                lvlname = stair.LevelName;
                foreach (Level l in GC.WorldLevels)
                {
                    if (l.Name == lvlname)
                    {
                        lvl = l;
                        break;
                    }
                }
                //get stairs from new level
                if (dir.Key == ConsoleKey.OemPeriod)
                {
                    newStair = lvl.Entrance;
                    newStair.hasBeenSeen();
                }
                else if (dir.Key == ConsoleKey.OemComma)
                {
                    newStair = lvl.Exit;
                    newStair.hasBeenSeen();
                }
                newPos = newStair.Position;
                //set new level's map  as current
                GC.CurrentMap = lvl.Map;
                //set current level
                GC.CurrentLevel = lvl;
                //set new entity list from new level
                GC.Entities = lvl.EntityList;
                //set player at new map
                GC.CurrentMap.addObjectAt(newPos.X + GC.CurrentMap.getOffsetX(), newPos.Y + GC.CurrentMap.getOffsetY(), GC.PC);
                //use stamina every  5 minutes (ie 30 rounds) if not in comabt
                if (Game.GC.turnCounter != 0 && Game.GC.turnCounter % 30 == 0)
                {
                    GC.PC.ActualStamina -= 1;
                }
                Game.bottomPanel.needUpdate = true;
                ClearMap();
                GC.CurrentMap.draw();
            }
        }