Exemplo n.º 1
0
        public static void Run()
        {
            Resolver resolver = new Resolver(AGSGame.Device, new AGSGameSettings("MonoAGS Editor", new Size(1280, 800),
                                                                                 windowSize: new Size(1280, 800), windowState: WindowState.Normal, preserveAspectRatio: false));
            IGame game = AGSGame.Create(resolver);

            //Rendering the text at a 4 time higher resolution than the actual game, so it will still look sharp when maximizing the window.
            GLText.TextResolutionFactorX = 4;
            GLText.TextResolutionFactorY = 4;

            game.Events.OnLoad.Subscribe(async() =>
            {
                game.Factory.Resources.ResourcePacks.Add(new ResourcePack(new FileSystemResourcePack(AGSGame.Device.FileSystem, AGSGame.Device.Assemblies.EntryAssembly), 0));
                game.Factory.Resources.ResourcePacks.Add(new ResourcePack(new EmbeddedResourcesPack(AGSGame.Device.Assemblies.EntryAssembly), 1));
                game.Factory.Fonts.InstallFonts("Fonts/Font Awesome 5 Free-Solid-900.otf", "Fonts/Fira/FiraSans-Regular.ttf");
                FontIcons.Init(game.Factory.Fonts);
                game.Settings.Defaults.TextFont   = game.Factory.Fonts.LoadFontFromPath("Fonts/Fira/FiraSans-Regular.ttf", 14f, FontStyle.Regular);
                game.Settings.Defaults.SpeechFont = game.Settings.Defaults.TextFont;

                AGSEditor editor = resolver.Container.Resolve <AGSEditor>();
                editor.Editor    = game;

                game.Settings.Defaults.Skin = null;

                WelcomeScreen screen = new WelcomeScreen(editor);
                screen.Load();
                screen.Show();

                var room = game.Factory.Room.GetRoom("MainEditorRoom");
                ReflectionCache.Refresh();
                await game.State.ChangeRoomAsync(room);
            });

            game.Start();
        }
Exemplo n.º 2
0
        public static void Run()
        {
            FakeAGSTestGameStarter starter = new FakeAGSTestGameStarter();
            var game = AGSGame.CreateEmpty();

            _gameDebugView = new Lazy <GameDebugView>(() =>
            {
                var gameDebugView = new GameDebugView(game, new KeyboardBindings(game.Input));
                gameDebugView.Load();
                return(gameDebugView);
            });

            starter.StartGame(game);

            Size screenSize = new AGS.API.Size(320, 200);
            int  factor     = 2;

            AGSGameSettings settings = new AGSGameSettings(
                "Demo Game",
                screenSize,
                windowSize: new AGS.API.Size(screenSize.Width * factor, screenSize.Height * factor),
                windowState: WindowState.Normal);

            game.Start(settings);
        }
Exemplo n.º 3
0
        public static void Run()
        {
            IGame game = AGSGame.CreateEmpty();

            _gameDebugView = new Lazy <GameDebugView>(() =>
            {
                var gameDebugView = new GameDebugView(game);
                gameDebugView.Load();
                return(gameDebugView);
            });

            //Rendering the text at a 4 time higher resolution than the actual game, so it will still look sharp when maximizing the window.
            GLText.TextResolutionFactorX = 4;
            GLText.TextResolutionFactorY = 4;

            game.Events.OnLoad.Subscribe(async() =>
            {
                game.Factory.Fonts.InstallFonts("../../Assets/Fonts/pf_ronda_seven.ttf", "../../Assets/Fonts/Pixel_Berry_08_84_Ltd.Edition.TTF");
                AGSGameSettings.DefaultSpeechFont     = game.Factory.Fonts.LoadFontFromPath("../../Assets/Fonts/pf_ronda_seven.ttf", 14f, FontStyle.Regular);
                AGSGameSettings.DefaultTextFont       = game.Factory.Fonts.LoadFontFromPath("../../Assets/Fonts/Pixel_Berry_08_84_Ltd.Edition.TTF", 14f, FontStyle.Regular);
                AGSGameSettings.CurrentSkin           = null;
                game.State.RoomTransitions.Transition = AGSRoomTransitions.Fade();
                setKeyboardEvents(game);
                Shaders.SetStandardShader();

                addDebugLabels(game);
                Debug.WriteLine("Startup: Loading Assets");
                await loadPlayerCharacter(game);
                Debug.WriteLine("Startup: Loaded Player Character");
                await loadSplashScreen(game);
            });

            game.Start(new AGSGameSettings("Demo Game", new AGS.API.Size(320, 200),
                                           windowSize: new AGS.API.Size(640, 400), windowState: WindowState.Normal));
        }
Exemplo n.º 4
0
        public static void Run()
        {
            setupResolver();

            IGame game = AGSGame.CreateEmpty();

            //Rendering the text at a 4 time higher resolution than the actual game, so it will still look sharp when maximizing the window.
            GLText.TextResolutionFactorX = 4;
            GLText.TextResolutionFactorY = 4;

            game.Events.OnLoad.Subscribe(async() =>
            {
                AGSGameSettings.CurrentSkin = null;

                //addDebugLabels(game);
                WelcomeScreen screen = new WelcomeScreen(game);
                screen.Load();
                screen.Show();

                var room = game.Factory.Room.GetRoom("MainEditorRoom");
                await game.State.ChangeRoomAsync(room);
            });

            game.Start(new AGSGameSettings("MonoAGS Editor", new AGS.API.Size(1280, 800),
                                           windowSize: new AGS.API.Size(1280, 800), windowState: WindowState.Normal, preserveAspectRatio: false));
        }
Exemplo n.º 5
0
        public static void Run()
        {
            DemoStarter starter = new DemoStarter();
            var         game    = AGSGame.Create(starter.Settings);

            starter.StartGame(game);
            game.Start();
        }
Exemplo n.º 6
0
        private static async Task load(AGSProject agsProj)
        {
            var(games, assembly) = await GetGames(agsProj);

            if (games.Count == 0)
            {
                throw new Exception($"Cannot load game: failed to find an instance of IGameCreator in {agsProj.AGSProjectPath}.");
            }
            if (games.Count > 1)
            {
                throw new Exception($"Cannot load game: found more than one instance of IGameCreator in {agsProj.AGSProjectPath}.");
            }
            var gameCreatorImplementation = games[0];
            var gameCreator = (IGameStarter)Activator.CreateInstance(gameCreatorImplementation);
            var game        = AGSGame.CreateEmpty();

            gameCreator.StartGame(game);

            KeyboardBindings keyboardBindings = null;

            if (game is AGSGame agsGame) //todo: find a solution for any IGame implementation
            {
                Resolver resolver = agsGame.GetResolver();
                keyboardBindings = resolver.Container.Resolve <KeyboardBindings>();
                var resourceLoader = resolver.Container.Resolve <IResourceLoader>();
                resourceLoader.ResourcePacks.Add(new ResourcePack(new EmbeddedResourcesPack(assembly), 2));
            }

            _gameDebugView = new Lazy <GameDebugView>(() =>
            {
                var gameDebugView = new GameDebugView(game, keyboardBindings);
                gameDebugView.Load();
                return(gameDebugView);
            });

            game.Start(new AGSGameSettings("Demo Game", new AGS.API.Size(320, 200),
                                           windowSize: new AGS.API.Size(640, 400), windowState: WindowState.Normal));

            keyboardBindings.OnKeyboardShortcutPressed.Subscribe(async action =>
            {
                if (action == KeyboardBindings.GameView)
                {
                    var gameDebug = _gameDebugView.Value;
                    if (gameDebug.Visible)
                    {
                        gameDebug.Hide();
                    }
                    else
                    {
                        await gameDebug.Show();
                    }
                }
            });
        }
Exemplo n.º 7
0
        public static void Run()
        {
            IGame game = AGSGame.CreateEmpty();

            game.Events.OnLoad.Subscribe(async() =>
            {
                setupGame(game);
                await loadIntroRoom(game);
            });

            game.Start(new AGSGameSettings("A Game", new AGS.API.Size(1280, 720), windowState: WindowState.Normal));
        }
Exemplo n.º 8
0
        // TODO: proper struct to pass arguments
        public static void Run(string asset_path, string user_path)
        {
            AMG.Init(asset_path, user_path);
            IGame game = AGSGame.CreateEmpty();

            game.Events.OnLoad.Subscribe(async() =>
            {
                setupGame(game);
                await AMG.Rooms.MixerRoom.GotoAsync();
            });

            game.Start(new AGSGameSettings("Audio Mixer Test Game", new AGS.API.Size(1280, 800), windowState: WindowState.Normal));
        }
Exemplo n.º 9
0
        // TODO: proper struct to pass arguments
        public static void Run(string asset_path, string user_path)
        {
            LF.Init(asset_path, user_path);
            IGame game = AGSGame.CreateEmpty();

            game.Events.OnLoad.Subscribe(async() =>
            {
                setupGame(game);
                await LF.Rooms.TitleScreen.GotoAsync();
            });

            game.Start(new AGSGameSettings("Last & Furious", new AGS.API.Size(640, 400), windowState: WindowState.Normal));
        }
Exemplo n.º 10
0
        // TODO: proper struct to pass arguments
        public static void Run(string asset_path, string user_path)
        {
            Assets.Init(asset_path, user_path);
            IGame game = AGSGame.CreateEmpty();

            game.Events.OnLoad.Subscribe(async() =>
            {
                setupGame(game);
                await Assets.Rooms.ParallaxRoom.GotoAsync();
            });

            game.Start(new AGSGameSettings("Layer Game", new AGS.API.Size(640, 400), windowState: WindowState.Normal));
        }
Exemplo n.º 11
0
        public static void Run()
        {
            DemoStarter starter = new DemoStarter();
            var         game    = AGSGame.CreateEmpty();

            _gameDebugView = new Lazy <GameDebugView>(() =>
            {
                var gameDebugView = new GameDebugView(game, new KeyboardBindings(game.Input));
                gameDebugView.Load();
                return(gameDebugView);
            });

            starter.StartGame(game);
            game.Start(new AGSGameSettings("Demo Game", new AGS.API.Size(320, 200),
                                           windowSize: new AGS.API.Size(640, 400), windowState: WindowState.Normal));
        }
Exemplo n.º 12
0
        private static async Task load(AGSProject agsProj, AGSEditor editor)
        {
            var(games, assembly) = await GetGames(agsProj);

            if (games.Count == 0)
            {
                throw new Exception($"Cannot load game: failed to find an instance of {nameof(IGameStarter)} in {agsProj.AGSProjectPath}.");
            }
            if (games.Count > 1)
            {
                throw new Exception($"Cannot load game: found more than one instance of {nameof(IGameStarter)} in {agsProj.AGSProjectPath}.");
            }
            var gameCreatorImplementation = games[0];
            var gameCreator = (IGameStarter)Activator.CreateInstance(gameCreatorImplementation);

            var editorResolver = editor.EditorResolver;
            var updatePump     = editorResolver.Container.Resolve <IUpdateMessagePump>();

            var gameSettings = gameCreator.Settings;
            var gameResolver = new Resolver(AGSGame.Device, gameSettings);

            gameResolver.Builder.RegisterType <EditorShouldBlockEngineInput>().SingleInstance().As <IShouldBlockInput>().As <EditorShouldBlockEngineInput>();
            gameResolver.Builder.RegisterInstance(updatePump).As <IUpdateMessagePump>().As <IUpdateThread>();
            AGSEditor.Platform.SetResolverForGame(gameResolver, editorResolver);
            var game = AGSGame.Create(gameResolver);

            editor.Game         = game;
            editor.GameResolver = gameResolver;
            gameCreator.StartGame(game);

            var keyboardBindings = new KeyboardBindings(editor.Editor.Input);
            var actions          = editorResolver.Container.Resolve <ActionManager>();
            var resourceLoader   = gameResolver.Container.Resolve <IResourceLoader>();

            resourceLoader.ResourcePacks.Add(new ResourcePack(new FileSystemResourcePack(AGSGame.Device.FileSystem, assembly), 2));
            resourceLoader.ResourcePacks.Add(new ResourcePack(new EmbeddedResourcesPack(assembly), 3));

            EditorShouldBlockEngineInput blocker = gameResolver.Container.Resolve <EditorShouldBlockEngineInput>();

            var toolbar = new GameToolbar(blocker, editor.Editor.Input, editor.Editor.State, editor.Editor.Settings);

            toolbar.Init(editor.Editor.Factory, editor);

            game.Events.OnLoad.Subscribe(() =>
            {
                editor.Init();

                var gameDebugView = new GameDebugView(editor, keyboardBindings, actions, toolbar);
                toolbar.SetGame(game, editor.GameResolver.Container.Resolve <IWindowInfo>(), gameDebugView.Tree);
                var canvas = new GameCanvas(editor, toolbar, gameDebugView.Tree);
                canvas.Init();
                gameDebugView.Load();
                gameDebugView.Show();

                keyboardBindings.OnKeyboardShortcutPressed.Subscribe(async action =>
                {
                    if (action == KeyboardBindings.GameView)
                    {
                        if (gameDebugView.Visible)
                        {
                            gameDebugView.Hide();
                        }
                        else
                        {
                            await gameDebugView.Show();
                        }
                    }
                });
            });

            game.Start();
        }