27 lines
897 B
C#
Executable file
27 lines
897 B
C#
Executable file
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<Move>().Lives +=damage;
|
|
}else{
|
|
int damage = UnityEngine.Random.Range(MinDamage, MaxDamage);
|
|
int FinDamage = (damage - GameObject.Find("BodyPlayer").GetComponent<ArmorOnPlayer>().HeadArmorSafe);
|
|
if(FinDamage <0){FinDamage = 0;}
|
|
collision.gameObject.GetComponent<Move>().Lives -=FinDamage;
|
|
}
|
|
}
|
|
}
|
|
}
|