From 80b3eb0dc76c194d479e48d5c2e593eccb7db07a Mon Sep 17 00:00:00 2001 From: vylion Date: Sat, 29 Oct 2016 03:21:58 +0200 Subject: [PATCH] Added critical hit boolean check and unit receiveDamage function --- Assets/UnitBehaviour.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Assets/UnitBehaviour.cs b/Assets/UnitBehaviour.cs index 89bdd61..b151bb0 100644 --- a/Assets/UnitBehaviour.cs +++ b/Assets/UnitBehaviour.cs @@ -64,10 +64,21 @@ public class UnitBehaviour : MonoBehaviour { attackElem = e; } - bool attack() { + bool attackHit() { return (Random.Range (0, 100) < precision); } + bool criticalHit() { + return (Random.Range (0, 100) < critChance); + } + + void receiveDamage(int damage) { + if (health <= damage) + Die (); + else + health -= damage; + } + // Use this for initialization void Start () {