public static void Run(GameSpecification specification, GameCartridge gameCartridge, string devContentPath)
 {
     using (var game = new MachinaGame(specification, gameCartridge, new DesktopPlatformContext(), devContentPath))
     {
         game.Run();
     }
 }
Beispiel #2
0
 public Playback(GameCartridge gameCartridge, Demo demo, int playbackSpeed)
 {
     this.demo                 = demo;
     this.time                 = 0f;
     this.currentIndex         = 0;
     this.demoLength           = this.demo.records.Count;
     this.playbackSpeed        = playbackSpeed;
     gameCartridge.Random.Seed = demo.seedAtStart;
 }
Beispiel #3
0
        private void PlayIntroAndLoadGame(GameCartridge gameCartridge)
        {
            // Steal control
            void OnEnd()
            {
                // Start the actual game
                InsertGameCartridgeAndRun(gameCartridge);
            }

            InsertCartridge(new IntroCartridge(this.specification.settings, OnEnd));
        }
Beispiel #4
0
        private void InsertGameCartridgeAndRun(GameCartridge gameCartridge)
        {
            this.specification.commandLineArgs.ExecuteEarlyArgs();
            InsertCartridge(gameCartridge);
            this.specification.commandLineArgs.ExecuteArgs();

            if (DebugLevel >= DebugLevel.Passive)
            {
                MachinaClient.Print("Debug build detected");
            }
        }
Beispiel #5
0
        public void LateSetup(GameCartridge gameCartridge, WindowInterface windowInterface)
        {
            Console.Out.WriteLine("Constructing SpriteBatch");
            this.WindowInterface = windowInterface;

            Console.Out.WriteLine("Applying settings");
            this.specification.settings.LoadSavedSettingsIfExist(MachinaClient.FileSystem, windowInterface);
            Console.Out.WriteLine("Settings Window Size");
            this.WindowInterface.SetWindowSize(this.specification.settings.startingWindowSize);

            var loadingCartridge = new LoadingScreenCartridge(this.specification.settings);

            InsertCartridge(loadingCartridge);
            loadingCartridge.PrepareLoadingScreen(gameCartridge, this, MachinaClient.Assets as AssetLibrary, this.WindowInterface, FinishLoadingContent);
        }
Beispiel #6
0
        public MachinaGame(GameSpecification specification, GameCartridge gameCartridge, IPlatformContext platformContext, string devContentPath = "")
        {
            this.specification    = specification;
            this.gameCartridge    = gameCartridge;
            this.platformContext  = platformContext;
            Content.RootDirectory = "Content";

            var graphics = new GraphicsDeviceManager(this)
            {
                HardwareModeSwitch = false
            };

            MachinaClient.Setup(new AssetLibrary(this), this.specification, graphics, devContentPath);

            this.platformContext.OnGameConstructed(this);
        }
Beispiel #7
0
        public static void Run(GameCartridge cartridge, GameSpecification spec, Activity activity)
        {
            GamePlatform.Set(PlatformType.Android, GetFilesAtContentDirectory_Android, ReadFileInContentDirectory_Android, ReadTextFile_Android);

            // I don't think I need these but they might be useful
            // activity.Window.AddFlags(WindowManagerFlags.Fullscreen);
            // activity.Window.AddFlags(WindowManagerFlags.LayoutInOverscan);

            var game = new MachinaGame(spec, cartridge, new AndroidPlatformContext());
            var view = game.Services.GetService(typeof(View)) as View;

            view.SystemUiVisibility =
                (StatusBarVisibility)(SystemUiFlags.LayoutStable | SystemUiFlags.LayoutHideNavigation | SystemUiFlags.LayoutFullscreen | SystemUiFlags.HideNavigation | SystemUiFlags.Fullscreen | SystemUiFlags.ImmersiveSticky);
            activity.SetContentView(view);
            game.Run();
        }
Beispiel #8
0
 public Recorder(GameCartridge gameCartridge, string fileName)
 {
     this.demo      = new Demo(gameCartridge.Random.Seed);
     this.totalTime = 0f;
     this.fileName  = fileName;
 }
 public Demo.Playback SetDemo(GameCartridge gameCartridge, Demo demo, string demoName, int playbackSpeed)
 {
     this.playback = new Demo.Playback(gameCartridge, demo, playbackSpeed);
     this.text     = "Playback " + demoName;
     return(this.playback);
 }
 // Start is called before the first frame update
 void Start()
 {
     playerCanMove = true;
     myScore       = "Score: ";
     myGameManager = GameObject.Find("GameCartridge").GetComponent <GameCartridge>();
 }
Beispiel #11
0
        private void FinishLoadingContent(GameCartridge gameCartridge)
        {
#if DEBUG
            DebugLevel = DebugLevel.Passive;
#endif

            // Most cartridges get setup automatically but since the gamecartridge hasn't been inserted yet we have to do it early here
            gameCartridge.SetupSceneLayers(this, specification, WindowInterface);

            var debugActor            = gameCartridge.SceneLayers.DebugScene.AddActor("DebugActor");
            var demoPlaybackComponent = new DemoPlaybackComponent(debugActor);

            var demoName           = Demo.MostRecentlySavedDemoPath;
            var demoSpeed          = 1;
            var shouldSkipSnapshot = DebugLevel == DebugLevel.Off;

            void SetRandomSeedFromString(string seed)
            {
                gameCartridge.Random.Seed = (int)NoiseBasedRNG.SeedFromString(seed);
            }

            this.specification.commandLineArgs.RegisterEarlyFlagArg("skipsnapshot", () => { shouldSkipSnapshot = true; });
            this.specification.commandLineArgs.RegisterEarlyValueArg("randomseed", SetRandomSeedFromString);
            this.specification.commandLineArgs.RegisterEarlyValueArg("demopath", arg => { demoName = arg; });
            this.specification.commandLineArgs.RegisterEarlyValueArg("demospeed", arg => { demoSpeed = int.Parse(arg); });
            this.specification.commandLineArgs.RegisterEarlyValueArg("demo", arg =>
            {
                switch (arg)
                {
                case "record":
                    new DemoRecorderComponent(debugActor, new Demo.Recorder(gameCartridge, demoName));
                    break;

                case "playback":
                    DemoPlayback = demoPlaybackComponent.SetDemo(gameCartridge, Demo.FromDisk_Sync(demoName, MachinaClient.FileSystem), demoName, demoSpeed);
                    break;

                case "playback-nogui":
                    DemoPlayback = demoPlaybackComponent.SetDemo(gameCartridge, Demo.FromDisk_Sync(demoName, MachinaClient.FileSystem), demoName, demoSpeed);
                    demoPlaybackComponent.ShowGui = false;
                    break;

                default:
                    MachinaClient.Print("Unknown demo mode", arg);
                    break;
                }
            });

            this.specification.commandLineArgs.RegisterEarlyFlagArg("debug",
                                                                    () => { DebugLevel = DebugLevel.Active; });

#if DEBUG
            // PlayIntroAndLoadGame(gameCartridge);
            InsertGameCartridgeAndRun(gameCartridge);
#else
            if (SkipIntro)
            {
                InsertGameCartridgeAndRun(gameCartridge);
            }
            else
            {
                PlayIntroAndLoadGame(gameCartridge);
            }
#endif
            // Currently we go [SetupDebugScene] -> [LoadGame] -> [LateSetup], hopefully the cartridge system will mitigate the need for this.
            if (GamePlatform.IsDesktop)
            {
                // NOTE: If we play the intro in a debug build this flag will not be honored, tech debt.
                new SnapshotTaker(debugActor, shouldSkipSnapshot);
            }
        }