12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Sirenix.OdinInspector;
- using KairoEngine.Core;
- namespace KairoEngine.CharacterSystem
- {
- public class FloatingValuesController : MonoBehaviour
- {
- public GameObject floatingValueUiPrefab;
- public Transform canvasParent;
- void OnEnable()
- {
- DamageEvents.OnDamage += OnDamage;
- DamageEvents.OnHeal += OnHeal;
- FloatingMessageEvents.OnMessage += OnMessage;
- }
- void OnDisable()
- {
- DamageEvents.OnDamage -= OnDamage;
- DamageEvents.OnHeal -= OnHeal;
- FloatingMessageEvents.OnMessage -= OnMessage;
- }
- private void OnDamage(DamageData damageData)
- {
- GameObject obj = Instantiate(floatingValueUiPrefab, canvasParent);
- obj.GetComponent<FloatingValueUi>().Setup(damageData.damageController.transform.position, "-" + damageData.damage.ToString());
- }
- private void OnHeal(DamageController damageController, int heal)
- {
- GameObject obj = Instantiate(floatingValueUiPrefab, canvasParent);
- obj.GetComponent<FloatingValueUi>().Setup(damageController.transform.position, "+" + heal.ToString());
- }
- private void OnMessage(string message, Vector3 pos, float offset, float time, float fontSize)
- {
- GameObject obj = Instantiate(floatingValueUiPrefab, canvasParent);
- obj.GetComponent<FloatingValueUi>().Setup(pos, message, 1.2f);
- }
- }
- }
|