2022-02-09 21:22:43 +03:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
2022-02-11 20:15:57 +03:00
|
|
|
using UnityEngine.UI;
|
2022-02-09 21:22:43 +03:00
|
|
|
|
|
|
|
public class LibraryEffects : MonoBehaviour
|
|
|
|
{
|
|
|
|
public static LibraryEffects main;
|
|
|
|
|
2022-02-11 20:15:57 +03:00
|
|
|
public Dictionary<string, Sprite> effectsIcon = new Dictionary<string, Sprite>();
|
|
|
|
public GameObject effectPrefab;
|
|
|
|
|
|
|
|
[System.Serializable]
|
|
|
|
public class IconsEffects
|
|
|
|
{
|
|
|
|
public string name;
|
|
|
|
public Sprite icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IconsEffects[] effectIcons;
|
|
|
|
|
|
|
|
|
2022-02-09 21:22:43 +03:00
|
|
|
public void Start()
|
|
|
|
{
|
|
|
|
main = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Poison(GameObject _enemy, int _damage)
|
|
|
|
{
|
2022-02-11 20:15:57 +03:00
|
|
|
for (int i = 0; i < effectIcons.Length; i++)
|
|
|
|
{
|
|
|
|
if(effectIcons[i].name == "poison")
|
|
|
|
{
|
|
|
|
effectPrefab.GetComponentInChildren<Image>().sprite = effectIcons[i].icon;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
effectPrefab.GetComponentInChildren<Text>().text = _damage.ToString();
|
2022-02-09 21:22:43 +03:00
|
|
|
_enemy.GetComponent<Enemy>().ChangeHp(_damage);
|
2022-02-11 20:15:57 +03:00
|
|
|
GameObject link = Instantiate(effectPrefab, _enemy.transform);
|
|
|
|
_enemy.GetComponent<Enemy>().effectsLink.Add(link);
|
2022-02-09 21:22:43 +03:00
|
|
|
}
|
|
|
|
}
|