Exemplo n.º 1
0
        public InitWorldViewModel(Grid gameOfLifeGrid)
        {
            RectSize = 3;
            GameOfLifeGrid = gameOfLifeGrid;

            World = new World(75, 75);
            Ran = new Random();

            CreateGrid();
            GameOfLifeViewModel = new GameOfLifeViewModel(World);
        }
Exemplo n.º 2
0
        public GameOfLifeViewModel(World world)
        {
            TaskFactory = new TaskFactory(TaskScheduler.FromCurrentSynchronizationContext());

            World = world;
            PreviousWorld = new World(world.XRows, world.YRows)
            {
                Grid2DArray = world.CopyGrid2DArray(),
                Grid = world.Grid
            };

            GameThread = new Thread(GameOfLife);
        }
Exemplo n.º 3
0
        private void SetWorldVisuals()
        {
            int count = 0;

            for (int i = 0; i < World.Grid2DArray.GetLength(0); i++)
            {
                for (int j = 0; j < World.Grid2DArray.GetLength(1); j++)
                {
                    World.Grid[count].Visibility = PreviousWorld.Grid2DArray[i, j] ?
                        Visibility.Visible :
                        Visibility.Hidden;

                    World.Grid2DArray[i, j] = PreviousWorld.Grid2DArray[i, j];

                    count++;
                }
            }

            PreviousWorld = new World(World.XRows, World.YRows)
            {
                Grid2DArray = World.CopyGrid2DArray(),
                Grid = World.Grid
            };
        }