Beispiel #1
0
        public void Button_Click(object sender, EventArgs args)
        {
            int x = (((Button)sender).Location.X - groupDisplay.Location.X) / SIZE;
            int Y = (((Button)sender).Location.Y - groupDisplay.Location.Y) / SIZE;

            foreach (Unit u in map.Units)
            {
                if (u.GetType() == typeof(RangedUnit))
                {
                    RangedUnit r = (RangedUnit)u;

                    if (r.PosX == x && r.PosY == Y)
                    {
                        rtbxOutput2.Text = "" + r.toString();
                    }
                }

                else if (u.GetType() == typeof(MeeleeUnit))
                {
                    MeeleeUnit m = (MeeleeUnit)u;

                    if (m.PosX == x && m.PosY == Y)
                    {
                        rtbxOutput2.Text = "" + m.toString();
                    }
                }

                else if (u.GetType() == typeof(WarlockUnit))
                {
                    WarlockUnit m = (WarlockUnit)u;

                    if (m.PosX == x && m.PosY == Y)
                    {
                        rtbxOutput2.Text = "" + m.toString();
                    }
                }
            }

            foreach (Building b in map.Buildings)
            {
                if (b.GetType() == typeof(FactoryBuilding))
                {
                    FactoryBuilding fb = (FactoryBuilding)b;

                    if (fb.PosX == x && fb.PosY == Y)
                    {
                        rtbxOutput2.Text = "" + fb.toString();
                    }
                }

                else if (b.GetType() == typeof(ResourceBuilding))
                {
                    ResourceBuilding rb = (ResourceBuilding)b;

                    if (rb.PosX == x && rb.PosY == Y)
                    {
                        rtbxOutput2.Text = "" + rb.toString();
                    }
                }
            }
        }