Start() public method

public Start ( ) : void
return void
Example #1
0
        private void _startSinglePlayer()
        {
            MainGame game = null;

            game = new MainGame();
            game.OnNavigateBack += game_OnNavigateBack;
            game.NetworkClient   = null;
            MainGame.BackwardNavigationService = this.NavigationService;
            game.Start();
            startButton.IsEnabled = true;
        }
Example #2
0
 public void StartGame() => MainGame.Start();
Example #3
0
        private void btnReplay_Click(object sender, RoutedEventArgs e)
        {
            if (!Directory.Exists("./Replays"))
            {
                Directory.CreateDirectory("./Replays");
            }
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.InitialDirectory = Directory.GetCurrentDirectory() + "\\Replays";
            dlg.DefaultExt       = ".sgs";                                                                        // Default file extension
            dlg.Filter           = "Replay File (.sgs)|*.sgs|Crash Report File (.rpt)|*.rpt|All Files (*.*)|*.*"; // Filter files by extension
            bool?result = dlg.ShowDialog();

            if (result != true)
            {
                return;
            }

            string fileName = dlg.FileName;

            Client   client;
            MainGame game = null;

            try
            {
                client = new Client();
                game   = new MainGame();
                game.OnNavigateBack += game_OnNavigateBack;
                Stream stream = File.Open(fileName, FileMode.Open);
                byte[] seed   = new byte[8];
                stream.Seek(-16, SeekOrigin.End);
                stream.Read(seed, 0, 8);
                if (System.Text.Encoding.Default.GetString(seed).Equals(Misc.MagicAnimal.ToString("X8")))
                {
                    stream.Read(seed, 0, 8);
                    game.HasSeed = Convert.ToInt32(System.Text.Encoding.Default.GetString(seed), 16);
                }
                stream.Seek(0, SeekOrigin.Begin);

                byte[] bytes = new byte[4];
                stream.Read(bytes, 0, 4);
                int length = BitConverter.ToInt32(bytes, 0);
                if (length != 0)
                {
                    byte[] msg = new byte[length];
                    stream.Read(msg, 0, length);
                    UnicodeEncoding uniEncoding = new UnicodeEncoding();
                    MessageBox.Show(new String(uniEncoding.GetChars(msg)));
                }
                client.StartReplay(stream);
                game.NetworkClient = client;
            }
            catch (Exception)
            {
                MessageBox.Show("Failed to open replay file.");
                return;
            }
            if (game != null)
            {
                MainGame.BackwardNavigationService = this.NavigationService;
                game.Start();
                // this.NavigationService.Navigate(game);
            }
        }