Example #1
0
    void Update()
    {
        if (skin.isVisible)
        {
            acceleration      = Input.acceleration;
            lowPassValue      = Vector3.Lerp(lowPassValue, acceleration, updateAcceleration);
            deltaAcceleration = acceleration - lowPassValue;

            // If shake magnitude threshold hit, reduce obj
            if (deltaAcceleration.sqrMagnitude >= minShake)
            {
                obj.transform.localScale -= new Vector3(0.05f, 0.05f, 0.05f);
                shakeCount++;

                if (shakeCount > 10)
                {
                    Destroy(obj);
                    hint.SetActive(true);
                    sphere.SetActive(true);
                }
            }

            if (ARHandler.GetHitIfAny().Equals(sphere.name))
            {
                Destroy(hint);
                Destroy(sphere);
                ARHandler.GetAchievement("King of the slimes");
            }
        }
    }
    void Update()
    {
        // levelMax equals to the highest normalized value power 2, a small number because < 1
        // pass the value to a static var so we can access it from anywhere
        if (obj.GetComponentInChildren <SkinnedMeshRenderer>().isVisible)
        {
            volume = MicrophoneLevelMax();

            if (volume > 0.04 && !complete && skin.isVisible)
            {
                anim.SetTrigger(scare);
                obj.transform.Rotate(0, 180, 0);
                obj.transform.position = Vector3.MoveTowards(obj.transform.position, obj.transform.position - moveTo, Time.deltaTime * 1200);
                complete = true;
                hint.SetActive(true);
                hintsphere.SetActive(true);
            }

            if (ARHandler.GetHitIfAny().Equals(hintsphere.name))
            {
                // Waiting for finalised achievement list
                Destroy(hint);
                ARHandler.GetAchievement("TNT I'm Zygomite!");
            }
        }
    }
Example #3
0
 void Update()
 {
     if (ARHandler.GetHitIfAny().Equals(hint.name))
     {
         Destroy(hint);
         ARHandler.GetAchievement("What a steal!");
     }
     else if (ARHandler.GetHitIfAny().Equals(collide.name))
     {
         // Rotate 'obj' to face the camera (only in the y axis)
         obj.transform.forward = (Vector3.ProjectOnPlane(-Camera.main.transform.forward, new Vector3(0, 1, 0)));
     }
 }
Example #4
0
    void Update()
    {
        if (ARHandler.GetHitIfAny().Equals(resource.name))
        {
            hitCounter++;
        }

        if (hitCounter == 3)
        {
            Destroy(resource);
            resourceCollected.SetActive(true);
            Destroy(obj);
        }
    }
    void Update()
    {
        // TODO: fix directions
        if (obj.GetComponentInChildren <SkinnedMeshRenderer>().isVisible)
        {
            string item = ARHandler.GetHitIfAny();

            moveTo = Vector3.zero;

            // Based on swipe, manipulate transform vector
            if (swipe.GetUp())
            {
                moveTo += new Vector3(0, 0, 0.001f);
            }
            if (swipe.GetDown())
            {
                moveTo += new Vector3(0, 0, -0.001f);
            }
            if (swipe.GetLeft())
            {
                moveTo += new Vector3(0.001f, 0, 0);
            }
            if (swipe.GetRight())
            {
                moveTo += new Vector3(-0.001f, 0, 0);
            }

            //moveTo = new Vector3(-0.001f, 0, 0);

            if ((planks[which].transform.position - hint.transform.position).magnitude < 0.3f)
            {
                planks[which].transform.position = Vector3.MoveTowards(planks[which].transform.position, planks[which].transform.position + 5 * moveTo, 20 * Time.deltaTime);
            }
            else
            {
                if (which < 4)
                {
                    which++;
                }
            }

            if (ARHandler.GetHitIfAny().Equals(hintsphere.name))
            {
                Destroy(hint);
                Destroy(hintsphere);
                ARHandler.GetAchievement("Yak whisperer");
            }
        }
    }
Example #6
0
    void Update()
    {
        // If fish are toggled
        if (reactionFrames > 0)
        {
            reactionFrames--;

            string hit = ARHandler.GetHitIfAny();

            if (hit.Equals(hitSphere[0].transform.name))
            {
                Destroy(fish[0]);
                Destroy(hitSphere[0]);
                feedbackMarker[0].SetActive(true);
                ARHandler.GetAchievement("Finding Nome");
            }

            if (hit.Equals(hitSphere[0].transform.name))
            {
                Destroy(fish[1]);
                Destroy(hitSphere[1]);
                feedbackMarker[1].SetActive(true);
                ARHandler.GetAchievement("Finding Dyro");
            }
        }

        else
        {
            // Toggle one fish at a time
            float selector = Random.value;
            if (selector < 0.5f)
            {
                if (fish[0] != null && hitSphere[0] != null)
                {
                    fish[0].SetActive(false);
                    hitSphere[0].SetActive(false);
                }
            }
            else
            {
                if (fish[0] != null && hitSphere[0] != null)
                {
                    fish[1].SetActive(false);
                    hitSphere[1].SetActive(false);
                }
            }

            float rand = Random.value;
            if (rand < probability)
            {
                // Show sphere for 1 second at a time
                reactionFrames = (int)(0.5f / Time.deltaTime);

                if (selector < 0.5f)
                {
                    if (fish[0] != null && hitSphere[0] != null)
                    {
                        fish[0].SetActive(true);
                        hitSphere[0].SetActive(true);
                    }
                }
                else
                {
                    if (fish[0] != null && hitSphere[0] != null)
                    {
                        fish[1].SetActive(true);
                        hitSphere[1].SetActive(true);
                    }
                }
            }
        }
    }
    void Update()
    {
        // If 4 values have been entered, reset the counter, check if correct, act accordingly
        if (pushCount == 4)
        {
            pushCount = 0;
            // Change values for custom code
            if (inputCode[0] == 1 && inputCode[1] == 2 && inputCode[2] == 3 && inputCode[3] == 4)
            {
                for (int i = 0; i < numpad.Length; i++)
                {
                    Destroy(numpad[i]);
                    Destroy(shells[i]);
                    Destroy(feedbackMarker[i]);
                }
                hint.SetActive(true);
                hintsphere.SetActive(true);
            }

            else
            {
                // Reset feedbackMarker materials
                for (int i = 0; i < feedbackMarker.Length; i++)
                {
                    SimpleChangeMaterial(feedbackMarker[i], feedbackMaterial[0]);
                }
            }
        }

        // Find which button was pressed
        switch (ARHandler.GetHitIfAny())
        {
        case "key1":
            inputCode[pushCount] = 1;
            SimpleChangeMaterial(feedbackMarker[pushCount], feedbackMaterial[1]);
            pushCount++;
            break;

        case "key2":
            inputCode[pushCount] = 2;
            SimpleChangeMaterial(feedbackMarker[pushCount], feedbackMaterial[1]);
            pushCount++;
            break;

        case "key3":
            inputCode[pushCount] = 3;
            SimpleChangeMaterial(feedbackMarker[pushCount], feedbackMaterial[1]);
            pushCount++;
            break;

        case "key4":
            inputCode[pushCount] = 4;
            SimpleChangeMaterial(feedbackMarker[pushCount], feedbackMaterial[1]);
            pushCount++;
            break;

        case "hintsphere":
            Destroy(hint);
            Destroy(hintsphere);
            ARHandler.GetAchievement("Crab rave");
            break;

        default:
            break;
        }
    }