Exemple #1
0
        private void Button_Click(object sender, EventArgs e)
        {
            int x = (((Button)sender).Location.X - GBMap.Location.X) / SIZE;
            int y = (((Button)sender).Location.Y - GBMap.Location.Y) / SIZE;

            txtInfo.Text = x + " " + y;
            foreach (Unit u in map.Units)
            {
                if (u.GetType() == typeof(MeleeUnit))
                {
                    MeleeUnit m = (MeleeUnit)u;
                    if (m.Xpos == x && m.Ypos == y)
                    {
                        txtInfo.Text = "Melee" + m.ToString();
                    }
                }
            }
            foreach (Unit Y in map.Units)
            {
                if (y.GetType() == typeof(RangesUnit))
                {
                    RangesUnit r = (RangesUnit)Y;
                    if (r.Xpos == x && r.Ypos == y)
                    {
                        txtInfo.Text = "Archer" + r.ToString();
                    }
                }
            }
            foreach (Unit X in map.Units)
            {
                if (y.GetType() == typeof(Grubs))
                {
                    Grubs G = (Grubs)X;
                    if (G.Xpos == x && G.Ypos == y)
                    {
                        txtInfo.Text = "Grubs" + G.ToString();
                    }
                }
            }
        }