Button to deal damage to random participant
This commit is contained in:
parent
778228bc6b
commit
581d9d7811
2 changed files with 15 additions and 2 deletions
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,10 @@ public class BattleParticipant
|
||||||
protected int hp;
|
protected int hp;
|
||||||
protected int maxHP;
|
protected int maxHP;
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
this.hp = this.maxHP;
|
||||||
|
}
|
||||||
|
|
||||||
public string getDisplayName() {
|
public string getDisplayName() {
|
||||||
return this.displayName;
|
return this.displayName;
|
||||||
}
|
}
|
||||||
|
|
@ -20,7 +24,8 @@ public class BattleParticipant
|
||||||
return this.maxHP;
|
return this.maxHP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void dealDamage(int damage) {
|
||||||
this.hp = this.maxHP;
|
this.hp -= damage;
|
||||||
|
if (this.hp < 0) this.hp = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue