private void FormatBubble(int totalLines, int textLength, int offsetX, int offsetY) { if (m_bubbleType.Equals(BubbleType.ChatBubble)) { m_outerMiddleBorder.SetActive(true); m_outerMiddleBackground.SetActive(true); UpdateBubbleObjectSize(m_innerBorder, textLength * 6 + 2, 17 + 11 * (totalLines - 1), -9 + offsetX, -12 + offsetY); UpdateBubbleObjectSize(m_innerBackground, textLength * 6 + 2, 15 + 11 * (totalLines - 1), -9 + offsetX, -11 + offsetY); UpdateBubbleObjectSize(m_middleBorder, textLength * 6 + 6, 15 + 11 * (totalLines - 1), -11 + offsetX, -11 + offsetY); UpdateBubbleObjectSize(m_middleBackground, textLength * 6 + 6, 13 + 11 * (totalLines - 1), -11 + offsetX, -10 + offsetY); UpdateBubbleObjectSize(m_outerMiddleBorder, textLength * 6 + 8, 13 + 11 * (totalLines - 1), -12 + offsetX, -10 + offsetY); UpdateBubbleObjectSize(m_outerMiddleBackground, textLength * 6 + 8, 9 + 11 * (totalLines - 1), -12 + offsetX, -8 + offsetY); UpdateBubbleObjectSize(m_outerBorder, textLength * 6 + 10, 9 + 11 * (totalLines - 1), -13 + offsetX, -8 + offsetY); } else { m_outerMiddleBorder.SetActive(false); m_outerMiddleBackground.SetActive(false); UpdateBubbleObjectSize(m_innerBorder, textLength * 6 + 4, 17, -9 + offsetX, -12 + offsetY); UpdateBubbleObjectSize(m_innerBackground, textLength * 6 + 4, 15, -9 + offsetX, -11 + offsetY); UpdateBubbleObjectSize(m_middleBorder, textLength * 6 + 6, 15, -10 + offsetX, -11 + offsetY); UpdateBubbleObjectSize(m_middleBackground, textLength * 6 + 6, 13, -10 + offsetX, -10 + offsetY); UpdateBubbleObjectSize(m_outerBorder, textLength * 6 + 8, 13, -11 + offsetX, -10 + offsetY); } }
public virtual IEnumerator SearchAnidado(BubbleType matchType, bool matchByType = true) { // me fijo si : // - el tipo es igual // - es un especial que no matchea por color // - ya procese este vecino if ((matchType.Equals(compoBubble.type) && matchByType) && !processed) { processed = true; TileGrid.instance.cluster.Add(this.compoBubble); BubbleNeighbor myNeighbors = new BubbleNeighbor(); foreach (var neighbor in myNeighbors.GetWithoutDiagonals()) //GetTileOffsetsBasedOnParity(compoBubble.rowRaw % 2)) { // lista de vectores de offset para agregar a la posicion de // composite bubble. // reviso estar en rango y que tenga sentido hacer la comparacion if (compoBubble.rowRaw - (int)neighbor.y >= 0 && compoBubble.rowRaw - (int)neighbor.y < TileGrid.instance.grid.GetLength(1)) { if (compoBubble.colRaw + (int)neighbor.x >= 0 && compoBubble.colRaw + (int)neighbor.x < TileGrid.instance.grid.GetLength(0)) { // estando en la grilla, reviso el tipo var target = TileGrid.instance.grid[compoBubble.colRaw + (int)neighbor.x, compoBubble.rowRaw - (int)neighbor.y]; // si es valido y es una burbuja, hago otro search anidado a sus vecinos if (target != null && target.gameObject.activeInHierarchy) { RaycastHit2D recheck = Physics2D.Raycast(transform.position, target.transform.position - transform.position); Debug.DrawRay(transform.position, target.transform.position - transform.position, Color.red, 2f); Debug.Log("Drawing ray recheck"); //yield return new WaitForSeconds(2f); if (recheck.collider != null && this.compoBubble != null) { if (matchType.Equals(this.compoBubble.type) && matchType.Equals(recheck.collider.GetComponent <Bubble>().type)) { yield return(StartCoroutine(target.GetComponent <PopBubble>().SearchAnidado(matchType, matchByType))); } } } } } } } else if (!matchByType && !processed) { switch (compoBubble.type.type) { /// todos estos casos deben estar definidos en la lista de burbujas /// especiales (guardada en BubbleResources). case "line": processed = true; for (int col = 0; col < TileGrid.instance.grid.GetLength(0); col++) { if (compoBubble.rowRaw >= 1 && compoBubble.rowRaw < TileGrid.instance.grid.GetLength(1)) { TileGrid.instance.cluster.Add(TileGrid.instance.grid[col, this.compoBubble.rowRaw]); TileGrid.instance.cluster.Add(TileGrid.instance.grid[col, compoBubble.rowRaw - 1]); Debug.Log("Doble fila deleteada"); } else if (compoBubble.rowRaw == 0) { TileGrid.instance.cluster.Add(TileGrid.instance.grid[col, this.compoBubble.rowRaw]); Debug.Log("Fila techo deleteada"); } } break; } } }