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) { _enemy.GetComponent().ChangeHp(_damage); } public void Stun(GameObject _enemy) { _enemy.GetComponent().hasStun = true; } public void InstantiateEffect(string _name, GameObject _parent, int _damageText) { for (int i = 0; i < effectIcons.Length; i++) { if (effectIcons[i].name == _name) { effectPrefab.GetComponentInChildren().sprite = effectIcons[i].icon; } } var _move = new Vector3(520, -369, 0); effectPrefab.GetComponentInChildren().text = _damageText.ToString(); GameObject link = Instantiate(effectPrefab, _parent.transform); link.transform.localPosition = _move; _parent.GetComponent().effectsLink.Add(link); } }