/// <summary>
        /// Runs the command line application with specified arguments.
        /// </summary>
        /// <param name="args">The arguments.</param>
        /// <returns>The exit code from the executed command.</returns>
        public async Task <int> RunAsync(IEnumerable <string> args)
        {
            try
            {
                return(await _executor
                       .Execute(_configurator, args)
                       .ConfigureAwait(false));
            }
            catch (Exception ex)
            {
                // Should we propagate exceptions?
                if (_configurator.ShouldPropagateExceptions)
                {
                    throw;
                }

                // Render the exception.
                ConsoleRenderer.Render(GetRenderableErrorMessage(ex));

                // Should we always propagate when debugging?
                if (Debugger.IsAttached &&
                    ex is CommandAppException appException &&
                    appException.AlwaysPropagateWhenDebugging)
                {
                    throw;
                }

                return(-1);
            }
        }
        public void Renderer_TestEmptyCell()
        {
            this.cell = new MazeCell();
            IRenderer dummyRenderer = new ConsoleRenderer();

            dummyRenderer.Render("dummy command", '-');
            this.cell.Render(dummyRenderer);
        }
        public void Renderer_TestPlayerValue()
        {
            this.cell = new MazeCell();
            IRenderer dummyRenderer = new ConsoleRenderer();

            dummyRenderer.Render("dummy command", '*');
            this.cell.Render(dummyRenderer);
        }
Beispiel #4
0
        [STAThread]         /// required to read user input multiple keys at a time
        static void Main(string[] args)
        {
            // Displays a loading message for user
            Console.Write("Loading");
            System.Threading.Thread.Sleep(100);

            // Setup console for a game
            NativeFunctions.InitializeConsole();                /// sets up console for use (no clicks, no arrow keys, etc)
            Console.TreatControlCAsInput = true;                /// prevents keyboard inturrupts, only reads input


            // Initialize engine classes
            ConsoleRenderer.Init();
            Input.Init();
            Time.Init();
            Runesole.Engine.Random.Init();

            // Game Setup
            SpriteManager.GenerateSprites();            /// generates sprites
            WorldBlock.Init();                          /// generates world blocks
            GameManager.Start();                        /// starts the game logic
            GameObject.__CallStartEvent();              /// calls start event on all gameobjects
            Console.Clear();                            /// clears the screen once everything is loaded

            mainLoopStarted = true;                     /// sets main loop started "flag" to true

            // while loop for each frame
            while (true)
            {
                // updates engine classes
                Time.Update();
                Input.Update();
                ConsoleRenderer.Update();

                // core game
                GameObject.__CallUpdateEvent();                                 /// Preforms game logic on gameobjects
                GameManager.Update();                                           /// updates game logic
                CoroutineManager.Update();                                      /// updates coroutine logic
                GameManager.world.Draw(GameManager.camera);                     /// draws the world
                GameObject.__DrawGameObjects(GameManager.camera);               /// draws game objects
                UI.Draw();                                                      ///	draws UI
                ConsoleRenderer.Render();                                       /// renders everything (UI & world) to console

                // updates engine classes end of frame
                GameManager.LateUpdate();
                Input.LateUpdate();
                Time.LateUpdate();

                // Add and destroy any gameobjects at end of frame
                GameObject.__AddGameObjects();
                GameObject.__DestroyGameObjects();
            }
        }
Beispiel #5
0
        public static void Main(string[] args)
        {
            var renderer   = new ConsoleRenderer("Stupid Princess", WindowSizingTool.GetWindowSize());
            var game       = new GameState();
            var timeKeeper = new TimeKeeper(10);

            while (!game.ShouldExit())
            {
                var deltaTime = timeKeeper.WaitForUpdate();
                renderer.Render(game);
                game.Update(deltaTime);
            }
        }
Beispiel #6
0
        /// <summary>
        /// Runs the command line application with specified arguments.
        /// </summary>
        /// <param name="args">The arguments.</param>
        /// <returns>The exit code from the executed command.</returns>
        public async Task <int> RunAsync(IEnumerable <string> args)
        {
            try
            {
                if (!_executed)
                {
                    // Add built-in (hidden) commands.
                    _configurator.AddBranch(Constants.Commands.Branch, cli =>
                    {
                        cli.HideBranch();
                        cli.AddCommand <VersionCommand>(Constants.Commands.Version);
                        cli.AddCommand <XmlDocCommand>(Constants.Commands.XmlDoc);
                    });
                }

                _executed = true;

                return(await _executor
                       .Execute(_configurator, args)
                       .ConfigureAwait(false));
            }
            catch (Exception ex)
            {
                // Render the exception.
                var pretty = GetRenderableErrorMessage(ex);
                if (pretty != null)
                {
                    var renderer = new ConsoleRenderer(_configurator.Settings.Console);
                    foreach (var item in pretty)
                    {
                        renderer.Render(item);
                    }
                }

                // Should we always propagate when debugging?
                if (Debugger.IsAttached &&
                    ex is CommandAppException appException &&
                    appException.AlwaysPropagateWhenDebugging)
                {
                    throw;
                }

                if (_configurator.Settings.PropagateExceptions)
                {
                    throw;
                }

                return(-1);
            }
        }
        public void RenderCorrectlyWritesToConsole(string expected)
        {
            // Fixture setup
            using (var @out = new StringWriter())
            {
                Console.SetOut(@out);

                var sut = new ConsoleRenderer();
                // Exercise system
                sut.Render(expected);
                // Verify outcome
                Assert.Equal(expected, @out.ToString());
                // Teardown
            }
        }
Beispiel #8
0
        private void Render()
        {
            GraphicsContext.CullMode = CullMode.None;
            GraphicsContext.Clear(1.0f);

            SetFilterMode();

            _modelRenderer.SetEffect(_effect);
            _modelRenderer.SelectedAnchor = _editor.FocusAnchor;

            _effect.Technique = _techniqueHandle;
            _effect.Begin();

            _effect.BeginPass(0);

            _effect.SetMatrix("worldMat", Matrix.Identity);
            var wvpm = _viewMat * _projection;

            _effect.SetMatrix("worldViewProjMat", wvpm);

            _effect.CommitChanges();

            _ray = BasicCamera.ScreenToWorldRay(GraphicsContext, MousePosition.X, MousePosition.Y);

            RenderModel();

            _effect.SetMatrix("worldMat", Matrix.Identity);
            _effect.SetMatrix("worldViewProjMat", wvpm);
            _effect.CommitChanges();
            GraphicsContext.World      = Matrix.Identity;
            GraphicsContext.View       = _viewMat;
            GraphicsContext.Projection = _projection;

            _modelRenderer.Wireframe = false;
            _coordinateMarkerRenderer.Render(_effect);
            _modelRenderer.FloorPlane();

            _effect.EndPass();

            _effect.End();

            _guiRenderer.Render(_guiManager);

            _consoleRenderer.Render();
        }
Beispiel #9
0
        public void RenderTest()
        {
            Labyrinth lab = new Labyrinth(4);

            char[,] testMatrix = new char[, ] {
                { '-', 'X', '-', 'X' },
                { '-', '-', '-', 'X' },
                { 'X', 'X', '-', '-' },
                { 'X', 'X', '-', '-' }
            };

            lab.TestMatrix(testMatrix);


            ConsoleRenderer renderer = new ConsoleRenderer();
            var             actual   = renderer.Render(lab);
            var             expected = " - X - X\r\n - - - X\r\n X X - -\r\n X X - -\r\n";

            Assert.AreEqual(expected, actual);
        }
Beispiel #10
0
        protected override void OnRender()
        {
            base.OnRender();
            AlphaBlending(true);

            _guiRenderer.Render(_gui);
            _consoleRenderer.Render();

            if (_gui.HoverWidget != null)
            {
                var widgetPosition = new Vector2(_mousePosition.X, _mousePosition.Y) - _gui.HoverWidget.GetAbsolutePosition();
                var widgetName     = _gui.HoverWidget.UniqueName;

                _font.DrawString("Screen: " + _mousePosition + "  Widget[" + widgetName + "]:" + widgetPosition, 0, 0, Colours.Yellow);
            }
            else
            {
                _font.DrawString("Screen: " + _mousePosition, 0, 0, Colours.Yellow);
            }
        }