- 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
68 lines
1.7 KiB
C#
68 lines
1.7 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Rendering.PostProcessing;
|
|
|
|
public class PlayerDeathVFX : MonoBehaviour
|
|
{
|
|
PostProcessVolume postProcess;
|
|
|
|
public float blendDuration = 0.5f;
|
|
|
|
private Coroutine blendCoroutine;
|
|
|
|
private void Awake()
|
|
{
|
|
postProcess = GetComponent<PostProcessVolume>();
|
|
}
|
|
|
|
public void BlendIn(Action callback = null)
|
|
{
|
|
StopBlendCoroutine();
|
|
blendCoroutine = StartCoroutine(BlendWeight(0f, 1f, blendDuration, callback));
|
|
}
|
|
|
|
public void BlendOut(Action callback = null)
|
|
{
|
|
StopBlendCoroutine();
|
|
blendCoroutine = StartCoroutine(BlendWeight(1f, 0f, blendDuration, callback));
|
|
}
|
|
|
|
public void ResetWeight()
|
|
{
|
|
postProcess.weight = 0;
|
|
}
|
|
|
|
public void BlendTo(float targetWeight, Action callback = null)
|
|
{
|
|
StopBlendCoroutine();
|
|
blendCoroutine = StartCoroutine(BlendWeight(postProcess.weight, targetWeight, blendDuration, callback));
|
|
}
|
|
|
|
private IEnumerator BlendWeight(float startWeight, float endWeight, float duration, Action callback = null)
|
|
{
|
|
float elapsedTime = 0f;
|
|
|
|
while (elapsedTime < duration)
|
|
{
|
|
elapsedTime += Time.deltaTime;
|
|
float t = Mathf.Clamp01(elapsedTime / duration);
|
|
postProcess.weight = Mathf.Lerp(startWeight, endWeight, t);
|
|
yield return null;
|
|
}
|
|
|
|
postProcess.weight = endWeight;
|
|
if (callback != null)
|
|
callback.Invoke();
|
|
}
|
|
|
|
private void StopBlendCoroutine()
|
|
{
|
|
if (blendCoroutine != null)
|
|
{
|
|
StopCoroutine(blendCoroutine);
|
|
}
|
|
}
|
|
}
|