Esempio n. 1
0
        public static GameControler Load()
        {
            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
            if ( !settings.Contains("Saved") || settings["Saved"].ToString() == false.ToString())
            {
                return null;
            }

            Board board = new Board();
            GameControler ctrl;
            try
            {
                using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
                {
                    using (IsolatedStorageFileStream isoStream = store.OpenFile(@"board.dat", FileMode.Open))
                    {
                        BinaryReader br = new BinaryReader(isoStream);
                        board.Deserialize(br);
                        br.Close();
                    }
                }
                ctrl = new GameControler(board);

                ctrl.SetUpGame(parseType(settings["Game.Player1"].ToString()), parseType(settings["Game.Player2"].ToString()));

                if (settings["Game.CurrentTurnFrom"].ToString() == 1.ToString())
                {
                    ctrl.currentPlayer = ctrl.player1;
                }
                else
                {
                    ctrl.currentPlayer = ctrl.player2;
                }

                return ctrl;
            }
            catch (Exception)
            {
                return null;
            }
        }
Esempio n. 2
0
        private void initGame()
        {
            if (gameControler == null)
            {
                gameControler = new GameControler();
                gameControler.aiLevel = getLevel();
                if (NavigationContext.QueryString["side"].ToLower() == "zero")
                {
                    gameControler.SetUpGame(PlayerType.Machine, PlayerType.Human);
                }
                else
                {
                    gameControler.SetUpGame(PlayerType.Human, PlayerType.Machine);
                }
            }

            // TODO: use this.content to load your game content here
            Microsoft.Xna.Framework.Rectangle gameRect = new Microsoft.Xna.Framework.Rectangle(0, 0, (int)ActualWidth, (int)ActualHeight );
            game = new XoGame(SharedGraphicsDeviceManager.Current.GraphicsDevice, gameControler, gameRect, content);

            game.LoadContent();
            game.TurnAnimationEvent += OnAnimationReady;
        }