using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class LibraryEffects : MonoBehaviour { public static LibraryEffects main; public Dictionary effectsIcon = new Dictionary(); public GameObject effectPrefab; [System.Serializable] public class IconsEffects { public string name; public Sprite icon; } public IconsEffects[] effectIcons; public void Start() { main = this; } public void Poison(GameObject _enemy, int _damage) { for (int i = 0; i < effectIcons.Length; i++) { if(effectIcons[i].name == "poison") { effectPrefab.GetComponentInChildren().sprite = effectIcons[i].icon; } } effectPrefab.GetComponentInChildren().text = _damage.ToString(); _enemy.GetComponent().ChangeHp(_damage); GameObject link = Instantiate(effectPrefab, _enemy.transform); _enemy.GetComponent().effectsLink.Add(link); } }