//button click information public void InfoClick(object sender, EventArgs e) { Button b = (Button)sender; int x = b.Location.X / 20; int y = b.Location.Y / 20; foreach (Unit u in units) { if (u is MeleeUnit) { MeleeUnit mu = (MeleeUnit)u; if (mu.xpos == x && mu.ypos == y) { txt.Text = ""; txt.Text = mu.ToString(); } } if (u is RangedUnit) { RangedUnit ru = (RangedUnit)u; if (ru.xpos == x && ru.ypos == y) { txt.Text = ""; txt.Text = ru.ToString(); } } } }
//button click information public void InfoClick(object sender, EventArgs e) { Button b = (Button)sender; int x = b.Location.X / 20; int y = b.Location.Y / 20; foreach (Unit u in units) { if (u is MeleeUnit) { MeleeUnit mu = (MeleeUnit)u; if (mu.xpos == x && mu.ypos == y) { txt.Text = ""; txt.Text = mu.ToString(); } } if (u is RangedUnit) { RangedUnit ru = (RangedUnit)u; if (ru.xpos == x && ru.ypos == y) { txt.Text = ""; txt.Text = ru.ToString(); } } } foreach (Buildings f in build) { if (f is FactoryBuilding) { FactoryBuilding mu = (FactoryBuilding)f; if (mu.xxpos == x && mu.yypos == y) { txt.Text = ""; txt.Text = mu.ToString(); } } if (f is ResourceBuilding) { ResourceBuilding mu = (ResourceBuilding)f; if (mu.xxpos == x && mu.yypos == y) { txt.Text = ""; txt.Text = mu.ToString(); } } } }