public static FindChildByTag ( Transform theParent, string childTag ) : Transform | ||
theParent | Transform | |
childTag | string | Child tag. |
return | Transform |
/// <summary> /// Clear the path. /// </summary> public void ClearPath() { numberOfPoints = 0; for (int i = 0; i < linePieces.Count; i++) { GameObject.Destroy(linePieces [i].gameObject); } linePieces.Clear(); points.Clear(); rects.Clear(); Transform gridCellContent = null; for (int i = 0; i < path.Count; i++) { gridCell = PuzzleManager.gridCells [path [i]]; if (i == 0 || i == path.Count - 1) { //Reset elements(dots) pair sprites gridCellContent = GameObjectUtil.FindChildByTag(gridCell.transform, "GridCellContent"); if (gridCellContent != null) { gridCellContent.GetComponent <Image> ().sprite = PuzzleManager.currentLevel.dotsPairs [gridCell.elementPairIndex].pairSprite; gridCellContent.GetComponent <Image> ().color = PuzzleManager.currentLevel.dotsPairs [gridCell.elementPairIndex].pairColor; } } ResetGridCell(gridCell); } completedLine = false; path.Clear(); }
protected void Start() { mMadBomberData = GetComponentInParent <MadBomberData>(); mController = GetComponentInParent <MB_CC_BomberController>(); mHitTakenController = GetComponentInParent <PlayerHitTakenController>(); mAnimator = GetComponentInChildren <Animator>(); mModel3DRenderers = GameObjectUtil.FindChildByTag(transform, TagName.MODEL_3D).GetComponentsInChildren <Renderer>(); }
/// <summary> /// When a click(touch) moved over the GridCell. /// </summary> private void GridCellClickMoved() { if (currentLine == null) { Debug.Log("Current Line is undefined"); return; } if (currentGridCell == null) { Debug.Log("Current GridCell is undefined"); return; } if (previousGridCell == null) { Debug.Log("Previous GridCell is undefined"); return; } if (currentGridCell.index == previousGridCell.index) { return; } ///If the current grid cell is not adjacent of the previous grid cell,then ignore it if (!previousGridCell.OneOfAdjacents(currentGridCell.index)) { Debug.Log("Current grid cell of index " + currentGridCell.index + " is Ignored [Reason : Not Adjacent Of Previous GridCell " + previousGridCell.index); return; } ///If the current grid cell is currently used if (currentGridCell.currentlyUsed) { if (currentGridCell.gridLineIndex == -1) { return; } if (currentGridCell.gridLineIndex == previousGridCell.gridLineIndex) { gridLines [currentGridCell.gridLineIndex].RemoveElements(currentGridCell.index); previousGridCell = currentGridCell; Debug.Log("Remove some Elements from the Line Path of index " + currentGridCell.gridLineIndex); ///Increase the movements counter IncreaseMovements(); return; //skip next } else { Debug.Log("Clear the Line Path of index " + currentGridCell.gridLineIndex); gridLines [currentGridCell.gridLineIndex].ClearPath(); } } ///If the current grid cell is not empty or it's not a partner of the previous grid cell if (!currentGridCell.isEmpty && currentGridCell.index != previousGridCell.tragetIndex) { Debug.Log("Current grid cell of index " + currentGridCell.index + " is Ignored [Reason : Not the wanted Traget]"); return; //skip next } ///Increase the movements counter IncreaseMovements(); ///Setting up the attributes for the current grid cell currentGridCell.currentlyUsed = true; currentGridCell.gridLineIndex = previousGridCell.gridLineIndex; if (currentGridCell.gridLineIndex == -1) { return; } if (currentGridCell.isEmpty) { currentGridCell.tragetIndex = previousGridCell.tragetIndex; } ///Link the color of top background of the current grid cell with the top background color of the previous grid cell currentGridCell.topBackgroundColor = previousGridCell.topBackgroundColor; Debug.Log("New GridCell of Index " + currentGridCell.index + " added to the Line Path of index " + currentLine.index); ///Add the current grid cell index to the current traced grid cells list currentLine.path.Add(currentGridCell.index); ///Determine the New Line Point tempPoint = currentGridCell.transform.position; tempPoint.z = gridLineZPosition; ///Add the position of the New Line Point to the current line gridLines [currentGridCell.gridLineIndex].AddPoint(tempPoint); bool playBubble = true; if (!currentGridCell.isEmpty) { //Two pairs connected if (previousGridCell.tragetIndex == currentGridCell.index) { Debug.Log("Two GridCells connected [GridCell " + (gridLines [currentGridCell.gridLineIndex].GetFirstPathElement()) + " with GridCell " + (gridLines [currentGridCell.gridLineIndex].GetLastPathElement()) + "]"); currentLine.completedLine = true; GridCell gridCell = null; for (int i = 0; i < currentLine.path.Count; i++) { gridCell = gridCells [currentLine.path [i]]; if (i == 0 || i == currentLine.path.Count - 1) { //Setting up the connect pairs GameObjectUtil.FindChildByTag(gridCell.transform, "GridCellContent").GetComponent <SpriteRenderer> ().sprite = currentLevel.dotsPairs [gridCell.elementPairIndex].connectSprite; } ///Setting up the color of the top background of the grid cell tempColor = previousGridCell.topBackgroundColor; tempColor.a = gridCellTopBackgroundAlpha; tempSpriteRendererd = gridCell.transform.Find("background").GetComponent <SpriteRenderer> (); tempSpriteRendererd.color = tempColor; ///Enable the top backgroud of the grid cell tempSpriteRendererd.enabled = true; } ///Play the connected sound effect at the center of the unity world AudioSource.PlayClipAtPoint(connectedSFX, Vector3.zero, effectsAudioSource.volume); playBubble = false; Release(null); //检查是否过关 CheckLevelComplete(); return; } } if (playBubble) { ///Play the water buttle sound effect at the center of the unity world AudioSource.PlayClipAtPoint(waterBubbleSFX, Vector3.zero, effectsAudioSource.volume); } previousGridCell = currentGridCell; }