Ejemplo n.º 1
0
        /// <summary>
        /// Generates level by selected size and adds nodes to dictionary. Later we update the nodes by adding a number of bombs they are connected to.
        /// </summary>
        private void CreateLevel()
        {
            // Random rand = new Random();
            int maxBombs = levelSize;

            if (LevelSizeSelected.Equals(LevelSize.Medium))
            {
                maxBombs *= 2;
            }
            else if (LevelSizeSelected.Equals(LevelSize.Expert))
            {
                maxBombs *= 3;
            }
            for (int x = 1; x < levelSize + 1; x++)
            {
                for (int y = 1; y < levelSize + 1; y++)
                {
                    // Note: the ':' is used to avoid duplicate keys as 1:11 and 11:1 would be the same
                    node.Add(x + ":" + y, new Node {
                        Value = 0, Revealed = false
                    });
                }
            }
            GenerateBombs(maxBombs);
            GenerateMineProximity();
            DrawGame(0, 0);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Call this method to initialize the game. By default game will initialize to Easy 10x10
 /// </summary>
 public void PrepareLevel()
 {
     node.Clear();
     gameOver = false;
     for (int i = 0; i < Sizes.Length; i++)
     {
         if (LevelSizeSelected.Equals((LevelSize)i))
         {
             levelSize = Sizes[i];
             CreateLevel();
             // CustomLevel();
             DrawGame(0, 0);
         }
     }
 }