Ejemplo n.º 1
0
        public void Draw(Transform2 parentTransform)
        {
            var chars = GameWorld.Characters
                        .OrderBy(x => x.CurrentTile.Position.X)
                        .ThenBy(x => x.CurrentTile.Position.Y).ToList();

            Perf.Time("Drew Walls + Floors", () => GameWorld.Map.Tiles.ForEach(x =>
            {
                x.Draw(Floors, parentTransform, MultiplyColor);
                x.Draw(Walls, parentTransform, MultiplyColor);
            }));
            Perf.Time("Drew Highlights", () => GameWorld.Highlights.Draw(parentTransform));
            Perf.Time("Drew Under Char Objects", () => GameWorld.Map.Tiles.ForEach(x =>
            {
                x.Draw(UnderChar1, parentTransform, MultiplyColor);
                x.Draw(UnderChar2, parentTransform, MultiplyColor);
            }));
            Perf.Time("Drew Characters", () => chars.ForEach(x => x.Draw(parentTransform)));
            Perf.Time("Drew Over Char Objects", () => GameWorld.Map.Tiles.ForEach(x =>
            {
                x.Draw(OverChar1, parentTransform, MultiplyColor);
                x.Draw(OverChar2, parentTransform, MultiplyColor);
                x.Draw(Shadows, parentTransform, MultiplyColor);
                x.Draw(FogOfWar, parentTransform);
            }));
            Perf.Time("Drew High Highlights", () => GameWorld.HighHighlights.Draw(parentTransform));
            Perf.Time("Drew PostFX", () => GameWorld.Map.Tiles.ForEach(x => _fx.Draw(parentTransform, x)));
            Perf.Time("Drew Char UI", () => chars.ForEach(x => x.DrawUI(parentTransform)));
        }
Ejemplo n.º 2
0
 private GameMap LoadMap()
 {
     return(Perf.Time("Loaded Map",
                      () => new GameMapFactory().CreateGameMap(
                          new Tmx(CurrentGame.GraphicsDevice, MapDir, MapFileName),
                          TileData.RenderSize)));
 }
 protected override void Initialize()
 {
     try
     {
         Perf.Time($"{nameof(NeedlesslyComplexMainGame)}.Initialize", () =>
         {
             CurrentGame.Init(this);
             Resources.Init();
             // @todo #1 Bug: Update the GraphicsDeviceManager in the constructor, to avoid the window being mispositioned and visibly changing size
             CurrentDisplay.Init(_graphics, _display);
             Window.Position = new Point((GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width - CurrentDisplay.GameWidth) / 2,
                                         (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height - CurrentDisplay.GameHeight) / 2 - 40); // Delete this once the above issue is fixed
             IsMouseVisible    = true;
             _uiSpriteBatch    = new SpriteBatch(GraphicsDevice);
             _worldSpriteBatch = new SpriteBatch(GraphicsDevice);
             Input.SetController(_controller);
             World.Init(_worldSpriteBatch);
             UI.Init(_uiSpriteBatch);
             _scene.Init();
             base.Initialize();
         });
     }
     catch (Exception e)
     {
         _errorHandler.Handle(new Exception("Error while Initializing MonoDragons Core engine", e));
     }
 }
Ejemplo n.º 4
0
 private static void Main()
 {
     HandleExceptions(() =>
     {
         using (var game = Perf.Time("Startup", () => CreateGame("Lobby")))
             game.Run();
     });
 }
Ejemplo n.º 5
0
        public virtual void Draw(Transform2 parentTransform)
        {
            var t = _useAbsolutePosition ? Transform2.Zero : parentTransform + GetOffset();

            _visuals.ForEach(x =>
            {
                Perf.Time($"Drew {x.GetType().Name}", () => x.Draw(t), 20);
            });
        }
Ejemplo n.º 6
0
 static void Main()
 {
     var appDetails = new MetaAppDetails("MonoDragons.Core", "1.0", Environment.OSVersion.VersionString);
     var fatalErrorReporter = new ReportErrorHandler(appDetails);
     Metric.AppDetails = appDetails;
     Error.HandleAsync(() =>
     {
         using (var game = Perf.Time("Startup", () => new NeedlesslyComplexMainGame(appDetails.Name, "Logo", new Display(1600, 900, false), SetupScene(), CreateKeyboardController(), fatalErrorReporter)))
             game.Run();
     }, x => fatalErrorReporter.ResolveError(x)).GetAwaiter().GetResult();
 }
Ejemplo n.º 7
0
 protected override void Initialize()
 {
     Perf.Time($"{nameof(NeedlesslyComplexMainGame)}.Initialize", () =>
     {
         CurrentGame.Init(this);
         Resources.Init();
         InitDisplayIfNeeded();
         // @todo #1 Bug: Update the GraphicsDeviceManager in the constructor, to avoid the window being mispositioned and visibly changing size
         CurrentDisplay.Init(_graphics, _display);
         Window.Position = new Point(0, 0); // Delete this once the above issue is fixed
         IsMouseVisible  = true;
         _sprites        = new SpriteBatch(GraphicsDevice);
         Input.SetController(_controller);
         World.Init(_sprites);
         UI.Init(_sprites);
         _scene.Init();
         base.Initialize();
     });
 }
Ejemplo n.º 8
0
 private static void RunGame(string sceneName)
 {
     try
     {
         using (var game = Perf.Time("Startup", () => new NeedlesslyComplexMainGame(AppMeta.Name, sceneName,
                                                                                    new Display(1600, 900, false), SetupScene(), CreateKeyboardController(), FatalErrorHandler)))
             game.Run();
     }
     catch (Exception e)
     {
         FatalErrorHandler.ResolveError(e);
         MessageBox.Show($"Your game has crashed, probably due to hacking by ZantoCorp.\n\n" +
                         $"The Fatal Error has been automatically reported.\n\n" +
                         $"Thank you for helping us with Quality Assurance!\n\n" +
                         $"Credits have been automatically deposited into your bank account.\n\n" +
                         $"Error: '{e.Message}'\n" +
                         $"StackTrace: {e.StackTrace}");
     }
 }
Ejemplo n.º 9
0
 public void Draw(Transform2 parentTransform)
 {
     _visuals.ForEach(x => Perf.Time($"Drew {x.GetType().Name}", () => x.Draw(parentTransform)));
 }
Ejemplo n.º 10
0
 static void Main()
 {
     using (var game = Perf.Time("Startup", () => new NeedlesslyComplexMainGame("MonoDragons.Core", "Logo", new Display(1600, 900, false), SetupScene(), CreateKeyboardController())))
         game.Run();
 }