Example #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((GemName != null ? GemName.GetHashCode() : 0) * 397) ^ (Version != null ? Version.GetHashCode() : 0));
     }
 }
Example #2
0
 public Gem(GameBoard board, GemName name, Rectangle bounds, Point index)
 {
     this.board  = board;
     this.name   = name;
     this.bounds = bounds;
     this.index  = index;
 }
Example #3
0
 public Gem(GameBoard board, GemName name, Rectangle bounds, Point index)
 {
     this.board = board;
     this.name = name;
     this.bounds = bounds;
     this.index = index;
 }
Example #4
0
 public void GenerateGem(GemName name)
 {
     Point cursor = gameMain.inGame.gameBoard.GetTranslatedCursor();
     foreach (List<Gem> list in gameMain.inGame.gameBoard.board)
         foreach(Gem gem in list) {
             if (Helpers.IsWithin(gem.bounds, cursor)) {
                 gem.name = name;
                 return;
             }
         }
 }
Example #5
0
        public void GenerateGem(GemName name)
        {
            Point cursor = gameMain.inGame.gameBoard.GetTranslatedCursor();

            foreach (List <Gem> list in gameMain.inGame.gameBoard.board)
            {
                foreach (Gem gem in list)
                {
                    if (Helpers.IsWithin(gem.bounds, cursor))
                    {
                        gem.name = name;
                        return;
                    }
                }
            }
        }
Example #6
0
        public void LoadBoardFromFile(string location)
        {
            board = new Board();
            List <GemName> gemsList = new List <GemName>();

            try {
                StreamReader sr = new StreamReader(location);

                while (!sr.EndOfStream)
                {
                    string temp = sr.ReadLine();
                    for (int i = 0; i < temp.Length; i++)
                    {
                        if (temp[i] == ' ')
                        {
                            continue;
                        }
                        int readNum = temp[i] - 48;
                        gemsList.Add((GemName)readNum);
                    }
                }
                sr.Close();
            }
            catch (FileNotFoundException)
            {
                System.Windows.Forms.MessageBox.Show("The file could not be found.");
            }

            int listIndex = 0;

            for (int i = 0; i < size; i++)
            {
                List <Gem> rowList = new List <Gem>();
                for (int j = 0; j < size; j++)
                {
                    Rectangle bounds   = new Rectangle(playField.X + Gem.size * j, playField.Y + Gem.size * i, Gem.size, Gem.size);
                    Point     index    = new Point(i, j);
                    GemName   tempRand = gemsList[listIndex++];
                    //Create a gem that does not create a triplet with adjacent gems

                    Gem gem = new Gem(this, tempRand, bounds, index);
                    rowList.Add(gem);
                }
                board.Add(rowList);
            }
        }
Example #7
0
 public void ResetToNothing()
 {
     name = GemName.Nothing;
 }
Example #8
0
 public void ResetToNothing()
 {
     name = GemName.Nothing;
 }