Ejemplo n.º 1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            tscbGameSpeed.ComboBox.DataSource   = Enum.GetValues(typeof(GameSpeed));
            tscbGameSpeed.ComboBox.SelectedItem = (GameSpeed)Properties.Settings.Default.Speed;

            try
            {
                _options = Options.Load(Properties.Settings.Default.OptionsFilePath);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                _options = Options.Default;
                Options.Save(Properties.Settings.Default.OptionsFilePath, _options);
            }

            _life  = new Engine.Life(new Map(Properties.Settings.Default.MapWidth, Properties.Settings.Default.MapHeight), _options.S, _options.B, _options.C);
            _grEng = new GraphicsEngine(pnlDraw.Handle, _life, Properties.Settings.Default.CellSize);
            GraphicsInit();
            ZoomInit();
            Zoom(false);
            SharpVisible(Properties.Settings.Default.SharpVisible);

            pnlDraw.Visible = true;
            _grEng.Draw();

            pnlMain.Invalidate();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Создает GraphicsEngine
        /// </summary>
        /// <param name="handle">Handle поверхности</param>
        /// <param name="life">Игровой движок</param>
        /// <param name="cellSize">Размер клетки</param>
        public GraphicsEngine(IntPtr handle, Engine.Life life, byte cellSize)
        {
            if (handle == null)
            {
                throw new ArgumentNullException("handle");
            }
            if (life == null)
            {
                throw new ArgumentNullException("life");
            }

            _handle           = handle;
            _cellSize         = cellSize;
            _life             = life;
            _life.MapChanged += Life_MapChanged;
            _life.MapCleaned += Life_MapCleaned;
            _life.StartGame  += Life_StartGame;
            _life.Step       += Life_Step;

            Init(_life.Map, _cellSize);
            ResetColorStep();
            VertexCellsInit(_life.Map);
            VertexSharpInit(_life.Map);

            IsDrawSharp = true;
            _sharpColor = Color.Black;
        }