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; public enum CardEffects { poison, stun }; [System.Serializable] public class IconsEffects { public CardEffects name; public Sprite icon; } public IconsEffects[] effectIcons; public void Start() { main = this; } public void Poison(GameObject _enemy, int _damage) { if (_enemy.name == "Player(Clone)") { _enemy.GetComponent().ChangeHp(_damage); } else { _enemy.GetComponent().ChangeHp(_damage); } } public void Stun(GameObject _enemy) { if (_enemy.name == "Player(Clone)") { _enemy.GetComponent().hasStun = true; } else { _enemy.GetComponent().hasStun = true; } } public void InstantiateEffect(string _name, GameObject _parent, int _damageText, int _numInColumn) { for (int i = 0; i < effectIcons.Length; i++) { if (effectIcons[i].name.ToString() == _name) { effectPrefab.GetComponentInChildren().sprite = effectIcons[i].icon; } } effectPrefab.GetComponentInChildren().text = _damageText.ToString(); GameObject link = Instantiate(effectPrefab, _parent.transform); if (_parent.name == "Player(Clone)") { var _move = new Vector3(185, 86 - 100 * _numInColumn, 0); link.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f); link.transform.localPosition = _move; _parent.GetComponent().effectsLink.Add(link); } else { var _move = new Vector3(520, -369 - 300 * _numInColumn, 0); link.transform.localPosition = _move; _parent.GetComponent().effectsLink.Add(link); } } }