Ejemplo n.º 1
0
 public Bubble(int xIndex, int yIndex, BubbleColor color)
 {
     this.index = new IndexPair (xIndex, yIndex);
       this.color = color;
 }
Ejemplo n.º 2
0
        // Get a list of indeies of bubbles that connect with new bubble and have the same color.
        private ArrayList GetAdjacentSameColorBubbles(IndexPair newBubbleIndex, BubbleColor color)
        {
            ArrayList bubbleIndexList = new ArrayList ();
              bubbleIndexList.Add (newBubbleIndex);
              Stack bubbleIndexStack = new Stack ();
              bubbleIndexStack.Push (newBubbleIndex);
              while (bubbleIndexStack.Count != 0) {
            IndexPair current = (IndexPair)bubbleIndexStack.Pop ();
            IndexPair[] nearbyIndex = getAllNearbyIndex (current.X, current.Y);
            for (int i = 0; i <= 5; i++) {
              if (!IndexCheck (nearbyIndex [i].X, nearbyIndex [i].Y))
            continue;

              Bubble bubble = bubbleMap [nearbyIndex [i].X, nearbyIndex [i].Y];
              if (bubble == null || bubble.Color != color || bubbleIndexList.Contains (nearbyIndex [i]))
            continue;

              bubbleIndexStack.Push (nearbyIndex [i]);
              bubbleIndexList.Add (nearbyIndex [i]);
            }
              }
              return bubbleIndexList;
        }
Ejemplo n.º 3
0
 private IndexPair[] getAllNearbyIndex(int indexX, int indexY)
 {
     IndexPair[] nearbyIndex = new IndexPair[6]; // left, right, leftup, leftbottom, rightup, rightbottom
       nearbyIndex [0] = new IndexPair (indexX, indexY - 1); // left
       nearbyIndex [1] = new IndexPair (indexX, indexY + 1); // right
       if (indexX % 2 == 0) {
     nearbyIndex [2] = new IndexPair (indexX - 1, indexY); // leftup
     nearbyIndex [3] = new IndexPair (indexX + 1, indexY); // leftbottom
     nearbyIndex [4] = new IndexPair (indexX - 1, indexY + 1); // rightup
     nearbyIndex [5] = new IndexPair (indexX + 1, indexY + 1); // rightbottom
       } else {
     nearbyIndex [2] = new IndexPair (indexX - 1, indexY - 1); // leftup
     nearbyIndex [3] = new IndexPair (indexX + 1, indexY - 1); // leftbottom
     nearbyIndex [4] = new IndexPair (indexX - 1, indexY); // rightup
     nearbyIndex [5] = new IndexPair (indexX + 1, indexY); // rightbottom
       }
       return nearbyIndex;
 }
Ejemplo n.º 4
0
 public Bubble(int xIndex, int yIndex, BubbleColor color)
 {
     this.index = new IndexPair(xIndex, yIndex);
     this.color = color;
 }