public BubbleModel CreateEasy() { BubbleModel bubbleModel = new BubbleModel(); BoxModel boxModel = new BoxModel() { layout = FlexLayout.vertical }; List <FlexComponentModel> boxModelContentsList = new List <FlexComponentModel>(); TextModel textModel1 = new TextModel() { text = "hello" }; TextModel textModel2 = new TextModel() { text = "world" }; boxModelContentsList.Add(textModel1); boxModelContentsList.Add(textModel2); boxModel.contents = boxModelContentsList; bubbleModel.body = boxModel; return(bubbleModel); }
public List <BubbleModel> GetBubbleData(Earthquake centralPoint, List <Earthquake> eqList) { List <BubbleModel> result = new List <BubbleModel>(); //FitPolynomial(eqList, 3); foreach (Earthquake eq in eqList) { BubbleModel bubble = new BubbleModel(); bubble.x = (double)(eq.Latitude - centralPoint.Latitude); if (bubble.x > 90) { bubble.x -= 90; } else if (bubble.x < -90) { bubble.x += 90; } bubble.y = (double)(eq.Longitude - centralPoint.Longitude); if (bubble.y > 180) { bubble.y -= 180; } else if (bubble.y < -180) { bubble.y += 180; } bubble.r = GetBubbleRadius(eq.Magnitude); result.Add(bubble); } return(result); }
public void ExplodeBubble(BubbleModel bubbleModel) { bubbleModel.m_bubbleRefs.m_bubbleTransform.DOKill(); bubbleModel.m_bubbleRefs.m_bubbleBg.transform.DOScale(0, 1.2f).SetEase(Ease.Linear); bubbleModel.m_bubbleRefs.m_destroyParticles.startColor = bubbleModel.m_bubbleColor; bubbleModel.m_bubbleRefs.m_destroyParticles.Play(); }
public void addToScene(BubbleModel model){ mountedTile = Global.tilesPool.getTile(model.tileI, model.tileJ); renderer.enabled = true; bubbleOffset = baseBubbleOffset; this.setIdle(); this.model = model; }
private void UpdateNextShootBubble() { m_currentBubbleToShoot = m_nextBubbleToShoot; m_currentBubbleToShoot.m_position = m_bubbleRefs.m_currentBubblePosition.localPosition; GameplayData.g_currentBubbleColor = m_currentBubbleToShoot.m_bubbleColor; m_bubbleViewController.SetCurrentBubble(m_currentBubbleToShoot); SpawnNextBubble(); EventManager.DoFireMergeCompleteEvent(); }
private void AddToInactiveBubbleList(BubbleModel bubbleModel) { if (m_inactiveBubblesList.Contains(bubbleModel)) { return; } ResetBubble(bubbleModel); m_inactiveBubblesList.Add(bubbleModel); }
public void ShowMergedValue(BubbleModel bubbleModel) { Color tempColor = bubbleModel.m_bubbleRefs.m_mergeText.color; tempColor.a = 1; bubbleModel.m_bubbleRefs.m_mergeText.color = tempColor; bubbleModel.m_bubbleRefs.m_mergeText.transform.localPosition = Vector3.zero; bubbleModel.m_bubbleRefs.m_bubbleTransform.SetAsLastSibling(); DOTween.Sequence().Insert(0.05f, bubbleModel.m_bubbleRefs.m_mergeText.transform.DOLocalMoveY(80, 0.7f).SetEase(Ease.Linear)) .Insert(0.6f, bubbleModel.m_bubbleRefs.m_mergeText.DOFade(0, 0.2f).SetEase(Ease.Linear)); }
private void SpawnNextBubble() { BubbleModel bubbleModel = GetBubbleModel(); bubbleModel.m_value = GetBubbleValue(); bubbleModel.m_bubbleColor = GetBubbleColor(bubbleModel.m_value); bubbleModel.m_position = m_bubbleRefs.m_nextBubblePosition.localPosition; bubbleModel.m_bubbleRefs.m_circleCollider.enabled = false; m_nextBubbleToShoot = bubbleModel; m_bubbleViewController.SpawnBubble(m_nextBubbleToShoot, 0.75f); }
private BubbleModel GetBubbleModel() { if (m_inactiveBubblesList.Count == 0) { PoolBubbles(1); } BubbleModel bubbleModel = m_inactiveBubblesList[0]; m_inactiveBubblesList.RemoveAt(0); ResetBubble(bubbleModel); return(bubbleModel); }
private void PoolBubbles(int poolSize) { GameObject loadedBubbleInMemory = Object.Instantiate(m_bubbleRefs.m_bubblePrefab, m_bubbleRefs.m_bubbleContainer); for (int index = 0; index < poolSize; index++) { GameObject bubble = Object.Instantiate(loadedBubbleInMemory, m_bubbleRefs.m_bubbleContainer); BubbleRefs bubbleRefs = bubble.GetComponent <BubbleRefs>(); BubbleModel bubbleModel = new BubbleModel(); bubbleModel.m_bubbleRefs = bubbleRefs; m_inactiveBubblesList.Add(bubbleModel); } }
private void SortBubblesList(List <BubbleModel> bubblesToMerge) { for (int i = 0; i <= bubblesToMerge.Count - 2; i++) { for (int j = 0; j <= bubblesToMerge.Count - 2; j++) { if (bubblesToMerge[j].m_gridIndex > bubblesToMerge[j + 1].m_gridIndex) { BubbleModel temp = bubblesToMerge[j + 1]; bubblesToMerge[j + 1] = bubblesToMerge[j]; bubblesToMerge[j] = temp; } } } }
private void SpawnCurrentBubble() { BubbleModel bubbleModel = GetBubbleModel(); bubbleModel.m_value = GetBubbleValue(); bubbleModel.m_bubbleColor = GetBubbleColor(bubbleModel.m_value); bubbleModel.m_position = m_bubbleRefs.m_currentBubblePosition.localPosition; bubbleModel.m_bubbleRefs.m_circleCollider.enabled = false; m_currentBubbleToShoot = bubbleModel; m_bubbleViewController.SpawnBubble(m_currentBubbleToShoot); GameplayData.g_currentBubbleColor = m_currentBubbleToShoot.m_bubbleColor; }
public void SpawnBubble(BubbleModel model, float scaleValue = 1, bool isInitialSpawning = false) { model.m_bubbleRefs.m_bubbleTransform.localPosition = model.m_position; model.m_bubbleRefs.m_valueText.text = model.m_value.ToString(); model.m_bubbleRefs.m_bubbleBg.color = model.m_bubbleColor; if (isInitialSpawning) { DOTween.Sequence().Insert(Random.Range(0, 0.1f), model.m_bubbleRefs.m_bubbleTransform.DOScale(scaleValue, 0.3f).SetEase(Ease.Linear)); } else { model.m_bubbleRefs.m_bubbleTransform.DOKill(); model.m_bubbleRefs.m_bubbleTransform.DOScale(scaleValue, 0.3f).SetEase(Ease.Linear); } }
private void ResetBubble(BubbleModel bubbleModel) { bubbleModel.m_bubbleRefs.m_rigidbody.gravityScale = 0; bubbleModel.m_bubbleRefs.m_rigidbody.velocity = Vector2.zero; bubbleModel.m_bubbleRefs.m_bubbleTransform.localScale = Vector3.zero; bubbleModel.m_bubbleRefs.m_bubbleTransform.localPosition = Vector3.zero; Color tempColor = Color.white; tempColor.a = 1; bubbleModel.m_bubbleRefs.m_bubbleBg.color = tempColor; bubbleModel.m_bubbleRefs.m_valueText.color = tempColor; bubbleModel.m_bubbleRefs.m_bubbleBg.transform.localScale = Vector3.one * 0.6f; }
private void MergeBubble() { List <BubbleModel> bubblesToMerge = new List <BubbleModel>(); m_bubblesToMerge.Clear(); bubblesToMerge.Add(m_currentBubbleToShoot); PerformMerge(bubblesToMerge, m_currentBubbleToShoot.m_gridIndex, m_currentBubbleToShoot.m_value); if (bubblesToMerge.Count == 1) { m_activeBubblesDict.Add(m_currentBubbleToShoot.m_gridIndex, m_currentBubbleToShoot); UpdateStateToShootAgain(); } else { int mergeValue = GetMergeValue(bubblesToMerge.Count, m_currentBubbleToShoot.m_value); mergeValue = Mathf.Clamp(mergeValue, 2, GameConstants.g_bubbleBlastValue); m_isBubbleReachMax = mergeValue >= GameConstants.g_bubbleBlastValue; SortBubblesList(bubblesToMerge); int mergePoint = m_isBubbleReachMax ? 0 : GetNextMergeIndex(bubblesToMerge, mergeValue); m_currentBubbleToShoot = bubblesToMerge[mergePoint]; m_currentBubbleToShoot.m_value = mergeValue; m_currentBubbleToShoot.m_bubbleColor = GetBubbleColor(mergeValue); if (m_activeBubblesDict.Count == 0) { m_bubbleViewController.BubbleDrop(m_currentBubbleToShoot); } m_bubbleViewController.MoveBubbleToMerge(bubblesToMerge, mergePoint, MergeComplete); DropDisconnectedBubbles(); m_bubblesToMerge.AddRange(bubblesToMerge); Vibration.Vibrate(TapticPlugin.ImpactFeedback.Heavy); } }
public ActionResult <List <BubbleModel> > GetBubbleData() { BubbleModel data1 = new BubbleModel { Count = new Count { X = 20, Y = 30, R = 10 }, Month = "January" }; BubbleModel data2 = new BubbleModel { Count = new Count { X = 20, Y = 20, R = 2 }, Month = "January" }; BubbleModel data3 = new BubbleModel { Count = new Count { X = 0, Y = 0, R = 20 }, Month = "January" }; List <BubbleModel> charts = new List <BubbleModel> { data1, data2, data3 }; return(charts); }
private void SpawnBubble(int index, bool isInitialSpawning = false) { BubbleModel bubbleModel = GetBubbleModel(); bubbleModel.m_gridIndex = index; bubbleModel.m_value = GetBubbleValue(); bubbleModel.m_bubbleColor = GetBubbleColor(bubbleModel.m_value); int currentRow = index / GameConstants.g_maxColumns; int currentColumn = index % GameConstants.g_maxColumns; float xPos = currentColumn * GameConstants.g_xSpawnDelta; float yPos = currentRow * -GameConstants.g_ySpawnDelta; bool isRowWithOffset = m_isFirstRowWithOffset ? currentRow % 2 == 0 : currentRow % 2 == 1; xPos = isRowWithOffset ? xPos - GameConstants.g_spawnDeltaOffset : xPos; bubbleModel.m_position = new Vector2(xPos, yPos); m_activeBubblesDict.Add(index, bubbleModel); m_bubbleViewController.SpawnBubble(bubbleModel, 1, isInitialSpawning); }
public CarouselModel Create() { #region carousel CarouselModel carouselModel = new CarouselModel(); List <BubbleModel> carouselContentList = new List <BubbleModel>(); for (int i = 0; i <= 3; i++) { #region body_bubble_1 BubbleModel bubbleModel = new BubbleModel(); #region box_1 //box BoxModel mainBoxModel = new BoxModel() { layout = FlexLayout.vertical }; List <FlexComponentModel> mainboxModelList = new List <FlexComponentModel>(); #region box_1_content_1 //text TextModel contentModel1 = new TextModel() { text = "abc", color = "#ffffff", size = FlexFontSize.sm }; mainboxModelList.Add(contentModel1); #endregion #region box_1_content_2 //text 課程標題 TextModel contentModel2 = new TextModel() { text = "課程標題", size = FlexFontSize.xxl, weight = TextWeight.regular, margin = FlexMarginSize.md, wrap = true }; mainboxModelList.Add(contentModel2); #endregion #region box_1_content_3 //text TextModel contentModel3 = new TextModel() { text = "老師", size = FlexFontSize.sm, }; mainboxModelList.Add(contentModel3); #endregion #region box_1_content_4 //text 課程副標題 TextModel contentModel4 = new TextModel() { text = "課程副標題", size = FlexFontSize.sm, color = "#aaaaaa", wrap = true, offsetTop = "5px" }; mainboxModelList.Add(contentModel4); #endregion #region box_1_content_5 //box BoxModel contentModel5 = new BoxModel() { layout = FlexLayout.baseline, margin = FlexMarginSize.xl, spacing = FlexMarginSize.xxl }; List <FlexComponentModel> contentModel5List = new List <FlexComponentModel>(); #region box_1_content_5_content_1 //text 原價 TextModel contentModel5To1 = new TextModel() { text = "NT$ 1000", size = FlexFontSize.sm, flex = 0, decoration = TextDecoration.line_through, gravity = FlexGravity.top, offsetTop = "-2px" }; contentModel5List.Add(contentModel5To1); #endregion #region box_1_content_5_content_2 //text 特價 TextModel contentModel5To2 = new TextModel() { text = "NT$ 800", size = FlexFontSize.lg, color = "#ff0000", flex = 0, gravity = FlexGravity.bottom }; contentModel5List.Add(contentModel5To2); #endregion contentModel5.contents = contentModel5List; mainboxModelList.Add(contentModel5); #endregion #region box_1_content_6 //box BoxModel contentModel6 = new BoxModel() { layout = FlexLayout.baseline, spacing = FlexMarginSize.md, paddingTop = "10px" }; List <FlexComponentModel> contentModel6List = new List <FlexComponentModel>(); #region box_1_content_6_content_1 //text 課程開始日期 TextModel contentModel6To1 = new TextModel() { text = "課程開始日期:", flex = 0 }; contentModel6List.Add(contentModel6To1); #endregion #region box_1_content_6_content_2 //text 課程開始日期 TextModel contentModel6To2 = new TextModel() { text = "2018/9/22", flex = 0, offsetTop = "1px" }; contentModel6List.Add(contentModel6To2); #endregion contentModel6.contents = contentModel6List; mainboxModelList.Add(contentModel6); #endregion #region box_1_content_7 //box BoxModel contentModel7 = new BoxModel() { layout = FlexLayout.baseline, spacing = FlexMarginSize.md }; List <FlexComponentModel> contentModel7List = new List <FlexComponentModel>(); #region box_1_content_7_content_1 //text 課程結束日期 TextModel contentModel7To1 = new TextModel() { text = "課程結束日期:", flex = 0 }; contentModel7List.Add(contentModel7To1); #endregion #region box_1_content_7_content_2 //text 課程結束日期 TextModel contentModel7To2 = new TextModel() { text = "2019/12/13", flex = 0, offsetTop = "1px" }; contentModel7List.Add(contentModel7To2); #endregion contentModel7.contents = contentModel7List; mainboxModelList.Add(contentModel7); #endregion #region box_1_content_8 //box BoxModel contentModel8 = new BoxModel() { layout = FlexLayout.baseline, spacing = FlexMarginSize.md }; List <FlexComponentModel> contentModel8List = new List <FlexComponentModel>(); #region box_1_content_8_content_1 //text 上課時段 TextModel contentModel8To1 = new TextModel() { text = "上課時段:", flex = 0 }; contentModel8List.Add(contentModel8To1); #endregion #region box_1_content_8_content_2 //text 上課時段 TextModel contentModel8To2 = new TextModel() { text = "六 09:00~16:00", flex = 0, wrap = true, maxLines = 3 }; contentModel8List.Add(contentModel8To2); #endregion contentModel8.contents = contentModel8List; mainboxModelList.Add(contentModel8); #endregion #region box_1_content_9 //box BoxModel contentModel9 = new BoxModel() { layout = FlexLayout.baseline, spacing = FlexMarginSize.md }; List <FlexComponentModel> contentModel9List = new List <FlexComponentModel>(); #region box_1_content_9_content_1 //text 地點 TextModel contentModel9To1 = new TextModel() { text = "地點:", flex = 0 }; contentModel9List.Add(contentModel9To1); #endregion #region box_1_content_9_content_2 //text 地點 TextModel contentModel9To2 = new TextModel() { text = "台北市OO路OO號台北市OO路OO號台北市OO路OO號", flex = 0, wrap = true, maxLines = 3 }; contentModel9List.Add(contentModel9To2); #endregion contentModel9.contents = contentModel9List; mainboxModelList.Add(contentModel9); #endregion #region box_1_content_10 //box BoxModel contentModel10 = new BoxModel() { layout = FlexLayout.vertical, position = FlexPosition.absolute, width = "53px", height = "25px", backgroundColor = "#ff334b", cornerRadius = "20px", offsetTop = "18px", offsetStart = "18px" }; List <FlexComponentModel> contentModel10List = new List <FlexComponentModel>(); #region box_1_content_10_content_1 //text TextModel contentModel10To1 = new TextModel() { text = "SALE", size = FlexFontSize.xs, color = "#ffffff", align = FlexAlign.center, offsetTop = "5px" }; contentModel10List.Add(contentModel10To1); #endregion contentModel10.contents = contentModel10List; mainboxModelList.Add(contentModel10); #endregion #endregion mainBoxModel.contents = mainboxModelList; #endregion bubbleModel.body = mainBoxModel; #region footer #region footer_box_1 //box BoxModel footerContent1 = new BoxModel() { layout = FlexLayout.vertical, flex = 0, spacing = FlexMarginSize.sm }; List <FlexComponentModel> footerContent1List = new List <FlexComponentModel>(); #region footer_box_1_content_1 //button 更多資訊 URIActionModel footerContent1To1Action1 = new URIActionModel() { label = "更多資訊", uri = "https://www.example.com" }; ButtonModel footerContent1To1 = new ButtonModel() { action = footerContent1To1Action1, height = ButtonHeight.sm }; footerContent1List.Add(footerContent1To1); #endregion #region footer_box_1_content_2 //button 購買 URIActionModel footerContent1To2Action1 = new URIActionModel() { label = "購買", uri = "https://www.example.com" }; ButtonModel footerContent1To2 = new ButtonModel() { action = footerContent1To2Action1, height = ButtonHeight.sm }; footerContent1List.Add(footerContent1To2); #endregion footerContent1.contents = footerContent1List; bubbleModel.footer = footerContent1; #endregion #endregion #endregion carouselContentList.Add(bubbleModel); } carouselModel.contents = carouselContentList; return(carouselModel); }
public CarouselModel Create() { #region carousel CarouselModel carouselModel = new CarouselModel(); List <BubbleModel> carouselContentList = new List <BubbleModel>(); #region body_bubble_1 BubbleModel bubbleModel = new BubbleModel(); #region box_1 BoxModel mainBoxModel = new BoxModel() { layout = FlexLayout.vertical, paddingAll = "0px" }; List <FlexComponentModel> mainboxModelList = new List <FlexComponentModel>(); #region box_1_content_1 ImageModel contentModel1 = new ImageModel() { url = "https://scdn.line-apps.com/n/channel_devcenter/img/flexsnapshot/clip/clip1.jpg", size = ImageSize.full, aspectMode = ImageAspectMode.cover, aspectRatio = ImageAspectRatio.R2To3, gravity = FlexGravity.top }; mainboxModelList.Add(contentModel1); #endregion #region box_1_content_2 BoxModel contentModel2 = new BoxModel() { layout = FlexLayout.vertical, spacing = FlexMarginSize.lg, position = FlexPosition.absolute, backgroundColor = "#03303Acc", paddingAll = "20px", paddingTop = "18px", offsetBottom = "0px", offsetStart = "0px", offsetEnd = "0px" }; List <FlexComponentModel> contentModel2List = new List <FlexComponentModel>(); #region box_1_content_2_content_1 BoxModel contentModel2To1 = new BoxModel(); contentModel2To1.layout = FlexLayout.vertical; List <FlexComponentModel> contentModel2To1List = new List <FlexComponentModel>(); #region box_1_content_2_content_1_content1 TextModel contentModel2To1To1 = new TextModel() { text = "Brown's T-shirts", size = FlexFontSize.xl, color = "#ffffff", weight = TextWeight.bold }; contentModel2To1List.Add(contentModel2To1To1); #endregion #endregion contentModel2To1.contents = contentModel2To1List; contentModel2List.Add(contentModel2To1); #region box_1_content_2_content_2 BoxModel contentModel2To2 = new BoxModel() { layout = FlexLayout.baseline, spacing = FlexMarginSize.lg, }; List <FlexComponentModel> contentModel2To2List = new List <FlexComponentModel>(); #region box_1_content_2_content_2_content1 TextModel contentModel2To2To1 = new TextModel() { text = "¥35,800", color = "#ebebeb", size = FlexFontSize.sm, flex = 0 }; contentModel2To2List.Add(contentModel2To2To1); #endregion #region box_1_content_2_content_2_content2 TextModel contentModel2To2To2 = new TextModel() { text = "¥75,000", color = "#ffffffcc", decoration = TextDecoration.line_through, gravity = FlexGravity.bottom, flex = 0, size = FlexFontSize.sm }; contentModel2To2List.Add(contentModel2To2To2); #endregion #endregion contentModel2To2.contents = contentModel2To2List; contentModel2List.Add(contentModel2To2); #region box_1_content_2_content_3 BoxModel contentModel2To3 = new BoxModel() { layout = FlexLayout.vertical, borderWidth = "1px", cornerRadius = "4px", spacing = FlexMarginSize.sm, borderColor = "#ffffff", margin = FlexMarginSize.xxl, height = "40px" }; List <FlexComponentModel> contentModel2To3List = new List <FlexComponentModel>(); #region box_1_content_2_content_3_content_1 FillerModel contentModel2To3To1 = new FillerModel(); contentModel2To3List.Add(contentModel2To3To1); #endregion #region box_1_content_2_content_3_content_2 BoxModel contentModel2To3To2 = new BoxModel() { layout = FlexLayout.baseline, spacing = FlexMarginSize.sm }; List <FlexComponentModel> contentModel2To3To2List = new List <FlexComponentModel>(); #region box_1_content_2_content_3_content_2_content1 FillerModel contentModel2To3To2To1 = new FillerModel(); contentModel2To3To2List.Add(contentModel2To3To2To1); #endregion #region box_1_content_2_content_3_content_2_content2 IconModel contentModel2To3To2To2 = new IconModel() { url = "https://scdn.line-apps.com/n/channel_devcenter/img/flexsnapshot/clip/clip14.png" }; contentModel2To3To2List.Add(contentModel2To3To2To2); #endregion #region box_1_content_2_content_3_content_2_content3 TextModel contentModel2To3To2To3 = new TextModel() { text = "Add to cart", color = "#ffffff", flex = 0, offsetTop = "-2px" }; contentModel2To3To2List.Add(contentModel2To3To2To3); #endregion #region box_1_content_2_content_3_content_2_content4 FillerModel contentModel2To3To2To4 = new FillerModel(); contentModel2To3To2List.Add(contentModel2To3To2To4); #endregion #endregion contentModel2To3To2.contents = contentModel2To3To2List; contentModel2To3List.Add(contentModel2To3To2); #region box_1_content_2_content_3_content_3 FillerModel contentModel2To3To3 = new FillerModel(); contentModel2To3List.Add(contentModel2To3To3); #endregion #endregion contentModel2To3.contents = contentModel2To3List; contentModel2List.Add(contentModel2To3); #endregion contentModel2.contents = contentModel2List; mainboxModelList.Add(contentModel2); #region box_1_content_3 BoxModel contentModel3 = new BoxModel() { layout = FlexLayout.vertical, position = FlexPosition.absolute, cornerRadius = "20px", offsetTop = "18px", backgroundColor = "#ff334b", offsetStart = "18px", height = "25px", width = "52px" }; List <FlexComponentModel> contentModel3List = new List <FlexComponentModel>(); #region box_1_content_3_content1 TextModel contentModel3To1 = new TextModel() { text = "SALE", color = "#ffffff", align = FlexAlign.center, size = FlexFontSize.xs, offsetTop = "3px" }; contentModel3List.Add(contentModel3To1); #endregion #endregion contentModel3.contents = contentModel3List; mainboxModelList.Add(contentModel3); #endregion mainBoxModel.contents = mainboxModelList; #endregion bubbleModel.body = mainBoxModel; carouselContentList.Add(bubbleModel); #endregion carouselModel.contents = carouselContentList; return(carouselModel); }
public void SetCurrentBubble(BubbleModel model) { model.m_bubbleRefs.m_bubbleTransform.DOKill(); model.m_bubbleRefs.m_bubbleTransform.DOLocalMove(model.m_position, 0.2f).SetEase(Ease.Linear); model.m_bubbleRefs.m_bubbleTransform.DOScale(1, 0.2f).SetEase(Ease.Linear); }
// Use this for initialization void Start (){ model = new BubbleModel(-1,0); bubbleOffset = baseBubbleOffset; renderer.enabled = true; mountedTile = null; }
public void BubbleDrop(BubbleModel bubbleModel) { bubbleModel.m_bubbleRefs.m_bubbleBg.transform.localScale = Vector3.zero; bubbleModel.m_bubbleRefs.m_destroyParticles.startColor = bubbleModel.m_bubbleColor; bubbleModel.m_bubbleRefs.m_destroyParticles.Play(); }
public Bubble addBubbleToScene(BubbleModel model){ Bubble bubble = getNextBubble(); bubble.addToScene(model); return bubble; }
public static void buildLevel(bool startFromLeft){ states = new Tile.State[Global.maxTileI+1,Global.maxTileJ+1]; bubbles = new BubbleModel[Global.maxTileI+1,Global.maxTileJ+1]; rotations = new Quaternion[Global.maxTileI+1,Global.maxTileJ+1]; for (int i=0; i<=Global.maxTileI; i++) for (int j=0; j<=Global.maxTileJ; j++){ states[i,j] = Tile.State.Neutral; bubbles[i,j] = new BubbleModel(i,j); rotations[i,j] = Quaternion.identity; } int currentTileI = 0; if (!startFromLeft) currentTileI = Global.maxTileI; int currentTileJ = 0; Global.rotatingCube.initParams(); Global.Direction lastDirection = Global.Direction.Left; bool shouldAvoidLastDirection = false; int shouldAvoidLastDirectionCounter = 0; BubbleModel currentBubble = null; while ((currentTileI < Global.maxTileI && startFromLeft) || (currentTileI > 0 && !startFromLeft)){ int probBubble = (int)(1.0f*bubbleProbLeft * (Global.maxTileI-currentTileI)/Global.maxTileI + 1.0f*bubbleProbRight * (currentTileI)/Global.maxTileI); if (shouldAvoidLastDirection){ if (shouldAvoidLastDirectionCounter++ > 20) shouldAvoidLastDirection = false; } else if (currentTileI > 2 && currentTileI < Global.maxTileI-2 && Random.Range(0,100) < probBubble){ currentBubble = bubbles[currentTileI, currentTileJ]; if (Random.Range(0,3) == 0) currentBubble.bubbleType = Bubble.Type.Red; else if (Random.Range(0,2) == 0) currentBubble.bubbleType = Bubble.Type.Green; else currentBubble.bubbleType = Bubble.Type.Blue; shouldAvoidLastDirection = true; shouldAvoidLastDirectionCounter = 0; rotations[currentTileI, currentTileJ] = Global.rotatingCube.transform.localRotation; states[currentTileI, currentTileJ] = Tile.State.Neutral; } if (Random.Range(0,2) == 0){ if (startFromLeft){ currentTileI++; Global.rotatingCube.quickMove(Global.Direction.Right); lastDirection = Global.Direction.Right; } else { currentTileI--; Global.rotatingCube.quickMove(Global.Direction.Left); lastDirection = Global.Direction.Left; } } else { if (currentTileJ > 0 && Random.Range(0,2) == 0 && (!shouldAvoidLastDirection || lastDirection != Global.Direction.Up)){ currentTileJ--; Global.rotatingCube.quickMove(Global.Direction.Down); lastDirection = Global.Direction.Down; } else if (currentTileJ < Global.maxTileJ && (!shouldAvoidLastDirection || lastDirection != Global.Direction.Down)){ currentTileJ++; Global.rotatingCube.quickMove(Global.Direction.Up); lastDirection = Global.Direction.Up; } else{ if (startFromLeft){ currentTileI++; Global.rotatingCube.quickMove(Global.Direction.Right); lastDirection = Global.Direction.Right; } else{ currentTileI--; Global.rotatingCube.quickMove(Global.Direction.Left); lastDirection = Global.Direction.Left; } } } states[currentTileI,currentTileJ] = Global.rotatingCube.getState(); if (shouldAvoidLastDirection && currentBubble != null){ currentBubble.addBlinkingTile(currentTileI,currentTileJ); } } Global.rotatingCube.initParams(); }