void Awake() { bScript = bubble.GetComponent<Bubble> (); actualBubble = getRandomBubbleColor(); nextBubble = getRandomBubbleColor(); updateBubbles (); }
public BubbleContent(Bubble parent, string text = "") { this.parent = parent; double radius = parent.getRadius(); textblock = new TextBlock() { Text = text, Foreground = new SolidColorBrush(ColorSettings.TextColor), TextAlignment = Windows.UI.Xaml.TextAlignment.Center, FontSize = Preferences.FontSize, FontFamily = Preferences.FontFamily, Width = radius * 2, MaxHeight = radius * 2, TextWrapping = TextWrapping.WrapWholeWords, TextTrimming = TextTrimming.CharacterEllipsis, VerticalAlignment = VerticalAlignment.Center, }; textcontainer = new Border() { Height = radius * 2, Child = textblock, }; BubbleContainer.canvas.Children.Add(textcontainer); Canvas.SetZIndex(textcontainer, Int16.MaxValue); }
// Use this for initialization void Start() { _bubble = GetComponent<Bubble>(); _cooldown = new Cooldown(); _cooldown.StartTimer(cooldownTime); }
void Awake() { if (!instance) { gameObject.SetActive(false); instance = this; } this.text = GetComponent<Text>(); }
public GameObject[] getNeighbours(Bubble bubbleScript, Vector3 localPosition) { Vector3 rowCol = bubbleScript.rowCol; //Debug.Log ("--x:"+rowCol.x+", y:"+rowCol.y); GameObject[] neighbours = new GameObject[6]; //Left and Right neighbours[0] = matrixBubble["x:"+(rowCol.x-1)+", y:"+(rowCol.y)] as GameObject; neighbours[1] = matrixBubble["x:"+(rowCol.x+1)+", y:"+(rowCol.y)] as GameObject; //Up and Down neighbours[2] = matrixBubble["x:"+(rowCol.x)+", y:"+(rowCol.y-1)] as GameObject; neighbours[3] = matrixBubble["x:"+(rowCol.x)+", y:"+(rowCol.y+1)] as GameObject; if (rowCol.y % 2 == 0) { //In a even row we see left neighbours[4] = matrixBubble["x:"+(rowCol.x+1)+", y:"+(rowCol.y+1)] as GameObject; neighbours[5] = matrixBubble["x:"+(rowCol.x+1)+", y:"+(rowCol.y-1)] as GameObject; } else { //In a odd row we see right neighbours [4] = matrixBubble ["x:" + (rowCol.x - 1) + ", y:" + (rowCol.y + 1)] as GameObject; neighbours [5] = matrixBubble ["x:" + (rowCol.x - 1) + ", y:" + (rowCol.y - 1)] as GameObject; } //Debug.Log (rowCol+""+neighbours[0]+"0"); //Debug.Log (rowCol+""+neighbours[1]+"1"); //Debug.Log (rowCol+""+neighbours[2]+"2"); //Debug.Log (rowCol+""+neighbours[3]+"3"); //Debug.Log (rowCol+""+neighbours[4]+"4"); //Debug.Log (rowCol+""+neighbours[5]+"5"); return neighbours; }
public Bubbles(Rectangle hitBox, Vector2 motion, Texture2D texture) { r = new Random(); this.hitBox = hitBox; this.motion = motion; int numOfBubbles = hitBox.Width * hitBox.Height / 1024; bubbles = new Bubble[numOfBubbles]; for (int i = 0; i < bubbles.Length; i++) bubbles[i] = new Bubble(motion, new Vector2(r.Next(hitBox.X, hitBox.X + hitBox.Width - 8), r.Next(hitBox.Y, hitBox.Y + hitBox.Height - 8)), texture); }
public static void AddLogPanel(string text) { Bubble item = new Bubble(); item.InerText = text; item.BackColor = "Black"; LANChat.ServerPage._LogBox.Items.Add(item); LANChat.ServerPage._LogBox.SelectedIndex = LANChat.ServerPage._LogBox.Items.Count - 1; LANChat.ServerPage._LogBox.ScrollIntoView(LANChat.ServerPage._LogBox.SelectedItem); }
EventMobile ToInterop(Event e, Bubble b) { EventMobile em = new EventMobile(); em.Id = e.Id; em.ProviderName = b.Profile.Nickname; em.MsgTitle = b.Name; em.Msg = b.AlertMsg; em.Timestamp = e.Timestamp; return(em); }
public async Task <ActionResult <Bubble> > PostBubble([FromBody] Bubble bubble) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Bubbles.Add(bubble); await _context.SaveChangesAsync(); return(Created($"api/bubble/{bubble.Id}", bubble)); }
public void TestBubbleSort(int[] arr) { Bubble bubbleSort = new Bubble(); int[] sortedArray = new int[arr.Length]; Array.Copy(arr, sortedArray, arr.Length); Array.Sort(sortedArray); Assert.That(() => bubbleSort.BubbleSort(arr), Is.EquivalentTo(sortedArray)); }
public void ShouldWorkCorrectlyWithTwoElements() { IBubble bubble = new Bubble(); int[] numbers = new int[] { 2, 1 }; bubble.Sort(numbers); Assert.AreEqual(1, numbers[0]); Assert.AreEqual(2, numbers[1]); }
public void FillPanel() { for (int index = 0; index < BubbleCount; index++) { Bubble bubble = new Bubble(Panel.Childs.Count, Panel); bubble.Margin = BubbleMargin; bubble.LoadSize(BubbleSideSize); SetBubble(bubble); } }
public void DestroyBubbles() { while (bubbles.Count > 0) { GameObject bubbleGameObject = bubbles.First(); Bubble bubble = bubbleGameObject.GetComponent <Bubble>(); bubble.DestroyBubble(); RemoveBubble(bubbleGameObject); } }
public bool IsColorBomb(Bubble bubble) { Bomb bomb = bubble.GetComponent <Bomb>(); if (bomb != null) { return(bomb.bombType == BombType.Color); } return(false); }
public void EventBubble(Bubble b) { if (b != null) { ServiceManager.OnBubbleReceived(b); } else { DebugPrint(Information.ServiceName + " is trying to 'event' a null bubble. Doing nothing..."); } }
public void SortOneItemList() { //Arrange & Act Bubble <int> bubble = new Bubble <int>(10); List <int> expectedOutput = new List <int>() { 10 }; //Assert Assert.AreEqual(expectedOutput, bubble); }
public void BubbleSort_SingleRepeatingNumber_WorksCorrectly() { int[] arr = { 1, 1, 1, 1, 1 }; int[] expectedResult = { 1, 1, 1, 1, 1 }; Bubble.BubbleSort(arr); int[] actualResult = arr; Assert.That(actualResult, Is.EqualTo(expectedResult)); }
public void StartCall(MonoBehaviour target, float time) { currentBulle = callBulle; Vector3 position = new Vector3((target.transform.position.x + currentOffsetX), currentBulle.transform.position.y, (target.transform.position.z + currentOffsetZ)); Bubble myBubble = Instantiate(currentBulle, position, currentBulle.transform.rotation); myBubble.SetValues(callOffsetX, callOffsetZ, target, time); myBubble.Init(); }
public void BubbleSort_2NumbersUnsorted_WorksCorrectly() { int[] arr = { 2, 1 }; int[] expectedResult = { 1, 2 }; Bubble.BubbleSort(arr); int[] actualResult = arr; Assert.That(actualResult, Is.EqualTo(expectedResult)); }
virtual public void Heal(int dHeal) { Hp = Hp + dHeal; if (Hp > maxHp) { Hp = maxHp; } if (dHeal > 0) { Bubble.AddBubble(BubbleSprType.hp, "+" + dHeal.ToString(), this, true); } }
protected void AddBubbleButton_Click(object sender, EventArgs e) { if (LocalProcessList.SelectedValue == null || LocalProcessList.SelectedValue == "") { return; } Guid localProcessId = new Guid(LocalProcessList.SelectedValue); LocalProcess localProcess = LocalProcessLogic.GetLocalProcess(localProcessId); Bubble bubble = BubbleLogic.AddBuble(DaemonHttpContext.LoggedInParticipant, localProcess); Response.Redirect(Request.Url.OriginalString); }
public void SortCollection() { int[] numbersToSort = { int.MaxValue, int.MinValue, 0, 1, -1 }; var bubble = new Bubble(); bubble.Sort(numbersToSort); int[] expectedSortedNumbers = { int.MinValue, -1, 0, 1, int.MaxValue }; Assert.That(numbersToSort, Is.EquivalentTo(expectedSortedNumbers)); }
public void BubbleCanSortNumbers(params int[] numbersToSort) { // Arrange var bubble = new Bubble(); var sortedNumbers = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; // Act bubble.Sort(numbersToSort); // Assert CollectionAssert.AreEqual(sortedNumbers, numbersToSort); }
public void Constuctior_InitilizeObject_CollectionCountIsSetUp() { var list = new List <int>() { 5, 4, 6, 8, 6 }; var bubble = new Bubble <int>(list); var expected = list.Count; var actual = bubble.Collection.Count; Assert.That(actual, Is.EqualTo(expected)); }
public void BubbleSort_5Numbers_WorksCorrectly() { int[] arr = { 1, 3, 2, 8, 6 }; int[] expectedResult = { 1, 2, 3, 6, 8 }; Bubble.BubbleSort(arr); int[] actualResult = arr; Assert.That(actualResult, Is.EqualTo(expectedResult)); }
public BubbleShape(Bubble parent) { this.parent = parent; double radius = parent.getRadius(); shape = new Ellipse() { Width = radius * 2, Height = radius * 2, Fill = new SolidColorBrush(ColorSettings.BubbleColor) }; BubbleContainer.canvas.Children.Add(shape); }
public void CreateBubble(Item item) { GameObject bubble = Instantiate(bubblePrefab); bubble.transform.SetParent(transform); Bubble currBubble = bubble.GetComponent <Bubble>(); currBubble.SetItemSprite(item.graphic); bubbles.Add(currBubble); RefreshPositionBubble(); }
public void ClearBubbleAt(int x, int y) { Bubble bubbleToClear = m_board.allBubbles[x, y]; if (bubbleToClear != null) { m_board.allBubbles[x, y] = null; Destroy(bubbleToClear.gameObject); } //HighlightTileOff(x,y); }
public void BubbleSort_NegativeNumbers_WorksCorrectly() { int[] arr = { 2, -3, -8, 1232, -678, 0 }; int[] expectedResult = { -678, -8, -3, 0, 2, 1232 }; Bubble.BubbleSort(arr); int[] actualResult = arr; Assert.That(actualResult, Is.EqualTo(expectedResult)); }
public void BubbleSort_EmptyArray_WorksCorrectly() { int[] arr = { }; int[] expectedResult = { }; Bubble.BubbleSort(arr); int[] actualResult = arr; Assert.That(actualResult, Is.EqualTo(expectedResult)); }
public void BubbleSort_ReverseOrder_WorksCorrectly() { int[] arr = { 5, 4, 3, 2, 1 }; int[] expectedResult = { 1, 2, 3, 4, 5 }; Bubble.BubbleSort(arr); int[] actualResult = arr; Assert.That(actualResult, Is.EqualTo(expectedResult)); }
public void BubbleSort_AlreadySorted_WorksCorrectly() { int[] arr = { 1, 2, 3, 4, 5 }; int[] expectedResult = { 1, 2, 3, 4, 5 }; Bubble.BubbleSort(arr); int[] actualResult = arr; Assert.That(actualResult, Is.EqualTo(expectedResult)); }
private System.Collections.IEnumerator Attaching(Bubble bubble) { allow = false; Bubble checkBubble = bubble; do { checkBubble = scoreManager.Attached(checkBubble); yield return(new WaitForSeconds(chainingDelay)); } while (checkBubble != null); allow = true; }
virtual public void HealLife(int dHeal) { life = life + dHeal; if (life > maxLife) { life = maxLife; } if (dHeal > 0) { Bubble.AddBubble(BubbleSprType.life, "+" + dHeal.ToString(), this, true); } }
public void createWaterColumns() { List <Bubble> bubbles = new List <Bubble>(); List <Block> blocks = new List <Block>(); PreWaterNode[,] vector = new PreWaterNode[GameConst.height, GameConst.width]; PreWaterNode node = new PreWaterNode(); node.row = row; node.col = col; node.type = WaterColumn.WaterType.Center; node.isObstacle = false; node.isBubble = true; vector[row, col] = node; find(ref vector); for (int i = 0; i < GameConst.height; i++) { for (int k = 0; k < GameConst.width; k++) { if (vector[i, k] != null) { PreWaterNode node_ = vector[i, k]; if (node_.isObstacle) { Block block = GameConst.sceneObstacles[i, k].GetComponent <Block>(); if (block != null) { blocks.Add(block); } } else if (node_.isBubble) { Bubble bubble = GameConst.bubbles[i, k]; bubble.trigger = true; bubbles.Add(GameConst.bubbles[i, k]); CreateWaterColumn(i, k, WaterColumn.WaterType.Center); } else { CreateWaterColumn(i, k, node_.type); } } } } foreach (Block block in blocks) { block.BeDestory(); } foreach (Bubble bubble in bubbles) { bubble.BeDestory(); } }
public Bubble[] PumpAir() { var x = _rnd.Next(10, 100); var bubbles = new Bubble[x]; for (var a = 0; a < x; a++) { bubbles[a] = (Bubble)_rnd.Next(1, 3); } return(bubbles); }
public void CreateBubbleList() { //Arrange & Act Bubble <int> bubble = new Bubble <int>(5, 3, 4, 1, 2); List <int> expectedOutput = new List <int>() { 1, 2, 3, 4, 5 }; //Assert Assert.AreEqual(expectedOutput, bubble); }
void FindBubbles(Bubble src, List<Bubble> found) { src.dontCheck = true; foreach (Bubble b in bubbles) { if (b.dontCheck == false && b.markedToRemove == false && IsNear(src, b) && src.type == b.type) { found.Add(b); FindBubbles(b, found); } } //src.dontCheck = false; }
public void Absorbtion(Bubble bubbleOther) { Bubble bubbleThis = _bubble; // controll BubbleController controllerThis = this; BubbleController controllerOther = bubbleOther.GetComponent<BubbleController>(); // suffixes & sizes float[] sizesThis = bubbleThis.getSizes(); float[] sizesOther = bubbleOther.getSizes(); float sizeAll = bubbleThis.GetRadiusTarget() + bubbleOther.GetRadiusTarget(); for (int i = 0, count = sizesThis.Length; i < count; ++i) { controllerThis.suffixes[i] = new Tuple<string, float>(controllerThis.suffixes[i].Item1, sizesThis[i] / sizeAll); } for (int i = 0, count = sizesOther.Length; i < count; ++i) { controllerOther.suffixes[i] = new Tuple<string, float>(controllerOther.suffixes[i].Item1, sizesOther[i] / sizeAll); } controllerThis.suffixes.AddRange(controllerOther.suffixes); //controllerThis.suffixes = controllerThis.suffixes.Distinct().ToList(); // size _bubble.ChangeRadius(bubbleOther.GetRadiusTarget()); // // change color //GameObject managers = GameObject.Find("Managers"); //GameManager gameManager = managers.GetComponent<GameManager>(); var meshRendererThis = GetComponentInChildren<MeshRenderer>().material; var meshRendererOther = bubbleOther.GetComponentInChildren<MeshRenderer>().material; float r = (meshRendererThis.color.r + meshRendererOther.color.r) / 2.0f; float g = (meshRendererThis.color.g + meshRendererOther.color.g) / 2.0f; float b = (meshRendererThis.color.b + meshRendererOther.color.b) / 2.0f; meshRendererThis.color = new Color(r, g, b); // // camera var camerasOther = bubbleOther.GetComponentsInChildren<Camera>(); for (int i = 0, count = camerasOther.Length; i < count; ++i) { camerasOther[i].transform.parent = gameObject.transform; } // Destroy(bubbleOther.gameObject); }
//创建泡泡 void InstanceBubble(Transform contain, char id) { GameObject obj = PoolManager.GetObject(PrefabKey.Bubble); obj.SetActive(true); //设置层级位置 Transform BubbleTran = obj.transform; BubbleTran.parent = contain; BubbleTran.localPosition = Position; BubbleTran.localScale = Vector2.zero;//用于缩放 //初始化泡泡 Bubble = BubbleTran.GetComponent<Bubble>(); Bubble.InitComponent(); Bubble.InitBubble(id); Bubble.Slot = this; Bubble.isAbsorb = true; }
public static ImmutableBubbleBurstGrid Create(Bubble[][] grid) { var result = ImmutableList.CreateBuilder<ImmutableList<Bubble>.Builder>(); var height = grid.Length; for (var i = 0; i < height; i++) { result.Add(ImmutableList.CreateBuilder<Bubble>()); } for (var i = 0; i < height; i++) { Debug.WriteLine($"Adding {string.Join(",", grid[i])} to position ({i})"); result[i].AddRange(grid[i]); } return new ImmutableBubbleBurstGrid(result.ToImmutableGrid()); }
/// <summary> /// initializes the bubbles /// </summary> private void InitializeBubbles() { for (int column = 0; column < BubbleColumns; column++) { for (int row = 0; row < BubbleRows; row++) { MyMaterial material = MyMaterial.GetRandomMaterial(); //get a random color //create a new bubble var go = (GameObject)Instantiate(BubbleParameter, new Vector3((float)column * BubbleParameter.transform.localScale.x, (float)row * BubbleParameter.transform.localScale.y, 0f), Quaternion.identity); go.tag = material.ColorName; BubblesArray[column, row] = new Bubble(go, material); go.name = column.ToString() + "-" + row.ToString(); var renderer = go.transform.GetComponent<Renderer>(); renderer.material = material; //set the color } } }
IEnumerator Shake(Bubble bubble) { isShake = true; Vector2 dir = mTran.position - bubble.mTran.position;//计算方向 float scope = ScopeBase / dir.magnitude;//计算幅度,距离越远,幅度越小 if (scope > ShakeMax) scope = ShakeMax;//限制幅度 Vector2 from = Slot.Position;//起始位置 Vector2 to = from + (dir.normalized * scope);//震动位置 //震动 while (true) { if (!isShake) yield break;//停止动画 mTran.localPosition = Vector2.Lerp(mTran.localPosition, to, Time.deltaTime * ShakeSpeed); float dis = Vector2.Distance(mTran.localPosition, to); if (dis <= ShakeMinDis) break; yield return 0; } //归位 while (true) { if (!isShake) yield break;//停止动画 mTran.localPosition = Vector2.Lerp(mTran.localPosition, from, Time.deltaTime * ShakeSpeed); float dis = Vector2.Distance(mTran.localPosition, from); if (dis <= ShakeMinDis) break; yield return 0; } mTran.localPosition = from; //状态回复 yield return 0; isShake = false; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); imageArray = new Texture2D[21]; colorArray = new Color[21][]; bombImageIndex.X = 0; bombImageIndex.Y = 5; imageArray[0] = Content.Load<Texture2D>("Weapon/weapon01"); imageArray[1] = Content.Load<Texture2D>("Weapon/weapon02"); imageArray[2] = Content.Load<Texture2D>("Weapon/weapon03"); imageArray[3] = Content.Load<Texture2D>("Weapon/weapon02"); imageArray[4] = Content.Load<Texture2D>("Weapon/weapon01"); vineImageIndex.X = 5; vineImageIndex.Y = 4; imageArray[5] = Content.Load<Texture2D>("Vine/vinebase"); imageArray[6] = Content.Load<Texture2D>("Vine/vinebase02"); imageArray[7] = Content.Load<Texture2D>("Vine/vinebase03"); imageArray[8] = Content.Load<Texture2D>("Vine/vinebase04"); bubbleImageIndex.X = 10; bubbleImageIndex.Y = 5; imageArray[10] = Content.Load<Texture2D>("Bubble/bubble00"); imageArray[11] = Content.Load<Texture2D>("Bubble/bubble01"); imageArray[12] = Content.Load<Texture2D>("Bubble/bubble02"); imageArray[13] = Content.Load<Texture2D>("Bubble/bubble03"); imageArray[14] = Content.Load<Texture2D>("Bubble/Gas 001"); wallImageIndex.X = 15; wallImageIndex.Y = 2; imageArray[15] = Content.Load<Texture2D>("walledge00"); imageArray[16] = Content.Load<Texture2D>("walledge01"); imageArray[20] = Content.Load<Texture2D>("Cursor/cursor02"); colorArray[0] = new Color[imageArray[0].Width * imageArray[0].Height]; colorArray[1] = new Color[imageArray[1].Width * imageArray[1].Height]; colorArray[2] = new Color[imageArray[2].Width * imageArray[2].Height]; colorArray[3] = new Color[imageArray[3].Width * imageArray[3].Height]; colorArray[4] = new Color[imageArray[4].Width * imageArray[4].Height]; colorArray[5] = new Color[imageArray[5].Width * imageArray[5].Height]; colorArray[6] = new Color[imageArray[6].Width * imageArray[6].Height]; colorArray[7] = new Color[imageArray[7].Width * imageArray[7].Height]; colorArray[8] = new Color[imageArray[8].Width * imageArray[8].Height]; colorArray[10] = new Color[imageArray[10].Width * imageArray[10].Height]; colorArray[11] = new Color[imageArray[11].Width * imageArray[11].Height]; colorArray[12] = new Color[imageArray[12].Width * imageArray[12].Height]; colorArray[13] = new Color[imageArray[13].Width * imageArray[13].Height]; colorArray[15] = new Color[imageArray[15].Width * imageArray[15].Height]; colorArray[16] = new Color[imageArray[16].Width * imageArray[16].Height]; imageArray[0].GetData(colorArray[0]); imageArray[1].GetData(colorArray[1]); imageArray[2].GetData(colorArray[2]); imageArray[3].GetData(colorArray[3]); imageArray[4].GetData(colorArray[4]); imageArray[5].GetData(colorArray[5]); imageArray[6].GetData(colorArray[6]); imageArray[7].GetData(colorArray[7]); imageArray[8].GetData(colorArray[8]); imageArray[10].GetData(colorArray[10]); imageArray[15].GetData(colorArray[15]); imageArray[16].GetData(colorArray[16]); vineMake = Content.Load<SoundEffect>("Vine/vineMake"); vineDestroy = Content.Load<SoundEffect>("Vine/vineDestroyHigh"); vineHit = Content.Load<SoundEffect>("Vine/vineHit02"); coreHit = Content.Load<SoundEffect>("coreHitSudden"); backgroundHum = Content.Load<SoundEffect>("lowThump").CreateInstance(); backgroundHum.Volume = 0.3f; //reduces headaches sFont = Content.Load<SpriteFont>("SpriteFont1"); for (int i = 0; i < wallCount; i++) { Sprite s = new Wall(); leftWallList.Add(s); } objectList.Add(leftWallList); for (int i = 0; i < wallCount; i++) { Sprite s = new Wall(); ((Wall)s).Flip(); rightWallList.Add(s); } objectList.Add(rightWallList); for (int i = 0; i < vineCount; i++) { SpriteList sl = new SpriteList();//Vine(); for (int j = 0; j < vineCount; j++) { Sprite s = new Vine(); sl.Add(s); } vineList.Add(sl); } objectList.Add(vineList); for (int i = 0; i < bombCount; i++) { Sprite s = new Bomb(); bombList.Add(s); } objectList.Add(bombList); for (int i = 0; i < bubbleCount; i++) { Sprite s = new Bubble(); bubbleList.Add(s); } uI.Add(bubbleList); //think they should always move. they are cosmetic afterall cursor = new Cursor(); uI.Add(cursor); objectList.Setup(); uI.Setup(); FindBorders(); State = GAME_MENU; // Comment out this line for one game // to clear the high score //GetHighScore(); }
public static void DrawEnvironmentBar(Game game, SpriteBatch spriteBatch, SpriteFont statsFont, int currentEnvironment, int maxEnvironemnt) { int barX = game.Window.ClientBounds.Width - 10 - (int)(41 * textScaleFactor); int barY = game.Window.ClientBounds.Height / 2 - (int)(EnvironmentBar.Height / 2 * textScaleFactor); string type = "ENVIRONMENT"; Color typeColor = Color.IndianRed; int barWidth = (int)(41 * textScaleFactor);// EnvironmentBar.Width / 2; double healthiness = (double)currentEnvironment / maxEnvironemnt; //Draw the negative space for the health bar //spriteBatch.Draw(EnvironmentBar, // new Rectangle(barX, barY, barWidth, EnvironmentBar.Height), // new Rectangle(barWidth + 1, 0, barWidth, EnvironmentBar.Height), // Color.Transparent); //Draw the current health level based on the current Health Color healthColor = Color.Gold; if (healthiness < 0.2) healthColor = Color.DarkRed; else if (healthiness < 0.5) healthColor = Color.Red; else if (healthiness < 0.8) healthColor = Color.LawnGreen; spriteBatch.Draw(EnvironmentBar, new Vector2(barX, barY + (EnvironmentBar.Height - (int)(EnvironmentBar.Height * healthiness)) * textScaleFactor), new Rectangle(45, EnvironmentBar.Height - (int)(EnvironmentBar.Height * healthiness), 43, (int)(EnvironmentBar.Height * healthiness)), healthColor, 0, Vector2.Zero, textScaleFactor, SpriteEffects.None, 0); //Draw the box around the health bar spriteBatch.Draw(EnvironmentBar, new Vector2(barX, barY), new Rectangle(0, 0, 41, EnvironmentBar.Height), Color.White, 0, Vector2.Zero, textScaleFactor, SpriteEffects.None, 0); //spriteBatch.DrawString(statsFont, type.ToUpper(), new Vector2(game.Window.ClientBounds.Width / 2 - ((type.Length / 2) * 14), heightFromTop - 1), typeColor); //spriteBatch.DrawString(statsFont, type.ToUpper(), new Vector2(barX + 10, barY + 20), typeColor, 90.0f, new Vector2(barX + 10, barY + 20), 1, SpriteEffects.FlipVertically, 0); type = type.ToUpper(); //spriteBatch.DrawString(statsFont, type.ToUpper(), new Vector2(barX + 35, barY + 70), typeColor, 3.14f / 2, new Vector2(0, 0), 1, SpriteEffects.None, 0); spriteBatch.DrawString(statsFont, type, new Vector2(barX + barWidth / 2, game.Window.ClientBounds.Height / 2), Color.Gold, 3.14f / 2, new Vector2(statsFont.MeasureString(type).X / 2, statsFont.MeasureString(type).Y / 2), textScaleFactor, SpriteEffects.None, 0); //draw the lobster on bottom //spriteBatch.Draw(lobsterTexture, new Vector2(barX + barWidth / 2, game.Window.ClientBounds.Height / 2 + EnvironmentBar.Height / 2 - 30), null, Color.White, 0, new Vector2(lobsterTexture.Width / 2, lobsterTexture.Height / 2), 1, SpriteEffects.None, 0); //draw floating bubbles inside tube if (PoseidonGame.playTime.TotalMilliseconds - lastBubbleCreated >= 250) { Bubble bubble = new Bubble(); bubble.LoadContentBubbleSmall(PoseidonGame.contentManager, new Vector2(barX + barWidth / 2, barY + (EnvironmentBar.Height) * textScaleFactor - 8), barX, barX + barWidth - 3); bubbles.Add(bubble); lastBubbleCreated = PoseidonGame.playTime.TotalMilliseconds; } for (int i = 0; i < bubbles.Count; i++) { if (bubbles[i].bubble2DPos.Y - bubbles[i].bubbleTexture.Height/2 * bubbles[i].startingScale <= barY + (EnvironmentBar.Height - (int)(EnvironmentBar.Height * healthiness)) * textScaleFactor || bubbles[i].bubble2DPos.Y - bubbles[i].bubbleTexture.Height/2 * bubbles[i].startingScale <= barY + 4) bubbles.RemoveAt(i--); } foreach (Bubble aBubble in bubbles) { aBubble.UpdateBubbleSmall(); aBubble.DrawBubbleSmall(spriteBatch); } }
//泡泡吸附泡泡 public void Absorb(Bubble bubble, Slot slot) { Vector2 pos = SlotContain.InverseTransformPoint(bubble.mTran.position); float DistanceMin = 1000; Vector2 location = slot.Location; bool even = slot.Row % 2 == 0; Slot targetSlot = null; //搜索邻近槽位 for (int i = 0, len = Directs.Length; i < len; i++) { Direct dir = Directs[i]; Slot temp = FindSideBubble(location, dir, even); if (temp != null && temp.Bubble == null) { float dis = Vector2.Distance(pos, temp.Position); //距离最短 if (dis < DistanceMin) { DistanceMin = dis; targetSlot = temp; } } } //泡泡嵌入槽内 bubble.mTran.parent = SlotContain; bubble.AbsorbAction(targetSlot); //震动传播 SpreadShake(bubble, targetSlot); }
//泡泡吸附顶部 public void AbsorbTop(Bubble bubble) { Vector2 pos = SlotContain.InverseTransformPoint(bubble.mTran.position); float DistanceMin = 1000; Slot targetSlot = null; //搜索顶部泡泡 Slot[] tops = Tables[0]; for (int i = 0, len = tops.Length; i < len; i++) { Slot slot = tops[i]; if (slot.Bubble == null) { float dis = Vector2.Distance(pos, slot.Position); if (dis < DistanceMin) { DistanceMin = dis; targetSlot = slot; } } } //泡泡嵌入槽内 bubble.mTran.parent = SlotContain; bubble.AbsorbAction(targetSlot); //震动传播 SpreadShake(bubble, targetSlot); }
public void setBubble(Bubble bubble) { this.bubble = bubble; }
private void MarkBubbles(Bubble Bubble, int column, int row, string colorToCompare) { if (Bubble != null) { if (Bubble.GameObject.tag == colorToCompare) { if (SelectedBubbles.Contains(Bubble)) return; //we're not checking the same Bubble twice, this will incur a stack overflow Bubble.GameObject.transform.GetComponent<Renderer>().material = selectedBubbleColor; SelectedBubbles.Add(Bubble); //check bottom if (row > 0) MarkBubbles(BubblesArray[column, row - 1], column, row - 1, colorToCompare); if (column > 0) //check left MarkBubbles(BubblesArray[column - 1, row], column - 1, row, colorToCompare); if (column < BubbleColumns - 1) //check right MarkBubbles(BubblesArray[column + 1, row], column + 1, row, colorToCompare); if (row < BubbleRows - 1) //check top MarkBubbles(BubblesArray[column, row + 1], column, row + 1, colorToCompare); } else return; } }
void Start() { _instance = this; }
public void setPositionI(int tileI){ this.tileI = tileI; transform.localPosition = Global.TilesOrigin + new Vector3(tileI*Global.TileWidth,tileJ*Global.TileHeight,10); state = LevelBuilder.getState(tileI,tileJ); stopBlinking(); if (LevelBuilder.getBubbleModel(tileI,tileJ).bubbleType != Bubble.Type.None){ currentBubble = Global.bubblesPool.addBubbleToScene(LevelBuilder.getBubbleModel(tileI,tileJ)); } else { currentBubble = null; int fillProbability = (int)(1.0f*fillNeutralProbabilityLeft * (Global.maxTileI-tileI)/Global.maxTileI + 1.0f*fillNeutralProbabilityRight * (tileI)/Global.maxTileI); int skipProbability = (int)(1.0f*skipColoredProbabilityLeft * (Global.maxTileI-tileI)/Global.maxTileI + 1.0f*skipColoredProbabilityRight * (tileI)/Global.maxTileI); if (state == Tile.State.Neutral){ if (Random.Range(0,100) < fillProbability){ if (Random.Range(0,3) == 0) state = Tile.State.Red; else if (Random.Range(0,2) == 0) state = Tile.State.Green; else state = Tile.State.Blue; } } else { if (Random.Range(0,100) < skipProbability) state = Tile.State.Neutral; } } if ((tileI < 3 && tileJ < 3) || (tileI > Global.maxTileI-2 && tileJ < 3)) state = State.Neutral; if (state == State.Neutral) currentTexture = grayTexture; else if (state == State.Red) currentTexture = redTexture; else if (state == State.Green) currentTexture = greenTexture; else if (state == State.Blue) currentTexture = blueTexture; renderer.material.mainTexture = currentTexture; }
private void Start() { _bubble = GetComponent<Bubble>(); _car = GetComponent<Car>(); }
//断开坠落 public void ToFall() { Bubble.ToFall(); Bubble = null; }
//连锁消除 public void ToChain() { Bubble.ToChain(); Bubble = null; }
private void Start() { _bubble = GetComponent<Bubble>(); _objectsToIgnoreTemp = new List<Crash>(); _cooldownCollision = new Cooldown(); init = true; }
//泡泡震动动画 public void ShakeAction(Bubble bubble) { StartCoroutine(Shake(bubble)); }
ProductTour BuildProductTourView(UITableView tableView) { var productTour = new ProductTour (); productTour.Frame = new RectangleF (0, 0, 320, tableView.Frame.Height); var bubble = new Bubble (new UIView (new RectangleF (0, 0, 320, 0)), "SCHEDULE MEMEMORIZATION", "Tap the verses you wish to memorize,\nthen tap the\"Move\" button and a day\nto schedule memorization.", ArrowPosition.Top, null); bubble.FontName = "SourceSansPro-Bold"; var bubbleArray = new NSMutableArray (1); bubbleArray.Add (bubble); productTour.Bubbles = bubbleArray; return productTour; }
void SetupTour() { var tour = Tour.Instance; if (tour.IsEnabled) { productTour = new ProductTour (); productTour.Frame = new RectangleF (0, 0, View.Bounds.Width, View.Bounds.Height); var step = tour.Step; if (step == 1) { var view = new UIView (new RectangleF(backingComposeButton.Frame.X, backingComposeButton.Frame.Y - 44, backingComposeButton.Frame.Width, backingComposeButton.Frame.Height)); var bubble = new Bubble (view, "DOWNLOAD", "Add a new verse\nto your library.", ArrowPosition.Top, null); bubble.FontName = "SourceSansPro-Bold"; var bubbles = new NSMutableArray (1); bubbles.Add (bubble); productTour.Bubbles = bubbles; Add (productTour); } else if (step == 2) { var view = new UIView (ViewForTab (1)); var bubble = new Bubble (view, "SWITCH TABS", "Tap the memorization tab.", ArrowPosition.Bottom, null); bubble.FontName = "SourceSansPro-Bold"; var bubbles = new NSMutableArray (1); bubbles.Add (bubble); productTour.Bubbles = bubbles; Add (productTour); } } }
private void omnomnom(Bubble bubbleOther, bool forceAbsorbation) { if (forceAbsorbation || bubbleOther.GetRadius(true) < _bubble.GetRadius(true)) { float radius = bubbleOther.GetRadiusTarget(); if (radius <= absorbationStep) { _bubble.ChangeRadius(radius); Destroy(bubbleOther.gameObject); } else { bubbleOther.ChangeRadius(-absorbationStep); float delta = radius - bubbleOther.GetRadiusTarget(); if (delta < absorbationStep) { _bubble.ChangeRadius(radius); Destroy(bubbleOther.gameObject); } else { _bubble.ChangeRadius(absorbationStep); } } } }
//震动传播 void SpreadShake(Bubble bubble, Slot slot) { Vector2 point = bubble.mTran.localPosition; Vector2 location = slot.Location; bool even = slot.Row % 2 == 0; for (int i = 0, len = Directs.Length; i < len; i++) { Direct dir = Directs[i]; Slot temp = FindSideBubble(location, dir, even); if (temp != null && temp.Bubble != null && !temp.Bubble.isShake) { float dis = Vector2.Distance(point, temp.Position); //距离限制 if (dis < SpreadRange) { temp.Bubble.ShakeAction(bubble); SpreadShake(bubble, temp); } } } }