예제 #1
0
    void Update()
    {
        //just some Debugging.
        Vector3 tapPositionA;

        if (Input.touchCount > 0)
        {
            touches      = Input.touches;
            tapPositionA = TapPosition(0);
            debug.NewDebug(tapPositionA.ToString(), "TapPosA");
            debug.NewDebug(Input.touchCount.ToString(), "TouchCount");
        }
        else
        {
            debug.NewDebug(Vector3.zero.ToString(), "TapPosA");
            debug.NewDebug("0", "TouchCount");
            touches.Initialize();
        }

        //debugging end

        SwipedOnEdge();
    }
예제 #2
0
    void Update()
    {
        switch (levelSettings.GetCurrentLevel())
        {
        case 0:
            levelComplete = true;
            break;

        case 1:
            GameObject[] spheres = GameObject.FindGameObjectsWithTag("moveable");
            //selects bottom in heirarchy
            int activeCount = 0;

            for (int i = 0; i < spheres.Length; i++)
            {
                GameData.spheresActive[i] = spheres[i].GetComponent <ObjectSettings>().locked;
                if (spheres[i].GetComponent <ObjectSettings>().locked)
                {
                    activeCount++;
                }
            }

            if (GameData.levelsComplete < 2)
            {
                if (activeCount == spheres.Length)
                {
                    levelComplete = true;
                }
                activeCount = 0;
            }
            else
            {
                levelComplete = true;
            }

            break;

        case 2:

            bool bellHit = false, spiralsRotated = false, sphereLocked = false;

            GameObject bell = GameObject.Find("bell");

            GameObject sphere = GameObject.Find("spherePivot");

            GameObject spiralLeft = GameObject.Find("spiralLeft");
            GameObject dirLeft    = spiralLeft.transform.Find("dir").gameObject;

            GameObject eyeLeft  = GameObject.Find("eyeLeft");
            GameObject eyeRight = GameObject.Find("eyeRight");


            Vector3 diffLeft  = spiralLeft.transform.position - dirLeft.transform.position;
            float   angleLeft = Mathf.Atan2(diffLeft.y, diffLeft.x) * Mathf.Rad2Deg;

            if (GameData.levelsComplete < 3)
            {
                if (angleLeft <= -125 && angleLeft >= -136)
                {
                    spiralsRotated = true;
                }
                if (sphere.GetComponent <ObjectSettings>().locked)
                {
                    sphereLocked = true;
                }
                if (bell.GetComponent <ObjectSettings>().selected)
                {
                    bellHit = true;
                }

                if (bellHit && spiralsRotated && sphereLocked)
                {
                    levelComplete = true;
                }

                print(angleLeft);
                debug.NewDebug("" + bellHit, "bell");
                debug.NewDebug("" + spiralsRotated, "sprial");
                debug.NewDebug("" + sphereLocked, "locked");
            }
            else
            {
                levelComplete = true;
            }

            if (levelComplete)
            {
                eyeLeft.transform.Rotate(Vector3.forward * 10 * Time.deltaTime);
                eyeRight.transform.Rotate(Vector3.forward * -10 * Time.deltaTime);
                glow.SetActive(true);
            }
            else
            {
                glow.SetActive(false);
            }

            break;

        case 3:
            levelComplete = true;
            break;

        case 4:
            int count = 0;

            for (int i = 0; i < GameData.spheresActive.Length; i++)
            {
                if (GameData.spheresActive[i])
                {
                    count++;
                }
            }
            if (count > 1)
            {
                levelComplete = true;
            }
            break;
        }

        if (levelComplete)
        {
            nextLevelButton.gameObject.SetActive(true);
        }
        else
        {
            nextLevelButton.gameObject.SetActive(false);
        }

        if (levelSettings.GetCurrentLevel() != 0)
        {
            lastLevelButton.gameObject.SetActive(true);
        }
        else
        {
            lastLevelButton.gameObject.SetActive(false);
        }
    }