Esempio n. 1
0
    void Update()
    {
        Vector3 inputVector;

        if (TouchScreenScript.GetTouch(out inputVector) && inputOn)
        {
            Ray        ray = Camera.main.ScreenPointToRay(inputVector);
            RaycastHit hit;

            if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity))
            {
                if (hit.collider.gameObject.name == "drapesHiding" && inputOn)
                {
                    questState = 1;
                    StartCoroutine(QuestStateTimeLine(questState, 0));

                    inputOn = false;
                }
            }
        }

        if (questState == 4 && completed == false)
        {
            completed = true;

            engine.IncrementScore(9);

            star.SetActive(true);

            trackableFairyAnim.SetTrigger("celebrate");
            bearAnim.SetTrigger("celebrate");
            bear.transform.LookAt(new Vector3(Camera.main.transform.position.x, bear.transform.position.y, Camera.main.transform.position.z));
            StartCoroutine(VictorySpeech());
        }
    }
Esempio n. 2
0
    private void Update()
    {
        // level completed
        if (questState == 1 && completed == false)
        {
            //CompleteLevel();
        }

        // With this you can check if you clicked/touched something in front of main camera or local camera.
        if (inputOn)
        {
            Vector3 inputVector;
            if (TouchScreenScript.GetTouch(out inputVector))
            {
                // raycast from main camera. Used to raycast objects in the room itself
                if (rayCastMainCamera)
                {
                    Ray        ray = Camera.main.ScreenPointToRay(inputVector);
                    RaycastHit hit;
                    if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity) && inputOn)
                    {
                        if (hit.collider.name != null)
                        {
                            StartCoroutine(WalkBear(hit.point, 0));
                            Debug.Log("Something in mainCam is clicked!");
                        }
                    }
                }
                // raycast from local camera. Used to raycast objects in the localObjects layer.
                if (rayCastLocalCamera)
                {
                    Ray        ray = localCamera.ScreenPointToRay(inputVector);
                    RaycastHit hit;
                    // check only "localObjects" layer for hit
                    if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity, (1 << 8)) && inputOn)
                    {
                        if (hit.collider.name != null)
                        {
                            Debug.Log("Something in localCam is clicked!");
                        }
                    }
                }
            }
        }
    }
    void Update()
    {
        Vector3 inputVector;

        if (TouchScreenScript.GetTouch(out inputVector) && inputOn)
        {
            Ray        ray = localCamera.ScreenPointToRay(inputVector);
            RaycastHit hit;

            if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity, 1 << 8))
            {
                if (hit.collider.gameObject.name == "drapesHiding" && inputOn)
                {
                    questState = 1;
                    StartCoroutine(QuestStateTimeLine(questState, 0));

                    inputOn = false;
                }
            }
        }
    }
    void Update()
    {
        Vector3 inputVector;

        if (TouchScreenScript.GetTouch(out inputVector) && inputOn)
        {
            //Ray ray = Camera.main.ScreenPointToRay(inputVector);
            Ray        ray = localCamera.ScreenPointToRay(inputVector);
            RaycastHit hit;

            if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity, 1 << 8) && inputOn)
            {
                if (hit.collider.gameObject.name == "drapesHiding" && questState == 0)
                {
                    Debug.Log("bear is now clicked");
                    inputOn     = false;
                    questState  = 1;
                    bearClicked = true;
                }
            }
        }
    }
    void Update()
    {
        Vector3 inputVector;

        if (TouchScreenScript.GetTouch(out inputVector) && inputOn)
        {
            Ray        ray = Camera.main.ScreenPointToRay(inputVector);
            RaycastHit hit;

            if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity) && inputOn)
            {
                if (hit.collider.gameObject.name == "closetHiding" || hit.collider.gameObject.name == "drapesHiding" ||
                    hit.collider.gameObject.name == "carpetHiding" || hit.collider.gameObject.name == "bedHiding")
                {
                    Debug.Log(hit.collider.gameObject.name + " Panda was found here");
                    questState++;
                    StartCoroutine(QuestStateTimeLine(questState));
                }
            }
        }

        if (questState == 5 && completed == false)
        {
            completed = true;

            engine.IncrementScore(10);

            star.SetActive(true);

            trackableFairyAnim.SetTrigger("celebrate");
            bearAnim.SetTrigger("celebrate");
            pandaAnim.SetTrigger("celebrate");

            StartCoroutine(VictorySpeech());

            bear.transform.LookAt(new Vector3(Camera.main.transform.position.x, bear.transform.position.y, Camera.main.transform.position.z));
            panda.transform.LookAt(new Vector3(Camera.main.transform.position.x, panda.transform.position.y, Camera.main.transform.position.z));
        }
    }
    private void Update()
    {
        if (switchingIsActive)
        {
            Vector3 inputVector;
            if (inputOn && TouchScreenScript.GetTouch(out inputVector))
            {
                Ray        ray = Camera.main.ScreenPointToRay(inputVector);
                RaycastHit hit;

                if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity))
                {
                    var hitGO = hit.collider.gameObject;
                    for (int i = 0; i < lightSwitches.Length; i++)
                    {
                        if (hitGO == lightSwitches[i])
                        {
                            StartCoroutine(BearWalkAndTriggerLight(new Vector3(hitGO.transform.position.x, bear.transform.position.y, bear.transform.position.z), i));
                        }
                    }
                }
            }
        }
    }
    void Update()
    {
        // level completed
        if (questState == 4 && completed == false)
        {
            completed = true;

            engine.IncrementScore(11);

            star.SetActive(true);

            trackableFairyAnim.SetTrigger("celebrate");
            bearAnim.SetTrigger("celebrate");
            bear.transform.LookAt(new Vector3(Camera.main.transform.position.x, bear.transform.position.y, Camera.main.transform.position.z));
            StartCoroutine(VictorySpeech());
        }

        if (inputOn)
        {
            Vector3 inputVector;

            if (TouchScreenScript.GetTouch(out inputVector))
            {
                if (jumpingIsActive)
                {
                    Ray        ray = Camera.main.ScreenPointToRay(inputVector);
                    RaycastHit hit;
                    if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity) && inputOn)
                    {
                        if (hit.collider.name == "otso")
                        {
                            inputOn = false;

                            StartCoroutine(BearIsJumping());
                        }
                    }
                }
                else if (memoryGameIsActive)
                {
                    Ray        ray = localCamera.ScreenPointToRay(inputVector);
                    RaycastHit hit;
                    if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity, (1 << 8)) && inputOn)
                    {
                        if (hit.collider.tag == "memoryGameCard")
                        {
                            if (hit.collider.transform.parent.transform.rotation.eulerAngles.y == 180f)
                            {
                                if (cardIsRotating == false)
                                {
                                    cardIsRotating = true;

                                    if (hit.collider.transform.parent.name == "placeholder_palaA1")
                                    {
                                        lastIndex    = currentIndex;
                                        currentIndex = 0;
                                        StartCoroutine(RotateCard(0));
                                    }
                                    else if (hit.collider.transform.parent.name == "placeholder_palaB1")
                                    {
                                        lastIndex    = currentIndex;
                                        currentIndex = 1;
                                        StartCoroutine(RotateCard(1));
                                    }
                                    else if (hit.collider.transform.parent.name == "placeholder_palaC1")
                                    {
                                        lastIndex    = currentIndex;
                                        currentIndex = 2;
                                        StartCoroutine(RotateCard(2));
                                    }
                                    else if (hit.collider.transform.parent.name == "placeholder_palaD1")
                                    {
                                        lastIndex    = currentIndex;
                                        currentIndex = 3;
                                        StartCoroutine(RotateCard(3));
                                    }
                                    else if (hit.collider.transform.parent.name == "placeholder_palaA2")
                                    {
                                        lastIndex    = currentIndex;
                                        currentIndex = 4;
                                        StartCoroutine(RotateCard(4));
                                    }
                                    else if (hit.collider.transform.parent.name == "placeholder_palaB2")
                                    {
                                        lastIndex    = currentIndex;
                                        currentIndex = 5;
                                        StartCoroutine(RotateCard(5));
                                    }
                                    else if (hit.collider.transform.parent.name == "placeholder_palaC2")
                                    {
                                        lastIndex    = currentIndex;
                                        currentIndex = 6;
                                        StartCoroutine(RotateCard(6));
                                    }
                                    else if (hit.collider.transform.parent.name == "placeholder_palaD2")
                                    {
                                        lastIndex    = currentIndex;
                                        currentIndex = 7;
                                        StartCoroutine(RotateCard(7));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Esempio n. 8
0
    // Update is called once per frame
    void Update()
    {
        if (questState == 6 && completed == false)
        {
            completed = true;

            engine.IncrementScore(6);

            star.SetActive(true);

            trackableFairyAnim.SetTrigger("celebrate");
            bearAnim.SetTrigger("celebrate");

            StartCoroutine(VictorySpeech());

            bear.transform.LookAt(new Vector3(Camera.main.transform.position.x, bear.transform.position.y, Camera.main.transform.position.z));
        }

        Vector3 inputVector;

        if (TouchScreenScript.GetTouch(out inputVector) && inputOn)
        {
            if (pickedTrash != null)
            {
                Ray        ray = Camera.main.ScreenPointToRay(inputVector);
                RaycastHit hit;

                if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity) && inputOn)
                {
                    if (hit.collider.gameObject.name == "binMetal" && pickedTrash.name == "trashMetal")
                    {
                        StartCoroutine(MoveDropAndPick(3, 2, 2, 10));
                        inputOn = false;
                    }

                    if (hit.collider.gameObject.name == "binBio" && pickedTrash.name == "trashBio")
                    {
                        StartCoroutine(MoveDropAndPick(2, 1, 3, 0));
                        inputOn = false;
                    }

                    if (hit.collider.gameObject.name == "binProblem" && pickedTrash.name == "trashProblem")
                    {
                        StartCoroutine(MoveDropAndPick(1, 0, 4, 2));
                        inputOn = false;
                    }

                    if (hit.collider.gameObject.name == "binPaper" && pickedTrash.name == "trashPaper")
                    {
                        StartCoroutine(MoveAndDropLast(0, 0, 5, 9));
                        inputOn = false;
                    }

                    if (hit.collider.gameObject.name == "binEnergy" && pickedTrash.name == "trashEnergy")
                    {
                        StartCoroutine(MoveDropAndPick(4, 3, 1, 1));
                        inputOn = false;
                    }
                }
            }
        }
    }
    void Update()
    {
        // level completed
        if (questState == 1 && completed == false)
        {
            completed = true;

            engine.IncrementScore(5);

            star.SetActive(true);

            trackableFairyAnim.SetTrigger("celebrate");
            bearAnim.SetTrigger("celebrate");
            bear.transform.LookAt(new Vector3(Camera.main.transform.position.x, bear.transform.position.y, Camera.main.transform.position.z));
            StartCoroutine(VictorySpeech());
        }

        Vector3 inputVector;

        //Raycasting, both for picturemode and level view (currently no use for level view raycasting)
        if (TouchScreenScript.GetTouch(out inputVector) && inputOn)
        {
            if (!pictureMode)
            {
                //Ray ray = Camera.main.ScreenPointToRay(inputVector);
                //RaycastHit hit;

                //if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity) && inputOn)
                //{
                //    print(hit.collider.gameObject.name);
                //}
            }
            else
            {
                Ray        ray = localCam.ScreenPointToRay(inputVector);
                RaycastHit hit;


                if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity, (1 << 8)) && inputOn)
                {
                    if (hit.collider.tag == "ColorCube")
                    {
                        selectedColor = hit.collider.GetComponent <MeshRenderer>().material.color;
                    }

                    if (hit.collider.name == "CheckButton")
                    {
                        CheckIfDrawingFinished();
                    }
                    if (hit.collider.name == "ConfirmButton")
                    {
                        fairySpeechAS.Stop();
                        buttons.SetActive(false);
                        StartCoroutine(EndTimeLine());
                    }
                    if (hit.collider.name == "DenyButton")
                    {
                        buttons.SetActive(false);
                        checkbutton.SetActive(true);
                        drawingLocal.gameObject.SetActive(true);
                        StopCoroutine(speechCO);
                        trackableFairySpeechBubble.SetActive(false);
                        fairySpeechAS.Stop();
                    }
                }
            }
        }
    }
Esempio n. 10
0
    void Update()
    {
        if (questState == 3 && completed == false)
        {
            completed = true;

            StopCoroutine(speechCO);
            trackableFairySpeechBubble.SetActive(false);

            engine.IncrementScore(8);

            bear.transform.LookAt(new Vector3(Camera.main.transform.position.x, bear.transform.position.y, Camera.main.transform.position.z));
            star.SetActive(true);
            trackableFairyAnim.SetTrigger("celebrate");
            bearAnim.SetTrigger("celebrate");
            StartCoroutine(VictorySpeech());
        }

        Vector3 inputVector;

        // Raycasting, both for picturemode and level view (currently no use for level view raycasting)
        if (TouchScreenScript.GetTouch(out inputVector) && inputOn)
        {
            if (!pictureMode)
            {
                //Ray ray = Camera.main.ScreenPointToRay(inputVector);
                //RaycastHit hit;

                //if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity) && inputOn)
                //{
                //    print(hit.collider.gameObject.name);
                //}
            }
            else
            {
                Ray        ray = localCam.ScreenPointToRay(inputVector);
                RaycastHit hit;


                if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity, (1 << 8)) && inputOn)
                {
                    if (hit.collider.tag == "ColorCube")
                    {
                        selectedColor = hit.collider.GetComponent <MeshRenderer>().material.color;
                    }

                    if (hit.collider.tag == "ColoringPicture")
                    {
                        if (hit.collider.transform.parent.parent.parent.name == "BunnyCanvas")
                        {
                            hit.collider.transform.parent.GetComponent <UnityEngine.UI.Image>().color = selectedColor;

                            aSideDone = true;

                            readyLocalButton.SetActive(true);
                        }
                        if (hit.collider.transform.parent.parent.parent.name == "CatCanvas" && allowCatColoring)
                        {
                            hit.collider.transform.parent.GetComponent <UnityEngine.UI.Image>().color = selectedColor;

                            if (aSideDone)
                            {
                                readyLocalButton.SetActive(true);
                            }
                        }
                    }

                    if (hit.collider.name == "ReadyButton")
                    {
                        readyLocalButton.SetActive(false);
                        drawingLocal.gameObject.SetActive(false);

                        if (questState == 0)
                        {
                            StartCoroutine(AfterFirstDrawingTimeLine());
                        }
                        else if (questState == 2)
                        {
                            StartCoroutine(IncQuestStateAfterDelay());
                        }
                    }

                    print(hit.collider.transform.parent.name);
                    print(selectedColor);
                }
            }
        }

        if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved && allowDrawingTurning)
        {
            inputOn = false;
            Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
            localPaperY += touchDeltaPosition.y * 4;
            localPaperY  = Mathf.Clamp(localPaperY, 0, 180);

            localPaper.rotation = Quaternion.Euler(0, localPaperY, 0);

            if (Input.GetTouch(0).phase == TouchPhase.Ended)
            {
                StartCoroutine(RotateToClamp());
            }
        }

        if (Input.GetMouseButton(0) && allowDrawingTurning)
        {
            inputOn      = false;
            localPaperY -= Input.GetAxis("Mouse X") * 5;
            localPaperY  = Mathf.Clamp(localPaperY, 0, 180);

            localPaper.rotation = Quaternion.Euler(0, localPaperY, 0);
        }

        if (Input.GetMouseButtonUp(0))
        {
            StartCoroutine(RotateToClamp());
        }
    }
    void Update()
    {
        if (questState == 8 && completed == false)
        {
            completed = true;

            engine.IncrementScore(0);

            star.SetActive(true);
            trackableFairyAnim.SetTrigger("celebrate");
            bearAnim.SetTrigger("celebrate");
            bear.transform.LookAt(new Vector3(playerCamera.transform.position.x, bear.transform.position.y, playerCamera.transform.position.z));
            StartCoroutine(VictorySpeech());
        }

        Vector3 inputVector;

        if (TouchScreenScript.GetTouch(out inputVector) && inputOn)
        {
            Ray        ray = playerCamera.ScreenPointToRay(inputVector);
            RaycastHit hit;

            if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity) && inputOn)
            {
                if (hit.collider.gameObject.name == "sink")
                {
                    // Open sink
                    if (questState == 0)
                    {
                        inputOn = false;
                        Vector3 desPos = hit.collider.transform.position;
                        soundEffectAS.clip = acm.energyRoom1Clips[0];
                        soundEffectAS.Play();
                        StartCoroutine(WalkBear(desPos, 1));
                        StartCoroutine(OpenSinkAfterDelay());
                        StartCoroutine(ShowResultImageAfterDelay(2.5f, 0));
                        StartCoroutine(InputCooldown(2.5f));
                        StartCoroutine(IncQuestStateAfterDelay(2.5f));

                        // wash hands
                    }
                    else if (questState == 1)
                    {
                        inputOn            = false;
                        soundEffectAS.clip = acm.energyRoom1Clips[2];
                        soundEffectAS.Play();
                        bearAnim.SetTrigger("handwash");

                        StartCoroutine(ShowResultImageAfterDelay(2.5f, 1));
                        StartCoroutine(InputCooldown(2.5f));
                        StartCoroutine(IncQuestStateAfterDelay(2.5f));
                        // close sink
                    }
                    else if (questState == 2)
                    {
                        inputOn = false;
                        sinkLoop.Stop();
                        soundEffectAS.clip = acm.energyRoom1Clips[13];
                        soundEffectAS.Play();
                        bearAnim.SetTrigger("pressButton");

                        hanaAnimator.SetTrigger("openSink");
                        StartCoroutine(ShowResultImageAfterDelay(2.5f, 2));
                        StartCoroutine(InputCooldown(2.5f));
                        StartCoroutine(IncQuestStateAfterDelay(2.5f));
                        // open sink
                    }
                    else if (questState == 4)
                    {
                        inputOn = false;
                        Vector3 desPos = hit.collider.transform.position;

                        StartCoroutine(WalkBear(desPos, 1));
                        StartCoroutine(OpenSinkAfterDelay());
                        StartCoroutine(ShowResultImageAfterDelay(2.5f, 4));
                        StartCoroutine(InputCooldown(2.5f));
                        StartCoroutine(IncQuestStateAfterDelay(2.5f));
                        // wash hands
                    }
                    else if (questState == 5)
                    {
                        inputOn            = false;
                        soundEffectAS.clip = acm.energyRoom1Clips[2];
                        soundEffectAS.Play();
                        bearAnim.SetTrigger("handwash");

                        StartCoroutine(ShowResultImageAfterDelay(2.5f, 5));

                        StartCoroutine(InputCooldown(2.5f));
                        StartCoroutine(IncQuestStateAfterDelay(2.5f));
                    }

                    // close sink
                    else if (questState == 6)
                    {
                        inputOn = false;
                        sinkLoop.Stop();
                        soundEffectAS.clip = acm.energyRoom1Clips[13];
                        soundEffectAS.Play();
                        bearAnim.SetTrigger("pressButton");

                        hanaAnimator.SetTrigger("openSink");
                        StartCoroutine(ShowResultImageAfterDelay(2.5f, 6));

                        StartCoroutine(InputCooldown(2.5f));
                        StartCoroutine(IncQuestStateAfterDelay(2.5f));
                    }
                }

                if (hit.collider.gameObject.name == "soap")
                {
                    if (questState == 3)
                    {
                        inputOn = false;
                        Vector3 desPos = hit.collider.transform.position;

                        StartCoroutine(WalkBear(desPos, 2));

                        StartCoroutine(ShowResultImageAfterDelay(2.5f, 3));
                        StartCoroutine(IncQuestStateAfterDelay(2.5f));

                        StartCoroutine(InputCooldown(4f));
                    }
                }
                if (hit.collider.gameObject.name == "towel")
                {
                    if (questState == 7)
                    {
                        inputOn = false;
                        Vector3 desPos = hit.collider.transform.position;

                        StartCoroutine(WalkBear(desPos, 3));
                        StartCoroutine(ShowResultImageAfterDelay(2.5f, 7));
                        StartCoroutine(IncQuestStateAfterDelay(4));
                    }
                }
            }
        }
    }
Esempio n. 12
0
    // Update is called once per frame
    void Update()
    {
        if (questState == 4 && completed == false)
        {
            completed = true;

            engine.IncrementScore(7);

            star.SetActive(true);

            car.SetActive(false);
            bicycle.SetActive(true);

            trackableFairyAnim.SetTrigger("celebrate");
            bearAnim.SetBool("thinking", false);
            bearAnim.Play("idleanim");
            bearAnim.SetTrigger("celebrate");
            bear.transform.LookAt(new Vector3(Camera.main.transform.position.x, bear.transform.position.y, Camera.main.transform.position.z));
            StartCoroutine(VictorySpeech());
        }

        if (inputOn)
        {
            Vector3 inputVector;
            if (TouchScreenScript.GetTouch(out inputVector))
            {
                Ray        ray = localCamera.ScreenPointToRay(inputVector);
                RaycastHit hit;
                if (Physics.Raycast(ray.origin, ray.direction, out hit, Mathf.Infinity, (1 << 8)) && inputOn)
                {
                    if (hit.collider.name == "bike")
                    {
                        inputOn = false;
                        StartSelectionA();
                    }
                    else if (hit.collider.name == "kupla")
                    {
                        inputOn = false;
                        StartSelectionB();
                    }
                    else if (hit.collider.name == "submarine")
                    {
                        inputOn = false;
                        StartSelectionC();
                    }
                    else if (hit.collider.name == "kupla2")
                    {
                        inputOn = false;
                        StartSelectionA();
                    }
                    else if (hit.collider.name == "kupla3")
                    {
                        inputOn = false;
                        StartSelectionA();
                    }
                    else if (hit.collider.name == "train")
                    {
                        inputOn = false;
                        StartSelectionB();
                    }
                    else if (hit.collider.name == "airplane")
                    {
                        inputOn = false;
                        StartSelectionC();
                    }
                    else if (hit.collider.name == "bike2")
                    {
                        inputOn = false;
                        StartSelectionB();
                    }
                    else if (hit.collider.name == "wheelbarrow")
                    {
                        inputOn = false;
                        StartSelectionC();
                    }
                }
            }
        }
    }