I am trying to update "Player's health." when "Player" attacks a target. Player's health is reduced based on the target's return damage.
My Game class (where the label is):
public partial class Game : Form
{
public static Wizard wizard;
public static Assasin assasin;
public Game()
{
InitializeComponent();
}
private void Battle_Click(object sender, EventArgs e)
{
Battle battle = new Battle();
battle.Show();
}
public void Game_Load(object sender, EventArgs e)
{
NameLabel.Text = HeroMaker.className;
if (HeroMaker.wizardChoosen)
{
wizard = new Wizard(HeroMaker.className);
HealthLabel.Text = wizard.Health.ToString();
DamageLabel.Text = wizard.AttackDamage.ToString();
HealthBar.Maximum = wizard.Health;
HealthBar.Value = wizard.Health;
}
}
}
My Battle class (when attacking is happening) :
public partial class Battle : Form
{
Creature troll = CreaturesFactory.CreateCreature(CreatureType.Troll);
public Battle()
{
InitializeComponent();
}
private void AttackTroll_Click(object sender, EventArgs e)
{
Game.wizard.Health -= troll.ReturnDamage;
//TODO: Update the "HealthLabel value."
}
}
The problem is that when I attack the troll, Player's health is decreasing but its not updating on the label. Thanks in advance.