Пример #1
0
        private void DisplayMap()
        {
            groupBox1.Controls.Clear();
            foreach (Units u in map.Units)
            {
                if (u.GetType() == typeof(MeleeUnit))
                {
                    int start_x, start_y;
                    start_x = groupBox1.Location.X;
                    start_y = groupBox1.Location.Y;
                    MeleeUnit m = (MeleeUnit)u;
                    Button    b = new Button();
                    b.Size     = new Size(SIZE, SIZE);
                    b.Location = new Point(start_x + (m.XPos * SIZE), start_y + (m.YPos * SIZE));
                    b.Text     = m.Symbol;
                    if (m.Faction == 1)
                    {
                        b.ForeColor = Color.Blue;
                    }
                    else
                    {
                        b.ForeColor = Color.Orange;
                    }

                    if (m.IsDead())
                    {
                        b.ForeColor = Color.Black;
                    }
                    b.Click += new EventHandler(buttn_click);
                    groupBox1.Controls.Add(b);
                }
                foreach (Units Y in map.Units)
                {
                    if (Y.GetType() == typeof(RangedUnit))
                    {
                        int start_x, start_y;
                        start_x = groupBox1.Location.X;
                        start_y = groupBox1.Location.Y;
                        RangedUnit r = (RangedUnit)Y;
                        Button     b = new Button();
                        b.Size     = new Size(SIZE, SIZE);
                        b.Location = new Point(start_x + (r.XPos * SIZE), start_y + (r.YPos * SIZE));
                        b.Text     = r.Symbol;
                        if (r.Faction == 1)
                        {
                            b.ForeColor = Color.Blue;
                        }
                        else
                        {
                            b.ForeColor = Color.Orange;
                        }

                        if (r.IsDead())
                        {
                            b.ForeColor = Color.Black;
                        }
                        b.Click += new EventHandler(buttn_click);
                        groupBox1.Controls.Add(b);
                    }
                }
            }
        }