Пример #1
0
            /// <summary>
            ///
            /// </summary>
            private void Start()
            {
                // create cell array
                _cells = new Cell[_countY, _countX];

                // instantiate cell prefabs and store in array
                for (int y = 0; y < _countY; y++)
                {
                    for (int x = 0; x < _countX; x++)
                    {
                        //instantiate a new cell using the cell prefab
                        Cell cell = Instantiate(_cellPrefab, transform);

                        //move the cell's position to correct location based on the index
                        cell.transform.localPosition = new Vector3(x, 0, y);

                        //store the newly created cell in the cells 2d array
                        _cells[y, x] = cell;
                    }
                }


                // create model using the rule attached to this component
                _rule  = GetComponent <ICARule2D>();
                _model = new CAModel2D(_rule, _countY, _countX);

                // initialize model
                _initializer.Initialize(_model.CurrentState);

                // create display
                _display = new ModelDisplay();
                _display.Initialize(_countX, _countY, _cells);
            }
Пример #2
0
            /// <summary>
            ///
            /// </summary>
            private void Awake()
            {
                // create model using the rule attached to this component
                _rule  = GetComponent <ICARule2D>();
                _model = new CAModel2D(_rule, _stack.RowCount, _stack.ColumnCount);

                // initialize model
                _initializer.Initialize(_model.CurrentState);

                // update layer / cells in the stack to the seed image
                _currentLayer = 1;
                UpdateStack();

                //
                _analyser = GetComponent <StackAnalyser>();
            }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rows"></param>
 /// <param name="columns"></param>
 public CAModel2D(ICARule2D rule, int rows, int columns)
 {
     Rule          = rule;
     _currentState = new int[rows, columns];
     _nextState    = new int[rows, columns];
 }