void OnTriggerEnter(Collider other) { CubeElement cubeElement = other.GetComponent <CubeElement>(); if (cubeElement.shape == this.shape) { cubeElement.DOShapeSelected(); gameManager.point++; } else { gameManager.DOGameOver(); } }
void Awake() { player = GetComponentInParent <Player>(); cube = GetComponentInParent <CubeElement>(); }
IEnumerator CreateWorld() { bool firstActivation = true; while (true) { int stopZ = UnityEngine.Random.Range(minNumOfCubeInLine, maxNumOfCubeInLine) + z; int activateElementAtPositionZ = UnityEngine.Random.Range(z + 1, stopZ - 2); CubeElement c = null; while (z <= stopZ) { while (GetNumberOfCubeInTheScene() > numMaxOfCubeInScene) { yield return(0); } c = InstantiateCube(x, z); if (z == activateElementAtPositionZ) { if (firstActivation) { firstActivation = false; } else { c.activateElement(); c.DORotateElement(); } } nextTargets.Add(c); c.isRightCube = true; z++; yield return(new WaitForSeconds(timeToMoveOnOneBlock)); } int stopX = UnityEngine.Random.Range(5, 10) + x; int activateElementAtPositionX = UnityEngine.Random.Range(x + 2, stopX - 2); while (x <= stopX) { while (GetNumberOfCubeInTheScene() > numMaxOfCubeInScene) { yield return(0); } c = InstantiateCube(x, z); if (x == activateElementAtPositionX) { c.activateElement(); } nextTargets.Add(c); c.isRightCube = false; x++; yield return(new WaitForSeconds(timeToMoveOnOneBlock)); } } }