RiftMayhem/Assets/Scripts/Player/PlayerDeathVFXManager.cs
Pedro Gomes 5a48a23de1 Cooldown for players & bugfixing
- ability cooldown tracker implemented on players.
- added cooldowns to multiple player spells.
- added cooldown tracking on Ability bind instances, allowing players to see their spell icon on cooldown, filling out.
- fixed melee slash hit vfx, no longer spawning on non-targettable units.
- fixed area of effect over time bug that prevented it deal damage if it was following a target and had "!damagefollowingtarget" flag.
- added callback on blend in /out for death related VFX
2024-07-21 11:05:48 +01:00

137 lines
3.9 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PlayerDeathVFXManager : MonoBehaviour
{
[Header("TextOverlay:")]
[SerializeField] private GameObject cheatedDeathText;
[SerializeField] private GameObject revivedText;
[SerializeField] private GameObject faintedText;
[SerializeField] private GameObject permaDeathText;
[Header("Volumes:")]
[SerializeField] private PlayerDeathVFX cheatedDeathVFX;
[SerializeField] private PlayerDeathVFX faintedVFX;
[SerializeField] private PlayerDeathVFX permaDeathVFX;
[Header("Listeners:")]
[SerializeField] private GameEventListener onLocalPlayerCheatedDeath;
[SerializeField] private GameEventListener onLocalPlayerFainted;
[SerializeField] private GameEventListener onLocalPlayerPermaDeath;
[SerializeField] private GameEventListener onLocalPlayerRevived;
[SerializeField] private GameEventListener_ZoneData onGameSceneLoaded;
private void Awake()
{
onLocalPlayerCheatedDeath.Response.AddListener(OnLocalCheatedDeath);
onLocalPlayerFainted.Response.AddListener(OnLocalFainted);
onLocalPlayerPermaDeath.Response.AddListener(OnLocalPermaDeath);
onLocalPlayerRevived.Response.AddListener(OnLocalPlayerRevived);
onGameSceneLoaded.Response.AddListener((x) => ResetAll());
}
private void ResetAll()
{
cheatedDeathVFX.ResetWeight();
faintedVFX.ResetWeight();
permaDeathVFX.ResetWeight();
cheatedDeathText.SetActive(false);
faintedText.SetActive(false);
permaDeathText.SetActive(false);
revivedText.SetActive(false);
}
private void OnLocalCheatedDeath()
{
EnableCheatedDeathVFX();
faintedVFX.ResetWeight();
permaDeathVFX.ResetWeight();
faintedText.SetActive(false);
permaDeathText.SetActive(false);
revivedText.SetActive(false);
StartCoroutine(FallbackCheatedDeathVFX());
}
IEnumerator FallbackCheatedDeathVFX()
{
yield return new WaitForSeconds(GameConstants.CharacterBalancing.SoloCheatDeathInvulnerabilityDuration);
DisableCheatedDeathVFX();
}
private void OnLocalFainted()
{
cheatedDeathVFX.ResetWeight();
EnableFaintedVFX();
permaDeathVFX.ResetWeight();
cheatedDeathText.SetActive(false);
permaDeathText.SetActive(false);
revivedText.SetActive(false);
}
private void OnLocalPermaDeath()
{
EnablePermaDeathVFX(() =>
{
cheatedDeathVFX.ResetWeight();
faintedVFX.ResetWeight();
});
cheatedDeathText.SetActive(false);
faintedText.SetActive(false);
revivedText.SetActive(false);
}
private void OnLocalPlayerRevived()
{
EnableCheatedDeathVFX();
faintedVFX.ResetWeight();
permaDeathVFX.ResetWeight();
revivedText.SetActive(true);
cheatedDeathText.SetActive(false);
faintedText.SetActive(false);
permaDeathText.SetActive(false);
StartCoroutine(FallbackCheatedDeathVFX());
}
public void EnableCheatedDeathVFX()
{
cheatedDeathVFX.BlendIn();
cheatedDeathText.SetActive(true);
}
public void DisableCheatedDeathVFX()
{
cheatedDeathVFX.BlendOut();
cheatedDeathText.SetActive(false);
revivedText.SetActive(false);
}
public void EnableFaintedVFX()
{
faintedVFX.BlendIn();
faintedText.SetActive(true);
}
public void DisableFaintedVFX()
{
faintedVFX.BlendOut();
faintedText.SetActive(false);
}
public void EnablePermaDeathVFX(Action callback = null)
{
permaDeathVFX.BlendIn(callback);
permaDeathText.SetActive(true);
}
public void DisablePermaDeathVFX()
{
permaDeathVFX.BlendOut();
permaDeathText.SetActive(false);
}
}