- 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
72 lines
2.0 KiB
C#
72 lines
2.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class AbilityBindInstance : MonoBehaviour
|
|
{
|
|
public GameKey gameKey;
|
|
|
|
[SerializeField] private GameEventListener_AbilityKeyBinder onAbilityKeyBinderSpawned;
|
|
public TMP_Text bind;
|
|
public TMP_Text manaCost;
|
|
public Image icon;
|
|
public GameObject noMana;
|
|
public GameObject pressed;
|
|
public Image coolDown;
|
|
|
|
[Header("Set by Code:")]
|
|
public AbilityKeyBinder abilityKeyBinder;
|
|
|
|
private void Awake()
|
|
{
|
|
onAbilityKeyBinderSpawned.Response.AddListener(InitializeAbilityBindInstance);
|
|
}
|
|
|
|
public void InitializeAbilityBindInstance(AbilityKeyBinder abilityKeyBinder)
|
|
{
|
|
if (abilityKeyBinder.GameKey != gameKey) return;
|
|
|
|
this.abilityKeyBinder = abilityKeyBinder;
|
|
string keyName = gameKey.keyCode.ToString();
|
|
//alpha
|
|
keyName = keyName.Remove(0, 5);
|
|
this.bind.text = keyName;
|
|
this.manaCost.text = abilityKeyBinder.Ability.manaCost.ToString();
|
|
this.icon.sprite = abilityKeyBinder.Ability.Icon;
|
|
noMana.SetActive(false);
|
|
pressed.SetActive(false);
|
|
coolDown.fillAmount = 1;
|
|
coolDown.gameObject.SetActive(false);
|
|
|
|
abilityKeyBinder.SetupAbilityBindInstance(this);
|
|
}
|
|
|
|
public void StartCooldownTrackerUI()
|
|
{
|
|
StartCoroutine(UIAbilityCooldownTracking());
|
|
}
|
|
|
|
float cooldownTime;
|
|
float elapsedTime;
|
|
IEnumerator UIAbilityCooldownTracking()
|
|
{
|
|
cooldownTime = abilityKeyBinder.Ability.cooldown;
|
|
elapsedTime = 0f;
|
|
|
|
coolDown.fillAmount = 1f;
|
|
coolDown.gameObject.SetActive(true);
|
|
|
|
while (elapsedTime < cooldownTime)
|
|
{
|
|
elapsedTime += Time.deltaTime;
|
|
coolDown.fillAmount = 1f - (elapsedTime / cooldownTime);
|
|
yield return null;
|
|
}
|
|
|
|
coolDown.fillAmount = 0f;
|
|
coolDown.gameObject.SetActive(false);
|
|
}
|
|
}
|