internal void StoreLevel()
        {
            LevelMemory storedLevel = (from mem in LevelMemory
                                       where mem.DungeonLevel == DungeonLevel
                                       select mem).FirstOrDefault();

            if (storedLevel == null)
            {
                Coordinate upstairs = (from obj in Objects
                                       where obj.Upstairs == true
                                       select new Coordinate
                {
                    X = obj.X,
                    Y = obj.Y
                }).FirstOrDefault();

                Coordinate downstairs = (from obj in Objects
                                         where obj.Downstairs == true
                                         select new Coordinate
                {
                    X = obj.X,
                    Y = obj.Y
                }).FirstOrDefault();

                LevelMemory level = new LevelMemory(Objects, Map, DungeonLevel, upstairs, downstairs);
                level.Objects.Remove(Player);
                LevelMemory.Add(level);
            }
            else
            {
                storedLevel.Objects = Objects;
                storedLevel.Objects.Remove(Player);
            }
        }
Exemplo n.º 2
0
        public static void NextLevel()
        {
            Rogue.GameWorld.StoreLevel();

            Rogue.GameWorld.DungeonLevel += 1;
            MessageLog.AddMessage("You descend deeper into the dungeon.");

            LevelMemory loadedLevel = Rogue.GameWorld.LoadLevel();

            if (loadedLevel != null)
            {
                Rogue.GameWorld.Map     = loadedLevel.Map;
                Rogue.GameWorld.Objects = loadedLevel.Objects;
                Rogue.GameWorld.Objects.Add(Rogue.GameWorld.Player);

                Rogue.GameWorld.Player.X = loadedLevel.Upstairs.X;
                Rogue.GameWorld.Player.Y = loadedLevel.Upstairs.Y;

                Camera.SetCamera();
            }
            else
            {
                MakeMap(Constants.Direction.Down);
            }
        }
        internal LevelMemory LoadLevel()
        {
            LevelMemory storedLevel = (from mem in LevelMemory
                                       where mem.DungeonLevel == DungeonLevel
                                       select mem).FirstOrDefault();

            return(storedLevel);
        }
Exemplo n.º 4
0
        public static Constants.PlayerAction PreviousLevel()
        {
            if (Rogue.GameWorld.DungeonLevel == 1)
            {
                int?choice = Menu.BasicMenu("Are you sure you want to exit the dungeon?", new List <string>()
                {
                    "Yes"
                }, "No");

                if (choice != null)
                {
                    return(Constants.PlayerAction.ExitWithoutSave);
                }
                else
                {
                    return(Constants.PlayerAction.NotUsedTurn);
                }
            }
            else
            {
                Rogue.GameWorld.StoreLevel();

                Rogue.GameWorld.DungeonLevel -= 1;
                MessageLog.AddMessage("You ascend higher into the dungeon.");

                LevelMemory loadedLevel = Rogue.GameWorld.LoadLevel();
                if (loadedLevel != null)
                {
                    Rogue.GameWorld.Map     = loadedLevel.Map;
                    Rogue.GameWorld.Objects = loadedLevel.Objects;
                    Rogue.GameWorld.Objects.Add(Rogue.GameWorld.Player);

                    Rogue.GameWorld.Player.X = loadedLevel.Downstairs.X;
                    Rogue.GameWorld.Player.Y = loadedLevel.Downstairs.Y;

                    Camera.SetCamera();
                }
                else
                {
                    MakeMap(Constants.Direction.Up);
                }

                return(Constants.PlayerAction.UsedTurn);
            }
        }