84 lines
2.1 KiB
C#
84 lines
2.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DamageNumbersPro;
|
|
using DamageNumbersPro.Demo;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class MRDamage : MonoBehaviour
|
|
{
|
|
public static MRDamage Ins;
|
|
|
|
DamageNumber[] prefabs;
|
|
int currentIndex;
|
|
DNP_PrefabSettings currentSettings;
|
|
|
|
Text currentPrefabText;
|
|
Text currentIndexText;
|
|
|
|
CanvasGroup fade;
|
|
|
|
void Awake()
|
|
{
|
|
Ins = this;
|
|
|
|
Transform parent = GameObject.Find("Special").transform.Find("Prefabs/Damage Numbers");
|
|
prefabs = new DamageNumber[parent.childCount];
|
|
for (int n = 0; n < parent.childCount; n++)
|
|
{
|
|
prefabs[n] = parent.GetChild(n).GetComponent<DamageNumber>();
|
|
}
|
|
parent.gameObject.SetActive(false);
|
|
|
|
//Text Components:
|
|
Transform guiParent = GameObject.Find("Special").transform.Find("GUI");
|
|
currentPrefabText = guiParent.Find("Background/Current").GetComponent<Text>();
|
|
currentIndexText = guiParent.Find("Background/Index").GetComponent<Text>();
|
|
|
|
Transform fadeTransform = transform.Find("GUI/Fade");
|
|
if (fadeTransform != null)
|
|
{
|
|
fade = fadeTransform.GetComponent<CanvasGroup>();
|
|
}
|
|
|
|
//Reset Index:
|
|
currentIndex = 0;
|
|
UpdateCurrent();
|
|
|
|
#if !UNITY_EDITOR && UNITY_WEBGL
|
|
WebGLInput.captureAllKeyboardInput = true;
|
|
#endif
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
if (fade != null)
|
|
{
|
|
fade.alpha = 1f;
|
|
}
|
|
}
|
|
|
|
void UpdateCurrent()
|
|
{
|
|
currentPrefabText.text = "➞ " + prefabs[currentIndex].name;
|
|
currentIndexText.text = (currentIndex + 1) + "/" + prefabs.Length;
|
|
|
|
currentSettings = prefabs[currentIndex].GetComponent<DNP_PrefabSettings>();
|
|
}
|
|
|
|
public DamageNumber GetCurrent()
|
|
{
|
|
return prefabs[currentIndex];
|
|
}
|
|
|
|
public DNP_PrefabSettings GetSettings()
|
|
{
|
|
if (currentSettings == null)
|
|
{
|
|
currentSettings = prefabs[currentIndex].gameObject.AddComponent<DNP_PrefabSettings>();
|
|
}
|
|
|
|
return currentSettings;
|
|
}
|
|
}
|