// This method is by Urho and controls the game being on the page
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            GameApp game = await surfaceGame.Show <GameApp>(new Urho.ApplicationOptions(assetsFolder: "GameData")
            {
                ResizableWindow = true,
                AdditionalFlags = $"{hardcore.ToString()},{continueGame.ToString()},{charClass.ToString()},{cheat.ToString()}"
            });

            // This method is passed into the game and will be called on restart
            game.Restart = () =>
            {
                Device.BeginInvokeOnMainThread(async() =>
                {
                    await game.Exit();
                    App.Current.MainPage = new MainPage();
                    App.Utilities.SetFullscreen();
                });
                return(false);
            };

            // This method is passed into the game and will be called on win
            game.HandleWin = () =>
            {
                int score = game.PlayerCharacter.Score;

                bool isHighscore = HighScoresManager.CheckScore(score);

                // Exit game
                Device.BeginInvokeOnMainThread(async() =>
                {
                    await game.Exit();
                    App.Current.MainPage = new Win(score, isHighscore);
                    App.Utilities.SetFullscreen();
                });
                return(false);
            };

            // This method is passed into the game and will be called on lose
            game.HandleLose = () =>
            {
                Device.BeginInvokeOnMainThread(async() =>
                {
                    await game.Exit();
                    App.Current.MainPage = new Lose();
                    App.Utilities.SetFullscreen();
                });
                return(false);
            };

            // Load saved game
            if (continueGame)
            {
                game.Load("latest.txt");
            }
        }
        public void Game_Save_CreatesFileWithGameData()
        {
            // retrieve current serialized data from created file to test
            string path         = "./.data/test.txt";
            string originalData = File.ReadLines(path).First();

            // Load the new game
            GameApp game = new GameApp(null);

            game.Load("test.txt");

            // Serialize new game to test
            game.Save("test.txt");
            string newData = File.ReadLines(path).First();

            Assert.IsTrue(newData == originalData);
        }