Files
2025-05-29 22:31:40 +03:00

68 lines
2.3 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.ParticleSystemJobs;
public class GhostReveal : MonoBehaviour
{
[SerializeField] private GameObject[] _lightΒulb;
[SerializeField] private Light[] _light;
[SerializeField] private GameObject _revealGhostLightGO;
[SerializeField] private Light[] _revealGhostLights;
[SerializeField] private Renderer[] _lightRend;
[SerializeField] private ParticleSystem[] _sparklesParticle;
[Header("GhostAnimator")] //Change that later to a manager instance.
[SerializeField] private Animator _GhostAnimator;
private void Start()
{
_revealGhostLights = _revealGhostLightGO.GetComponentsInChildren<Light>();
_lightRend[6].material.DisableKeyword("_EMISSION");
}
private void OnTriggerEnter(Collider col)
{
if(col.gameObject.tag == "Player")
{
StartCoroutine(GhostRevealLights());
}
}
IEnumerator GhostRevealLights()
{
_lightΒulb[0].SetActive(false);
_lightRend[0].material.DisableKeyword("_EMISSION");
_sparklesParticle[0].Play();
yield return new WaitForSeconds(0.5f);
_lightΒulb[1].SetActive(false);
_lightRend[1].material.DisableKeyword("_EMISSION");
_sparklesParticle[1].Play();
yield return new WaitForSeconds(0.5f);
_lightΒulb[2].SetActive(false);
_lightRend[2].material.DisableKeyword("_EMISSION");
_sparklesParticle[2].Play();
yield return new WaitForSeconds(0.5f);
_lightΒulb[3].SetActive(false);
_lightRend[3].material.DisableKeyword("_EMISSION");
_sparklesParticle[3].Play();
yield return new WaitForSeconds(0.5f);
_lightΒulb[4].SetActive(false);
_lightRend[4].material.DisableKeyword("_EMISSION");
_sparklesParticle[4].Play();
yield return new WaitForSeconds(0.5f);
_lightΒulb[5].SetActive(false);
_lightRend[5].material.DisableKeyword("_EMISSION");
_sparklesParticle[5].Play();
yield return new WaitForSeconds(4f);
foreach (Light light in _revealGhostLights) //Reveal Ghost lights enabled.
{
light.enabled = true;
}
_lightRend[6].material.EnableKeyword("_EMISSION");
_GhostAnimator.SetBool("IsRevealed", true);
}
}