コード例 #1
0
        private void Init()
        {
            m_timer          = new Timer();
            m_timer.Interval = 1000;
            m_timer.Tick    += Update;
            m_timer.Start();

            for (int i = 0; i < m_list_unit_rect.Length; ++i)
            {
                m_list_unit_rect[i] = new UnitRectInfo();
            }
        }
コード例 #2
0
        private void DrawUnit()
        {
            m_cur_rect_count = 0;
            using (Graphics gra = this.m_pic_root.CreateGraphics())
            {
                gra.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                Unit main_unit = null;
                using (Brush bush = new SolidBrush(Color.Green))
                {
                    Unit unit = null;
                    Dictionary <long, Unit> units = UnitManager.Instance.units;
                    foreach (var obj in units)
                    {
                        if (m_cur_rect_count >= m_list_unit_rect.Length)
                        {
                            break;
                        }

                        unit = obj.Value;
                        if (unit.obj_idx == PlayerDataMgr.Instance.main_player_id)
                        {
                            main_unit = unit;
                            continue;
                        }

                        int x = 10 * unit.pos.x + 500;
                        int y = 10 * unit.pos.y + 500;
                        gra.FillEllipse(bush, x, y, 10, 10);

                        UnitRectInfo unit_info = m_list_unit_rect[m_cur_rect_count];
                        unit_info.unit_idx    = unit.obj_idx;
                        unit_info.rect.X      = x;
                        unit_info.rect.Y      = y;
                        unit_info.rect.Width  = 10;
                        unit_info.rect.Height = 10;
                        ++m_cur_rect_count;
                    }
                }
                if (main_unit != null)
                {
                    using (Brush bush = new SolidBrush(Color.Red))
                    {
                        if (m_cur_rect_count >= m_list_unit_rect.Length)
                        {
                            return;
                        }

                        int x = 10 * main_unit.pos.x + 500;
                        int y = 10 * main_unit.pos.y + 500;
                        gra.FillEllipse(bush, x, y, 10, 10);

                        UnitRectInfo unit_info = m_list_unit_rect[m_cur_rect_count];
                        unit_info.unit_idx    = main_unit.obj_idx;
                        unit_info.rect.X      = x;
                        unit_info.rect.Y      = y;
                        unit_info.rect.Width  = 10;
                        unit_info.rect.Height = 10;
                        ++m_cur_rect_count;
                    }
                }
            }
        }