Exemple #1
0
    void Update()
    {
        if (!flag)
        {
            if (erko)
            {
                door.GetComponent <BoxCollider>().enabled = false;
                doorScript.ChangeDoorState();

                bellSoundSource.Play();
                flag = true;
            }
        }
    }
    void Update()
    {
        if (Input.GetKey(KeyCode.E))
        {
            Ray        ray = new Ray(transform.position, transform.forward);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, interactDistance))
            {
                if (hit.collider.CompareTag("Door"))
                {
                    DoorScript doorScript = hit.collider.transform.parent.GetComponent <DoorScript>();
                    if (doorScript == null)
                    {
                        return;
                    }

                    if (Inventory.keys[doorScript.index] == true)
                    {
                        doorScript.ChangeDoorState();
                    }
                }
                else if (hit.collider.CompareTag("Key"))
                {
                    Inventory.keys[hit.collider.GetComponent <Key>().index] = true;
                    Destroy(hit.collider.gameObject);
                }
            }
        }
    }
Exemple #3
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            Ray        ray = new Ray(transform.position, transform.forward);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, interactDistance))
            {
                if (hit.collider.CompareTag("HouseScene"))
                {
                    if (SceneManager.GetActiveScene().name.Equals("Game"))
                    {
                        SaveState();
                    }
                    SceneManager.LoadScene("Inside");
                }
                else if (hit.collider.CompareTag("Door"))
                {
                    DoorScript doorScript = hit.collider.transform.parent.GetComponent <DoorScript>();


                    if (doorScript == null)
                    {
                        return;
                    }

                    if (doorScript.name == "hinge")
                    {
                        doorScript.ChangeDoorState();
                        return;
                    }

                    pauseController notDoor = GameObject.Find("PauseMenuController").GetComponent <pauseController> ();

                    if (inventory != null && inventory.keys [doorScript.index] == true)
                    {
                        doorScript.ChangeDoorState();
                    }
                    else if (doorScript.index == 3)
                    {
                        notDoor.BadDoorNot();
                    }
                    else
                    {
                        notDoor.GoodDoorNot();
                    }
                }
                else if (hit.collider.CompareTag("Key"))
                {
                    if (inventory != null)
                    {
                        if (hit.collider.gameObject.name == "Key1")
                        {
                            inventory.keys [1] = true;
                        }
                        else if (hit.collider.gameObject.name == "Key2")
                        {
                            inventory.keys [2] = true;
                        }
                        else if (hit.collider.gameObject.name == "Key3")
                        {
                            inventory.keys [3] = true;
                        }
                    }
                    AudioSource.PlayClipAtPoint(keyPickup, hit.collider.transform.position);
                    Destroy(hit.collider.gameObject);
                }
                else if (hit.collider.CompareTag("NextLeveldoor"))
                {
                    if (SceneManager.GetActiveScene().name.Equals("Inside"))
                    {
                        SaveState();
                    }
                    SceneManager.LoadScene("Game");
                }


                else if (hit.collider.CompareTag("Rock"))
                {
                    Debug.Log(hit.collider.name);
                    if (papers)
                    {
                        Debug.Log("in paper");

                        CollectPaper paperScript = papers.GetComponent <CollectPaper>();
                        if (paperScript.papers >= paperScript.papersToWin)
                        {
                            Destroy(GameObject.Find("PlayerState"));
                            SceneManager.LoadScene("Win");
                        }
                    }
                }
            }
        }
    }
Exemple #4
0
    // Update is called once per frame
    void Update()
    {
        //numberOfKeys.text = keys.ToString();
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            Ray        ray = new Ray(transform.position, transform.forward);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, length))
            {
                if (hit.collider.CompareTag("Door"))
                {
                    DoorScript doorScript = hit.collider.transform.parent.GetComponent <DoorScript>();

                    if (doorScript == null)
                    {
                        return;
                    }

                    if (Inventory.keys[doorScript.index] == true)
                    {
                        doorScript.ChangeDoorState();
                        FindObjectOfType <AudioManager>().Play("OpenDoor");
                    }
                    else
                    {
                        FindObjectOfType <AudioManager>().Play("LockedDoor");
                    }

                    //Debug.Log("Colidi");
                    //player.ChangeCameraStateTrue();
                }

                else if (hit.collider.CompareTag("FinalDoor"))
                {
                    DoorScript doorScript = hit.collider.transform.parent.GetComponent <DoorScript>();

                    if (doorScript == null)
                    {
                        return;
                    }

                    if (Inventory.keys[doorScript.index] == true && soundEmitter >= 4 && imagePuzzle.valorFinal == 5)
                    {
                        doorScript.ChangeDoorState();
                        FindObjectOfType <AudioManager>().Play("OpenDoor");
                    }
                    else
                    {
                        FindObjectOfType <AudioManager>().Play("LockedDoor");
                        if (!textIsOnScreen)
                        {
                            textIsOnScreen = true;
                            finalDoorText.SetActive(true);
                            StartCoroutine(WaitForSec());
                        }
                    }

                    Debug.Log("Colidi");
                    //player.ChangeCameraStateTrue();
                }
                else if (hit.collider.CompareTag("Key"))
                {
                    Inventory.keys[hit.collider.GetComponent <KeyScript>().index] = true;
                    if (!textIsOnScreen)
                    {
                        textIsOnScreen = true;
                        uiObject.SetActive(true);
                        StartCoroutine("WaitForSec");
                    }
                    //Debug.Log("ColidiCarai");
                    //Destroy(gameObject);
                    FindObjectOfType <AudioManager>().Play("GetKey");

                    KeyScript keyScript = hit.collider.transform.GetComponent <KeyScript>();
                    keyScript.DestroyKey();
                    keys++;
                }

                //Interactable intercactable = hit.collider.GetComponent<Interactable>();

                else if (hit.collider.CompareTag("AnimInteractable"))
                {
                    PlayAnimation animation = hit.collider.transform.GetComponent <PlayAnimation>();
                    animation.AnimPlay();
                    Debug.Log("TaFuncionando"); //Não ta funcionando ;-; T-T
                }

                else if (hit.collider.CompareTag("Sink") && isCarryingWater == false)
                {
                    if (waterIsWorking)
                    {
                        isCarryingWater = true;
                        Debug.Log("PEGUEI A AGUA");
                        if (!textIsOnScreen)
                        {
                            textIsOnScreen = true;
                            uiObject2.SetActive(true);
                            StartCoroutine("WaitForSec");
                        }
                        glassIcon.SetActive(true);
                        trigger2.SetActive(true);
                    }
                    else
                    {
                        if (!textIsOnScreen)
                        {
                            textIsOnScreen = true;
                            uiObject3.SetActive(true);
                            StartCoroutine("WaitForSec");
                        }
                    }
                }

                else if (hit.collider.CompareTag("Fire"))
                {
                    if (isCarryingWater == true)
                    {
                        FireScript fireParticles = hit.collider.transform.GetComponent <FireScript>();
                        fireParticles.DestroyFire();
                        Debug.Log("APAGUEI O FOGO");
                        glassIcon.SetActive(false);
                        xGlassIcon.SetActive(true);
                        fireplaceKey.SetActive(true);
                        isCarryingWater = false;
                    }

                    else
                    {
                        if (!textIsOnScreen)
                        {
                            textIsOnScreen = true;
                            text3.SetActive(true);
                            StartCoroutine("WaitForSec");
                        }
                    }
                }

                else if (hit.collider.CompareTag("Regulator") && waterIsWorking == false)
                {
                    waterIsWorking = true;
                    Debug.Log("LIGUEI O REGISTRO");
                    if (!textIsOnScreen)
                    {
                        textIsOnScreen = true;
                        text.SetActive(true);
                        StartCoroutine("WaitForSec");
                    }
                    kitchenTable.SetActive(true);
                    normalTable.SetActive(false);
                    kitchenWater.SetActive(true);
                    //PoisonedWaterScript blackWater = hit.collider.transform.GetComponent<PoisonedWaterScript>();
                    //blackWater.DestroyWater();
                    //Debug.Log("RIP AGUA DA MORTE");
                    //waterTankKey.SetActive(true);
                    //normalWater.SetActive(true);
                    //fallingWater.SetActive(true);
                }

                else if (hit.collider.CompareTag("PoisonedWater"))
                {
                    if (waterIsWorking)
                    {
                        PoisonedWaterScript blackWater = hit.collider.transform.GetComponent <PoisonedWaterScript>();
                        blackWater.DestroyWater();
                        Debug.Log("RIP AGUA DA MORTE");
                        waterTankKey.SetActive(true);
                        normalWater.SetActive(true);
                        fallingWater.SetActive(true);
                    }

                    else
                    {
                        if (!textIsOnScreen)
                        {
                            textIsOnScreen = true;
                            text2.SetActive(true);
                            StartCoroutine("WaitForSec");
                        }
                    }
                }

                else if (hit.collider.CompareTag("MovableFloor"))
                {
                    FloorScript floor = hit.collider.transform.GetComponent <FloorScript>();
                    floor.DestroyFloor();
                    //secretCompartmentKey.SetActive(true);
                }

                else if (hit.collider.CompareTag("Text"))
                {
                    PrintMessage text = hit.collider.transform.GetComponent <PrintMessage>();

                    if (!textIsOnScreen)
                    {
                        textIsOnScreen = true;
                        text.ShowText();
                        StartCoroutine(WaitForSec());
                    }
                    //text.TextOnScreen();
                }

                // if (hit.collider.gameObject.name == "Boiler")
                // {
                // boiler.SetActive(false);
                //}

                else if (hit.collider.CompareTag("RightDoor"))
                {
                    DoorScript doorScript = hit.collider.transform.parent.GetComponent <DoorScript>();

                    if (doorScript == null)
                    {
                        return;
                    }
                    else
                    {
                        doorScript.PuzzleDoor();
                        pm.canMove = false;
                        StartCoroutine(WrongDoorEvent());
                        FindObjectOfType <AudioManager>().Play("OpenDoor");
                        FindObjectOfType <AudioManager>().Play("Right");
                        doorScript.ChangeGroup();
                    }

                    //player.ChangeCameraStateTrue();
                }

                else if (hit.collider.CompareTag("WrongDoor"))
                {
                    DoorScript doorScript = hit.collider.transform.parent.GetComponent <DoorScript>();

                    if (doorScript == null)
                    {
                        return;
                    }
                    else
                    {
                        Debug.Log(pm.transform.position);
                        doorScript.PuzzleDoor();
                        pm.canMove = false;
                        StartCoroutine(WrongDoorEvent());
                        FindObjectOfType <AudioManager>().Play("OpenDoor");
                        FindObjectOfType <AudioManager>().Play("Wrong");
                        //pm.SetPlayerSpeed(5);
                    }

                    //player.ChangeCameraStateTrue();
                }

                else if (hit.collider.CompareTag("SoundPuzzle"))
                {
                    Inventory.soundPuzzleObjects[hit.collider.GetComponent <SoundPuzzleScript>().index] = true;

                    SoundPuzzleScript soundPuzzle = hit.collider.transform.GetComponent <SoundPuzzleScript>();
                    soundPuzzle.ActivateIcon();
                    soundPuzzle.AddIndex();
                    soundPuzzle.DestroyObject();
                    uiObject4.SetActive(true);
                    FindObjectOfType <AudioManager>().Play("GetKey");
                    StartCoroutine("WaitForSec");
                    // soundEmitter++;
                }

                else if (hit.collider.CompareTag("NoiseEmitter"))
                {
                    NoiseEmitterScript noiseEmitterScript = hit.collider.transform.GetComponent <NoiseEmitterScript>();

                    if (noiseEmitterScript == null)
                    {
                        return;
                    }


                    if (Inventory.soundPuzzleObjects[noiseEmitterScript.index] == true)
                    {
                        soundEmitter++;
                        noiseEmitterScript.ActivateObject();
                        print(soundEmitter);
                        FindObjectOfType <AudioManager>().Play("Right");
                    }
                }
                // =======================Xylophone========================

                if (hit.collider.name == "XyloA")
                {
                    FindObjectOfType <AudioManager>().Play("XyloA");
                }

                if (hit.collider.name == "XyloB")
                {
                    FindObjectOfType <AudioManager>().Play("XyloB");
                }

                if (hit.collider.name == "XyloC")
                {
                    FindObjectOfType <AudioManager>().Play("XyloC");
                }

                if (hit.collider.name == "XyloD")
                {
                    FindObjectOfType <AudioManager>().Play("XyloD");
                }

                if (hit.collider.name == "XyloE")
                {
                    FindObjectOfType <AudioManager>().Play("XyloE");
                }

                if (hit.collider.name == "XyloF")
                {
                    FindObjectOfType <AudioManager>().Play("XyloF");
                }

                if (hit.collider.name == "XyloG")
                {
                    FindObjectOfType <AudioManager>().Play("XyloG");
                }
            }
        }

        if (soundEmitter == 4)
        {
            painting.SetActive(true);
        }
    }
Exemple #5
0
    private void OnTriggerEnter(Collider collision)
    {
        if (collision.gameObject.name == "BathroomJumpscareTrigger")
        {
            ghost.SetActive(true);
            canMove = false;
            FindObjectOfType <AudioManager>().Play("Scream");
            Destroy(trigger);
            Debug.Log("JUMPSCARE");
            camera.ChangeCameraStateTrue();
            StartCoroutine("JumpscareTimer");
        }

        if (collision.gameObject.name == "LivingRoomGhostTrigger")
        {
            ghost2.SetActive(true);
            Destroy(trigger1);
        }

        if (collision.gameObject.name == "KitchenGhostTrigger")
        {
            ghost3.SetActive(true);
            Destroy(trigger2);
        }

        if (collision.gameObject.name == "BedroomKnockingJumpscareTrigger")
        {
            FindObjectOfType <AudioManager>().Play("Knock");
            Destroy(trigger3);
        }

        if (collision.gameObject.name == "ChairsTrigger")
        {
            chairs.SetActive(true);
            diningTable.SetActive(false);
            modernTable.SetActive(true);
            dropTrigger.SetActive(true);
            Destroy(trigger4);
        }
        if (collision.gameObject.name == "WinConditionTrigger")
        {
            SceneManager.LoadScene("Menu");
        }

        if (collision.gameObject.name == "CorridorTrigger1" || collision.gameObject.name == "CorridorTrigger2")
        {
            if (doorScript.open == true)
            {
                doorScript.ChangeDoorState();
                FindObjectOfType <AudioManager>().Play("Slam");
                StartCoroutine(LockDoor());
                StartCoroutine(DestroyDoor());
            }
            else
            {
                StartCoroutine(LockDoor());
                StartCoroutine(DestroyDoor());
            }

            corridorTrigger1.SetActive(false);
            corridorTrigger2.SetActive(false);
            spotlightsTrigger.SetActive(true);
        }

        if (collision.gameObject.name == "SpotlightsTrigger" && stic.valorFinal != 5)
        {
            spotlights.SetActive(true);
            FindObjectOfType <AudioManager>().Play("BigSwitch");
            Destroy(spotlightsTrigger);
        }

        if (collision.gameObject.name == "DropTrigger")
        {
            rb1.useGravity = true;
            ro1.ySpeed     = 0f;
            rb2.useGravity = true;
            ro2.ySpeed     = 0f;
            StartCoroutine(DropSound());
            Destroy(dropTrigger);
        }
    }