using System.Collections; using System.Collections.Generic; using Unity.Mathematics; using UnityEngine; public class DamageBlock : MonoBehaviour { public int MinDamage; public int MaxDamage; public bool Heal; private void OnTriggerEnter2D(Collider2D collision) { if(collision.tag == "Player") { if(Heal) { int damage = UnityEngine.Random.Range(MinDamage, MaxDamage); collision.gameObject.GetComponent().Lives +=damage; }else{ int damage = UnityEngine.Random.Range(MinDamage, MaxDamage); int FinDamage = (damage - GameObject.Find("BodyPlayer").GetComponent().HeadArmorSafe); if(FinDamage <0){FinDamage = 0;} collision.gameObject.GetComponent().Lives -=FinDamage; } } } }