示例#1
0
    public void Init()
    {
        gameObject.SetActive(true);

        RenderSettings.ambientLight = AmbientColor;
        Sfx sfx = FindObjectOfType <Sfx>();

        sfx.MusicAudioSource.volume = HasBackgroundNoise ? Sfx.BaseMusicVolume : 0f;
        sfx.CinemaClick();

        foreach (TriggerBase tb in GetComponentsInChildren <TriggerBase>())
        {
            tb.ResetTrigger();
        }

        Ui ui = FindObjectOfType <Ui>();

        if (HasTransitionFlash)
        {
            ui.TransitionFlash();
        }
        if (HasGlitch)
        {
            ui.ClearFlash();
            const float glitchDuration = 0.5f;
            ui.Glitch(glitchDuration);
            sfx.Glitch(glitchDuration);
        }

        Player player = FindObjectOfType <Player>();

        player.ResetAt(PlayerStart);
        Usher usher = FindObjectOfType <Usher>();

        if (usher != null)
        {
            usher.IsLookingAtPlayer = IsUsherLookingAtPlayer;
            usher.SpookState        = IsUsherSpookyWhenVisible ? UsherSpookState.WaitingToTeleport : UsherSpookState.None;
        }

        UnityEngine.GameObject artworkSlots = UnityEngine.GameObject.Find("ArtworkSlots");
        if (artworkSlots != null)
        {
            Debug.Assert(artworkSlots.transform.childCount == 4);

            for (int i = 0; i < artworkSlots.transform.childCount; i++)
            {
                Transform slot         = artworkSlots.transform.GetChild(i);
                Material  slotMaterial = slot.GetComponent <MeshRenderer>().material;
                slotMaterial.SetTexture("_MainTex", Posters[i]);
            }
        }
    }