示例#1
0
    private void Update()
    {
        if ((Input.GetMouseButtonDown(0) || Input.touchCount > 0) && cubeToPlace != null)
        {
            GameObject newCube = Instantiate(
                cubeToCreate,
                cubeToPlace.position,
                Quaternion.identity) as GameObject;

            newCube.transform.SetParent(allCubes.transform);
            nowCube.setVector(cubeToPlace.position);
            allCubesPositions.Add(nowCube.GetVector());
            score++;

            allCubesRB.isKinematic = true;
            allCubesRB.isKinematic = false;
            SpawnPositions();
        }
        if (!isLose && allCubesRB.velocity.magnitude > 0.1f)
        {
            Destroy(cubeToPlace.gameObject);
            isLose = true;
            StopCoroutine(showCubePlace);
        }
    }
示例#2
0
    // Update is called once per frame
    void Update()
    {
        /* If User presses LEFT MOUSE KEY or touches touchscreen*/
        if ((Input.GetMouseButtonDown(0) || Input.touchCount > 0) && cubeToPlace != null)
        {
#if !UNITY_EDITOR
            if (Input.GetTouch(0).phase != TouchPhase.Began)
            {
                return;
            }
#endif
            GameObject newCube = Instantiate(CubeToCreate, cubeToPlace.position, Quaternion.identity) as GameObject;        //create new cube with random coordinates on user's touch or click
            Debug.Log(newCube);
            Debug.Log(AllCubes);
            newCube.transform.SetParent(AllCubes.transform);
            nowCube.SetVector(cubeToPlace.position);
            allCubesPositions.Add(nowCube.GetVector());

            allCubesRigidBody.isKinematic = true;
            allCubesRigidBody.isKinematic = false;
        }
        if (!gameOver && (allCubesRigidBody.velocity.magnitude > 0.1f))
        {
            Debug.Log(allCubesRigidBody.velocity.magnitude);
            Destroy(cubeToPlace.gameObject);
            gameOver = true;
            StopCoroutine(startGame);
        }
    }
    private void Update()
    {
        if ((Input.GetMouseButtonDown(0) || Input.touchCount > 0) && allCubes != null && cubeToPlace != null && !EventSystem.current.IsPointerOverGameObject())
        {
#if !UNITY_EDITOR
            if (Input.GetTouch(0).phase != TouchPhase.Began)
            {
                return;
            }
#endif
            if (!firstCube)
            {
                firstCube = true;
                foreach (GameObject item in canvasStartPage)
                {
                    Destroy(item);
                }
            }
            GameObject createCube = null;
            if (posibleCubesToCreate.Count == 1)
            {
                createCube = posibleCubesToCreate[0];
            }
            else
            {
                createCube = posibleCubesToCreate[UnityEngine.Random.Range(0, posibleCubesToCreate.Count)];
            }

            GameObject newCube = Instantiate(createCube, cubeToPlace.position, Quaternion.identity) as GameObject;

            newCube.transform.SetParent(allCubes.transform);
            nowCube.SetVector(cubeToPlace.position);
            allCubsPositions.Add(nowCube.GetVector());

            GameObject newVfx = Instantiate(vfx, newCube.transform.position, Quaternion.identity) as GameObject;
            Destroy(newVfx, 1.5f);

            allCubesRb.isKinematic = true;
            allCubesRb.isKinematic = false;

            SpawnPositions();
            MoveCameraChangeBg();
        }

        if (!IsLose && allCubesRb.velocity.magnitude > 0.1f)
        {
            Destroy(cubeToPlace.gameObject);
            IsLose = true;
            StopCoroutine(showCubePlace);
        }

        mainCam.localPosition = Vector3.MoveTowards(mainCam.localPosition, new Vector3(mainCam.localPosition.x, camMoveToYPosition,
                                                                                       mainCam.localPosition.z), camMoveSpeed * Time.deltaTime);

        if (Camera.main.backgroundColor != toCameraColor)
        {
            Camera.main.backgroundColor = Color.Lerp(Camera.main.backgroundColor, toCameraColor, Time.deltaTime / 1.5f);
        }
    }
示例#4
0
    private void Update()
    {
        if ((Input.GetMouseButtonDown(0) || Input.touchCount > 0) && CubeToPlace != null && AllCubes != null && !EventSystem.current.IsPointerOverGameObject())
        {
#if !UNITY_EDITOR
            if (Input.GetTouch(0).phase != TouchPhase.Began)
            {
                return;
            }
#endif

            if (!firstCube)
            {
                firstCube = true;
                foreach (GameObject obj in canvasStartPage)
                {
                    Destroy(obj);
                }
            }

            GameObject newCube = Instantiate(CubesToCreate[UnityEngine.Random.Range(0, CubesToCreate.Length)], CubeToPlace.position, Quaternion.identity) as GameObject;

            newCube.transform.SetParent(AllCubes.transform);
            nowCube.setVector(CubeToPlace.position);
            AllCubePositions.Add(nowCube.GetVector());

            GameObject newVfx = Instantiate(vfx, newCube.transform.position, Quaternion.identity) as GameObject;

            Destroy(newVfx, 1.5f);

            if (PlayerPrefs.GetString("music") != "No")
            {
                GetComponent <AudioSource>().Play();
            }

            AllCubesRb.isKinematic = true;
            AllCubesRb.isKinematic = false;

            SpawnPositions();
            MoveCameraChangeBg();
        }

        if (!IsLose && AllCubesRb.velocity.magnitude > 0.1f)
        {
            Destroy(CubeToPlace.gameObject);
            IsLose = true;
            StopCoroutine(shpowCubePlace);
        }

        mainCam.localPosition = Vector3.MoveTowards(mainCam.localPosition,
                                                    new Vector3(mainCam.localPosition.x, camMoveToYPosition, mainCam.localPosition.z),
                                                    camMoveSpeed * Time.deltaTime);

        if (Camera.main.backgroundColor != toCameraColor)
        {
            Camera.main.backgroundColor = Color.Lerp(Camera.main.backgroundColor, toCameraColor, Time.deltaTime / 1.5f);
        }
    }
    private void Update()
    {
        if ((Input.GetMouseButtonDown(0) || Input.touchCount > 0) && CubeToPlace != null && AllCubes != null && !EventSystem.current.IsPointerOverGameObject())
        {
#if !UNITY_EDITOR
            if (Input.GetTouch(0).phase != TouchPhase.Began)
            {
                return;
            }
#endif

            if (!FirstCube)
            {
                FirstCube = true;
                foreach (GameObject obj in canvasStartPage)
                {
                    Destroy(obj);
                }
            }

            GameObject newCube = Instantiate(CubeToCreate, CubeToPlace.position, Quaternion.identity) as GameObject;

            newCube.transform.SetParent(AllCubes.transform);
            nowCube.SetVector(CubeToPlace.position);
            allCubesPositions.Add(nowCube.GetVector());

            AllCubesRB.isKinematic = true;
            AllCubesRB.isKinematic = false;

            SpawnPositions();
            MoveCameraBG();
        }

        if (!IsLoos && AllCubesRB.velocity.magnitude > 0.1f)
        {
            Destroy(CubeToPlace.gameObject);
            IsLoos = true;
            StopCoroutine(showCubePlace);
        }
        mainCam.localPosition = Vector3.MoveTowards(mainCam.localPosition, (new Vector3(mainCam.localPosition.x, camMoveToPosition, mainCam.localPosition.z)), camMoveSpeed * Time.deltaTime);

        if (Camera.main.backgroundColor != toCameraCaller)
        {
            Camera.main.backgroundColor = Color.Lerp(Camera.main.backgroundColor, toCameraCaller, Time.deltaTime / 1.5f);
        }
    }
示例#6
0
    private void Update()
    {
        if ((Input.GetMouseButtonDown(0) || Input.touchCount > 0) && cubeToPlace != null && !EventSystem.current.IsPointerOverGameObject())
        {
#if !UNITY_EDITOR
            if (Input.GetTouch(0).phase != TouchPhase.Began)
            {
                return;
            }
#endif


            if (!firstCube)
            {
                firstCube = true;
                foreach (GameObject obj in CanvasStartPage)
                {
                    Destroy(obj);
                }
            }
            GameObject CreateCube = null;
            if (possibleCubesToCreate.Count == 1)
            {
                CreateCube = possibleCubesToCreate[0];
            }
            else
            {
                CreateCube = possibleCubesToCreate[UnityEngine.Random.Range(0, possibleCubesToCreate.Count)];
            }

            GameObject newCube = Instantiate(
                CreateCube,
                cubeToPlace.position,
                Quaternion.identity) as GameObject;

            newCube.transform.SetParent(allCubes.transform);
            nowCube.SetVector(cubeToPlace.position);
            allCUbesPos.Add(nowCube.GetVector());

            if (PlayerPrefs.GetString("Music") != "No")
            {
                GetComponent <AudioSource>().Play();
            }

            Instantiate(VFX, cubeToPlace.position, Quaternion.identity);

            allCubesRb.isKinematic = true;
            allCubesRb.isKinematic = false;

            SpawnPositions();
            MoveCameraChangeBG();
        }
        if (!islose && allCubesRb.velocity.magnitude > 0.3f)
        {
            Destroy(cubeToPlace.gameObject);
            islose = true;
            StopCoroutine(showCubePlace);
            GameObject.Find("Rotator").gameObject.GetComponent <RotsteCamera>().Rotate = true;
        }
        mainCam.localPosition = Vector3.MoveTowards(mainCam.localPosition,
                                                    new Vector3(mainCam.localPosition.x, camMovetoYPosition, mainCam.localPosition.z),
                                                    CamMoveSpeed * Time.deltaTime);

        if (Camera.main.backgroundColor != toCameraColor)
        {
            Camera.main.backgroundColor = Color.Lerp(Camera.main.backgroundColor, toCameraColor, Time.deltaTime / 1.5f);
        }
    }