Exemplo n.º 1
0
        private void ColorBubbleSort()
        {
            BubbleColor[] bubbleColors = InitRandomBubbleColors();
            int           brightness   = 40;
            int           n            = bubbleColors.Length;

            for (int x = 0; x < n; x++)
            {
                brightness += 2;
                if (brightness < nusbioPixel.GetMaxBrightness())
                {
                    nusbioPixel.SetBrightness(brightness);
                }

                for (int y = 0; y < n - 1; y++)
                {
                    if (bubbleColors[y].originalPosition > bubbleColors[y + 1].originalPosition)
                    {
                        BubbleColor temp = new BubbleColor();
                        temp.color            = bubbleColors[y + 1].color;
                        temp.originalPosition = bubbleColors[y + 1].originalPosition;

                        bubbleColors[y + 1].color            = bubbleColors[y].color;
                        bubbleColors[y + 1].originalPosition = bubbleColors[y].originalPosition;

                        bubbleColors[y].color            = temp.color;
                        bubbleColors[y].originalPosition = temp.originalPosition;

                        nusbioPixel.SetPixel(y, bubbleColors[y].color.R, bubbleColors[y].color.G, bubbleColors[y].color.B);
                        nusbioPixel.SetPixel(y + 1, bubbleColors[y + 1].color.R, bubbleColors[y + 1].color.G, bubbleColors[y + 1].color.B);
                        nusbioPixel.Show();
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the bubble.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <param name="column">The column.</param>
        /// <param name="color">The color.</param>
        private void AddBubble(int row, int column, BubbleColor color)
        {
            var bubble = new Bubble(row, column, _control, color);

            storage[row, column] = bubble;
            _control.AddBubble(bubble);
        }
Exemplo n.º 3
0
        private void TrySelectBuble(int row, int column, BubbleColor color)
        {
            var bubble = storage[row, column];

            if (bubble == null || bubble.Status != BubbleStatus.Normal || bubble.Color != color)
            {
                return;
            }

            bubble.Status = BubbleStatus.Selected;

            if (column > 0)
            {
                TrySelectBuble(row, column - 1, color);
            }
            if (column < Size - 1)
            {
                TrySelectBuble(row, column + 1, color);
            }
            if (row > 0)
            {
                TrySelectBuble(row - 1, column, color);
            }
            if (row < Size - 1)
            {
                TrySelectBuble(row + 1, column, color);
            }
        }
Exemplo n.º 4
0
    public Bubble CreateRandomBubble(Vector2 bubbleSpawnPosition)
    {
        Bubble      boardBubble       = Instantiate(BubblePrefab, bubbleSpawnPosition, Quaternion.identity).GetComponent <Bubble>();
        BubbleColor randomBubbleColor = (BubbleColor)Random.Range(0, 4);

        boardBubble.SetColor(randomBubbleColor, GetBubbleMaterial(randomBubbleColor));
        return(boardBubble);
    }
Exemplo n.º 5
0
 public Bubble(Game g, BubbleColor c, Point p)
     : base(g, locationX[(int)c], locationY[(int)c], new ModelBubble(c, p))
 {
     isPopped = false;
       isDropped = false;
       isConnected = false;
       currentRotation = Matrix.Identity;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Adds the bubble.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <param name="column">The column.</param>
        /// <param name="color">The color.</param>
        private void AddBubble(int row, int column, BubbleColor color)
        {
            var bubble = new Bubble {
                Color = color
            };

            _control.AddBubble(bubble);
            FieldControl.SetRow(bubble, row);
            FieldControl.SetColumn(bubble, column);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Makes the snap shot.
        /// </summary>
        public void MakeSnapShot(int score)
        {
            BubbleColor[,] shot = new BubbleColor[size, size];
            for (var row = 0; row < size; row++)
            {
                for (var column = 0; column < size; column++)
                {
                    var bubble = storage[row, column];

                    shot[row, column] = bubble == null ? BubbleColor.Empty : bubble.Color;
                }
            }
            _history.AddSnapShot(new Snapshot {
                Score = score, Bubbles = shot
            });
        }
Exemplo n.º 8
0
        private void ColorBubbleSortD()
        {
            //if (this.InvokeRequired)
            //{
            //    ColorBubbleSortDDelegate del = new ColorBubbleSortDDelegate(ColorBubbleSortD);
            //    object[] parameters = { };
            //    this.Invoke(del);
            //}
            //else
            //{
            BubbleColor[] bubbleColors = InitRandomBubbleColors();
            int           brightness   = 40;
            int           n            = bubbleColors.Length;

            for (int x = 0; x < n; x++)
            {
                brightness += 2;
                if (brightness < nusbioPixel.GetMaxBrightness())
                {
                    nusbioPixel.SetBrightness(brightness);
                }

                for (int y = 0; y < n - 1; y++)
                {
                    if (bubbleColors[y].originalPosition > bubbleColors[y + 1].originalPosition)
                    {
                        BubbleColor temp = new BubbleColor();
                        temp.color            = bubbleColors[y + 1].color;
                        temp.originalPosition = bubbleColors[y + 1].originalPosition;

                        bubbleColors[y + 1].color            = bubbleColors[y].color;
                        bubbleColors[y + 1].originalPosition = bubbleColors[y].originalPosition;

                        bubbleColors[y].color            = temp.color;
                        bubbleColors[y].originalPosition = temp.originalPosition;

                        nusbioPixel.SetPixel(y, bubbleColors[y].color.R, bubbleColors[y].color.G, bubbleColors[y].color.B);
                        nusbioPixel.SetPixel(y + 1, bubbleColors[y + 1].color.R, bubbleColors[y + 1].color.G, bubbleColors[y + 1].color.B);
                        nusbioPixel.Show();
                    }
                }
            }
            //}
        }
Exemplo n.º 9
0
    public Material GetBubbleMaterial(BubbleColor bubbleColor)
    {
        switch (bubbleColor)
        {
        case BubbleColor.Green:
            return(GreenMaterial);

        case BubbleColor.Yellow:
            return(YellowMaterial);

        case BubbleColor.Red:
            return(RedMaterial);

        case BubbleColor.Blue:
            return(BlueMaterial);

        default:
            throw new ArgumentOutOfRangeException(nameof(bubbleColor), bubbleColor, null);
        }
    }
Exemplo n.º 10
0
        private BubbleColor[] InitRandomBubbleColors()
        {
            Random rnd = new Random();

            BubbleColor[] bubbleColors = new BubbleColor[nusbioPixel.Count];
            for (int i = 0; i < nusbioPixel.Count; i++)
            {
                var color = RGBHelper.Wheel((i * 256 / nusbioPixel.Count) + 4);
                bubbleColors[i]                  = new BubbleColor();
                bubbleColors[i].color            = color; // r = color.R;
                bubbleColors[i].originalPosition = i;     // = (int)(0.299 * bubbleColors[i].r + 0.587 * bubbleColors[i].g + 0.144 * bubbleColors[i].b);
            }
            bubbleColors = bubbleColors.OrderBy(a => Guid.NewGuid()).ToArray <BubbleColor>();
            for (int i = 0; i < nusbioPixel.Count; i++)
            {
                nusbioPixel.SetPixel(i, bubbleColors[i].color.R, bubbleColors[i].color.G, bubbleColors[i].color.B);
            }
            nusbioPixel.SetBrightness(30);
            nusbioPixel.Show();
            return(bubbleColors);
        }
Exemplo n.º 11
0
 public void setColor(BubbleColor color)
 {
     this.color = color;
 }
Exemplo n.º 12
0
 public ModelBubble(BubbleColor c, Point p)
     : base(new Point(p),new Dimension(WIDTH,HEIGHT,DEPTH))
 {
     color = c;
       motionRotation = new Point(0.0f, 0.0f, 0.0f);
 }
Exemplo n.º 13
0
 public Bubble(int xIndex, int yIndex, BubbleColor color)
 {
     this.index = new IndexPair (xIndex, yIndex);
       this.color = color;
 }
Exemplo n.º 14
0
 public ModelBubble(BubbleColor c, Point p)
     : base(new Point(p),new Dimension(WIDTH,HEIGHT))
 {
     color = c;
 }
Exemplo n.º 15
0
		public Bubble(BubbleColor color){
			this._color = color;
			
		}
Exemplo n.º 16
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;
        }
Exemplo n.º 17
0
 public void changeColor(BubbleColor color)
 {
     ModelBubble b = (ModelBubble)this.displayable;
       b.setColor(color);
       section = new Rectangle(locationX[(int)color], locationY[(int)color], dimensions.width, dimensions.height);
 }
Exemplo n.º 18
0
 public Bubble(Game g, Texture2D t, BubbleColor c, Point p)
     : base(g,t, files[(int)c], locationX[(int)c], locationY[(int)c], new ModelBubble(c, p))
 {
     isPopped = false;
 }
Exemplo n.º 19
0
 // Get color from BubbleColor enum type.
 public Color GetColor(BubbleColor bubbleColor)
 {
     return colorTable [(int)bubbleColor];
 }