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(); } } } }
/// <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); }
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); } }
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); }
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; }
/// <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); }
/// <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 }); }
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(); } } } //} }
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); } }
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); }
public void setColor(BubbleColor color) { this.color = color; }
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); }
public Bubble(int xIndex, int yIndex, BubbleColor color) { this.index = new IndexPair (xIndex, yIndex); this.color = color; }
public ModelBubble(BubbleColor c, Point p) : base(new Point(p),new Dimension(WIDTH,HEIGHT)) { color = c; }
public Bubble(BubbleColor color){ this._color = color; }
// 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; }
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); }
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; }
// Get color from BubbleColor enum type. public Color GetColor(BubbleColor bubbleColor) { return colorTable [(int)bubbleColor]; }