Esempio n. 1
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     menu = new Scenes.Menu(ModifySaveFile.FileExists());
     game = new Scenes.GameState();
     this.IsMouseVisible = true;
     base.Initialize();
 }
Esempio n. 2
0
 public void SetNewGame()
 {
     ModifySaveFile.DeleteFile();
     ModifySaveFile.DeleteFile();
     for (int i = 0; i < 4; i++)
     {
         for (int j = 0; j < 4; j++)
         {
             tileNumber[i, j]     = -1;
             prevTileNumber[i, j] = -1;
         }
     }
     prevScore = 0;
     score     = 0;
     lose      = false;
     SetRandomTile();
 }
Esempio n. 3
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            switch (state)
            {
            case GameState.MainMenu:
                switch (menu.Update(gameTime))
                {
                case 1:
                    state = GameState.Game;
                    ModifySaveFile.DeleteFile();
                    game.StartGame(0);
                    break;

                case 2:
                    state = GameState.Game;
                    game.StartGame(1);
                    break;
                }
                break;

            case GameState.Game:
                switch (game.Update(gameTime))
                {
                case 1:
                    state = GameState.MainMenu;
                    break;
                }
                break;
            }

            base.Update(gameTime);
        }
Esempio n. 4
0
 public void SaveGame()
 {
     ModifySaveFile.SaveFile(score, tileNumber);
 }
Esempio n. 5
0
 public Board()
 {
     highScore = ModifySaveFile.ReadHighScore();
     moved     = false;
 }
Esempio n. 6
0
        public void MakeMovement(int move)
        {
            if (moved)
            {
                return;
            }
            int[,] prevTileProt = new int[4, 4];
            EqualTileNumbers(ref prevTileProt, ref tileNumber);
            prevScore = score;
            animList.Clear();
            switch (move)
            {
            case 0:
                moved = Move0();
                break;

            case 1:
                moved = Move1();
                break;

            case 2:
                moved = Move2();
                break;

            case 3:
                moved = Move3();
                break;

            case 4:
                moved = Move4();
                break;

            case 5:
                moved = Move5();
                break;

            case 6:
                moved = Move6();
                break;

            case 7:
                moved = Move7();
                break;
            }
            if (moved)
            {
                EqualTileNumbers(ref prevTileNumber, ref prevTileProt);
                SetRandomTile();
                //moved = false;
                if (score > highScore)
                {
                    highScore = score;
                    ModifySaveFile.SaveHighScore(highScore);
                }
                if (isFull())
                {
                    if (hasLost())
                    {
                        lose = true;
                    }
                }
            }
        }
Esempio n. 7
0
 public void OpenSavedGame()
 {
     ModifySaveFile.ReadFile(ref score, ref tileNumber);
     EqualTileNumbers(ref prevTileNumber, ref tileNumber);
     prevScore = score;
 }