Example #1
0
 public XoGame(GraphicsDevice device, GameControler gameController, Rectangle rect, ContentManager content, IInputEnumerator input)
 {
     this.gameController = gameController;
     this.screenRect = rect;
     this.content = content;
     this.device = device;
     this.inputEnumerator = input;
     gameLayers = new LayersCollection();
     scrollLayer = new ScrollLayer(gameLayers, screenRect);
 }
Example #2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            stat = new GameStatistics();
            // Set the sharing mode of the graphics device to turn on XNA rendering
            SharedGraphicsDeviceManager.Current.GraphicsDevice.SetSharingMode(true);

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(SharedGraphicsDeviceManager.Current.GraphicsDevice);

            if (NavigationContext.QueryString["resume"].ToLower() == "true")
            {
                gameControler = GameControler.Load();
            }

            initGame();

            // Start the timer
            timer.Start();

            base.OnNavigatedTo(e);

            undoButton = (Microsoft.Phone.Shell.ApplicationBarIconButton)ApplicationBar.Buttons[1];
        }
Example #3
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;
            }
        }
Example #4
0
 private void restartButton_Click(object sender, EventArgs e)
 {
     gameControler = null;
     initGame();
 }
Example #5
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;
        }
Example #6
0
 public XoGame(GraphicsDevice device, GameControler gameController, Rectangle rect, ContentManager content)
     : this(device, gameController, rect, content, new DefaultInputEnumerator())
 {
 }