Example #1
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);
        }
    }