Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            IReadInputProvider    readInputProvider    = new ConsoleInput();
            ISendOutputProvider   sendOutputProvider   = new ConsoleOutput();
            ITextMessagesProvider textMessagesProvider = new XMLTextMessages("eng.xml");
            ISettingsProvider     settingsProvider     = new XMLSettings("settings.xml");
            ICommands             commands             = new Commands();

            ConsoleDrawing consoleDrawing = new ConsoleDrawing(
                readInputProvider: readInputProvider,
                sendOutputProvider: sendOutputProvider,
                textMessagesProvider: textMessagesProvider,
                settingsProvider: settingsProvider,
                commands: commands);

            consoleDrawing.Run();
        }
Exemplo n.º 2
0
        private static void StartLevel(bool redraw)
        {
            string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\levels\boxworld.xml";

            levelSet = new LevelSet();
            levelSet.SetLevelSet(path);
            levelSet.CurrentLevel = 1;
            levelSet.SetLevelsInLevelSet(path);

            level = (Level)levelSet[levelSet.CurrentLevel - 1];
            draw  = new ConsoleDrawing(level);

            if (redraw)
            {
                Console.Clear();
                draw.DrawLevel();
            }
        }
Exemplo n.º 3
0
        private static void MoveDragger(MoveDirection direction)
        {
            if (direction == MoveDirection.Up)
            {
                level.MoveDragger(MoveDirection.Up);
            }
            else if (direction == MoveDirection.Down)
            {
                level.MoveDragger(MoveDirection.Down);
            }
            else if (direction == MoveDirection.Right)
            {
                level.MoveDragger(MoveDirection.Right);
            }
            else if (direction == MoveDirection.Left)
            {
                level.MoveDragger(MoveDirection.Left);
            }

            // Draw the changes of the level
            DrawChanges();
            if (level.IsFinished())
            {
                Console.WriteLine("You did it in {0} and {1} !!!", level.Moves.ToString(), level.Pushes.ToString());

                if (levelSet.CurrentLevel < levelSet.NrOfLevelsInSet)
                {
                    Console.WriteLine("Good job");
                    levelSet.CurrentLevel++;
                    level = (Level)levelSet[levelSet.CurrentLevel - 1];
                    draw  = new ConsoleDrawing(level);
                    draw.DrawLevel();
                }
                else
                {
                    Console.WriteLine("That was the last level!Well done");
                }
            }
        }