Ejemplo n.º 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);
            }
Ejemplo n.º 2
0
            /// <summary>
            ///
            /// </summary>
            public void ResetModel(Texture2D texture)
            {
                if (_initialized == false)
                {
                    Start();
                    _initialized = true;
                }

                // reset cell states
                foreach (var layer in _stack.Layers)
                {
                    foreach (var cell in layer.Cells)
                    {
                        cell.State = 0;
                    }
                }

                if (_model == null)
                {
                    _model = new CAModel2D(GetComponent <ICARule2D>(), _stack.RowCount, _stack.ColumnCount);
                }

                // re-initialize model
                _initializer.Initialize(_model.CurrentState, texture);

                // reset layer
                _currentLayer = -1;

                _buildComplete = false;
            }
Ejemplo n.º 3
0
            /// <summary>
            ///
            /// </summary>
            private void Awake()
            {
                // create model
                _model = new CAModel2D(GetComponent <ICARule2D>(), _stack.RowCount, _stack.ColumnCount);

                _stack = Instantiate(_stack);

                // initialize model
                _initializer.Initialize(_model.CurrentState);
            }
Ejemplo n.º 4
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>();
            }
Ejemplo n.º 5
0
            /// <summary>
            ///
            /// </summary>
            private void Start()
            {
                if (_initialized == false)
                {
                    // create model
                    _model = new CAModel2D(GetComponent <ICARule2D>(), _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>();
                    _initialized = true;
                }
            }