예제 #1
0
        void OnTriggerEnter(Collider other)
        {
            CubeElement cubeElement = other.GetComponent <CubeElement>();

            if (cubeElement.shape == this.shape)
            {
                cubeElement.DOShapeSelected();
                gameManager.point++;
            }
            else
            {
                gameManager.DOGameOver();
            }
        }
예제 #2
0
 void Awake()
 {
     player = GetComponentInParent <Player>();
     cube   = GetComponentInParent <CubeElement>();
 }
예제 #3
0
        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));
                }
            }
        }