示例#1
0
        private void timer_Tick(object sender, EventArgs e)
        {
            GameOfLifeManager manager = new GameOfLifeManager(board, rules);

            manager.ImplementRules();
            RefreshBoardView();
        }
示例#2
0
        private void bStart_Click(object sender, EventArgs e)
        {
            if (timer.Enabled == true)
            {
                return;
            }
            timer.Start();
            GameOfLifeManager manager = new GameOfLifeManager(board, rules);

            manager.ImplementRules();
            RefreshBoardView();
        }
        public override void Initialize()
        {
            base.Initialize();

            new ControlHandler(this);

            _manager = new GameOfLifeManager(this, "Manager");
            _manager.UpdateTimer.LastEvent += CheckAllCells;

            //Cells = new Tilemap(this, "Cells", EntityGame.Game.Content.Load<Texture2D>(@"GameOfLife\tiles"), new Point(30,30),new Point(16,16));

            Cells = new Tilemap(this, "Cells", EntityGame.Self.Content.Load<Texture2D>(@"GameOfLife\tilesSmall"),
                                new Point(30, 30), new Point(1, 1));
            Cells.Render.Scale = new Vector2(16, 16);
            Cells.SetAllTiles(new Tile(DEAD) { Color = Color.Red.ToRGBColor() });
            //Position Tilemap to center
            Cells.Body.Position = new Vector2(EntityGame.Viewport.Width / 2f - Cells.Width / 2f * Cells.Render.Scale.X, 10);

            Cells.TileSelected += OnTileSelected;
            _tiles = Cells.CloneTiles();

            //GUI
            Page page = new Page(this, "Page");
            page.Show();

            LinkLabel startLink = new LinkLabel(page, "StartLink", new Point(0, 0));
            startLink.Body.Position = new Vector2(Cells.Body.X, 500);
            startLink.OnFocusGain();
            startLink.Text = "Start";
            startLink.OnReleased += control => _manager.Start();

            LinkLabel stopLink = new LinkLabel(page, "StopLink", new Point(0, 1));
            stopLink.Body.Position = new Vector2(Cells.Body.X, startLink.Body.Bottom);
            stopLink.Text = "Stop";
            stopLink.OnReleased += control => _manager.Stop();

            LinkLabel resetLink = new LinkLabel(page, "ResetLink", new Point(0, 2));
            resetLink.Body.Position = new Vector2(Cells.Body.X, stopLink.Body.Bottom);
            resetLink.Text = "ResetTimer";
            resetLink.OnReleased += control => ResetCells();

            LinkLabel downMillisecondsLink = new LinkLabel(page, "downMillisecondsLink", new Point(1, 0));
            downMillisecondsLink.Body.Position = new Vector2(Cells.Body.X + 100, startLink.Body.Bottom);
            downMillisecondsLink.Text = "<-";
            downMillisecondsLink.OnDown += control => _manager.UpdateTimer.Milliseconds -= 50;

            _millisecondsText = new Label(page, "millisecondsText", new Point(2, 0));
            _millisecondsText.Body.Position = new Vector2(downMillisecondsLink.Body.Right + 2, startLink.Body.Bottom);
            _millisecondsText.Text = _manager.UpdateTimer.Milliseconds.ToString();

            LinkLabel upMillisecondsLink = new LinkLabel(page, "upMillisecondsLink", new Point(3, 0));
            upMillisecondsLink.Body.Position = new Vector2(_millisecondsText.Body.Right + 25, startLink.Body.Bottom);
            upMillisecondsLink.Text = "->";
            upMillisecondsLink.OnDown += control => _manager.UpdateTimer.Milliseconds += 50;
        }
示例#4
0
        public override void Initialize()
        {
            base.Initialize();

            new ControlHandler(this);

            _manager = new GameOfLifeManager(this, "Manager");
            _manager.UpdateTimer.LastEvent += CheckAllCells;

            //Cells = new Tilemap(this, "Cells", EntityGame.Game.Content.Load<Texture2D>(@"GameOfLife\tiles"), new Point(30,30),new Point(16,16));

            Cells = new Tilemap(this, "Cells", EntityGame.Self.Content.Load <Texture2D>(@"GameOfLife\tilesSmall"),
                                new Point(30, 30), new Point(1, 1));
            Cells.Render.Scale = new Vector2(16, 16);
            Cells.SetAllTiles(new Tile(DEAD)
            {
                Color = Color.Red.ToRGBColor()
            });
            //Position Tilemap to center
            Cells.Body.Position = new Vector2(EntityGame.Viewport.Width / 2f - Cells.Width / 2f * Cells.Render.Scale.X, 10);

            Cells.TileSelected += OnTileSelected;
            _tiles              = Cells.CloneTiles();

            //GUI
            Page page = new Page(this, "Page");

            page.Show();

            LinkLabel startLink = new LinkLabel(page, "StartLink", new Point(0, 0));

            startLink.Body.Position = new Vector2(Cells.Body.X, 500);
            startLink.OnFocusGain();
            startLink.Text        = "Start";
            startLink.OnReleased += control => _manager.Start();

            LinkLabel stopLink = new LinkLabel(page, "StopLink", new Point(0, 1));

            stopLink.Body.Position = new Vector2(Cells.Body.X, startLink.Body.Bottom);
            stopLink.Text          = "Stop";
            stopLink.OnReleased   += control => _manager.Stop();

            LinkLabel resetLink = new LinkLabel(page, "ResetLink", new Point(0, 2));

            resetLink.Body.Position = new Vector2(Cells.Body.X, stopLink.Body.Bottom);
            resetLink.Text          = "ResetTimer";
            resetLink.OnReleased   += control => ResetCells();

            LinkLabel downMillisecondsLink = new LinkLabel(page, "downMillisecondsLink", new Point(1, 0));

            downMillisecondsLink.Body.Position = new Vector2(Cells.Body.X + 100, startLink.Body.Bottom);
            downMillisecondsLink.Text          = "<-";
            downMillisecondsLink.OnDown       += control => _manager.UpdateTimer.Milliseconds -= 50;

            _millisecondsText = new Label(page, "millisecondsText", new Point(2, 0));
            _millisecondsText.Body.Position = new Vector2(downMillisecondsLink.Body.Right + 2, startLink.Body.Bottom);
            _millisecondsText.Text          = _manager.UpdateTimer.Milliseconds.ToString();

            LinkLabel upMillisecondsLink = new LinkLabel(page, "upMillisecondsLink", new Point(3, 0));

            upMillisecondsLink.Body.Position = new Vector2(_millisecondsText.Body.Right + 25, startLink.Body.Bottom);
            upMillisecondsLink.Text          = "->";
            upMillisecondsLink.OnDown       += control => _manager.UpdateTimer.Milliseconds += 50;
        }