diff --git a/Assets/Battle/BattleController.cs b/Assets/Battle/BattleController.cs index c660558..17ff644 100644 --- a/Assets/Battle/BattleController.cs +++ b/Assets/Battle/BattleController.cs @@ -61,4 +61,12 @@ public class BattleController : MonoBehaviour { } + + public void HitRandomParticipant() { + if (Random.Range(0f, 1f) < 0.5f) { + heroes[Random.Range(0, heroes.Length)].dealDamage(1); + } else { + monsters[Random.Range(0, monsters.Length)].dealDamage(2); + } + } } diff --git a/Assets/Battle/BattleParticipant.cs b/Assets/Battle/BattleParticipant.cs index 83439b7..ebe1efe 100644 --- a/Assets/Battle/BattleParticipant.cs +++ b/Assets/Battle/BattleParticipant.cs @@ -8,6 +8,10 @@ public class BattleParticipant protected int hp; protected int maxHP; + public void init() { + this.hp = this.maxHP; + } + public string getDisplayName() { return this.displayName; } @@ -20,7 +24,8 @@ public class BattleParticipant return this.maxHP; } - public void init() { - this.hp = this.maxHP; + public void dealDamage(int damage) { + this.hp -= damage; + if (this.hp < 0) this.hp = 0; } }