Exemple #1
0
 private void OnClick(ICellModel cellModel)
 {
     if (_paused)
     {
         cellModel.IsAlive = !cellModel.IsAlive;
     }
 }
Exemple #2
0
 public Cell()
 {
     Down  = new CellNull();
     Up    = new CellNull();
     Left  = new CellNull();
     Right = new CellNull();
 }
Exemple #3
0
        private void BuildBoard(int numLines, int numColumns, ICellModel cellModelPrototype, float cellWidth = 1f, float cellHeight = 1f)
        {
            _boardModel = new BoardModel(numLines, numColumns, cellModelPrototype, cellWidth, cellHeight);

            float halfWidth  = cellWidth * (numColumns - 1) * 0.5f;
            float halfHeight = cellHeight * (numLines - 1) * 0.5f;

            for (int i = 0; i < numLines; i++)
            {
                for (int j = 0; j < numColumns; j++)
                {
                    float x = Mathf.Lerp(-halfWidth, halfWidth, j / (numColumns - 1f));
                    float y = Mathf.Lerp(halfHeight, -halfHeight, i / (numLines - 1f));

                    ICellModel cellModelInstance = _boardModel.Cells[i, j];
                    cellModelInstance.OnClick.AddListener(OnClick);
                    cellModelInstance.Transform.localScale = new Vector3(cellWidth, cellHeight, 1f);
                    cellModelInstance.GameObject.name      = string.Format("Cell [{0}:{1}]", i, j);

                    Vector3 cellPosition = transform.TransformPoint(new Vector3(x, y, transform.localPosition.z));
                    cellModelInstance.Transform.localPosition = cellPosition;
                    cellModelInstance.Transform.parent        = transform;
                }
            }
        }
Exemple #4
0
        protected virtual void OnEnable()
        {
            if (_cellModelPrototype == null)
            {
                _cellModelPrototype = _cellPrefab.GetComponent <ICellModel>();
            }

            BuildBoard(_numLines, _numColumns, _cellModelPrototype, _cellWidth, _cellHeight);

            _simulationStepText.text = string.Format("Simulation Step: {0}", SimulationStep.ToString());

            if (!_paused)
            {
                Play();
            }
        }
 public ICellModel getCell(int col)
 {
     if (col >= 0 && col <= 16383)
     {
         ICellModel cellModel = default(ICellModel);
         if (this.CellsMap.TryGetValue(col, out cellModel))
         {
             return(cellModel);
         }
         CT_Cell cT_Cell = new CT_Cell();
         cT_Cell.R_Attr = CellPair.Name(this.RowNumber, col);
         cellModel      = new XMLCellModel(this._worksheetModel, this._manager, cT_Cell);
         this.CellsMap.Add(col, cellModel);
         return(cellModel);
     }
     throw new FatalException();
 }
Exemple #6
0
 internal Cell(ICellModel model)
 {
     mModel = model;
 }
Exemple #7
0
 public Cell(ICellModel model)
 {
     this.mModel = model;
 }