Example #1
0
        public void ConfiguringMatrix(int size, float matrixScale, float tileScale, Point screenSize, TileFactory tileFactory)
        {
            if (matrixScale > 1 || matrixScale < 0.5)
            {
                throw new System.ArgumentException("Margin must be between 1 and 0,5.");
            }

            int minScreenSide = Math.Min(screenSize.X, screenSize.Y);

            CellSize = Convert.ToInt32((minScreenSide * matrixScale) / size);

            // We need tile for get his size.
            var defaultTile = tileFactory.CreateRandomTile(new Cell(0, 0));

            // Calculate and set scale for tiles.
            tileFactory.TileScale = ((float)CellSize / (float)defaultTile.Size) * (tileScale);

            this.tileFactory = tileFactory;
            this.tileFactory.tileDestroying += OnTileDestroying;

            Rows    = size;
            Columns = size;

            data = new Tile[Rows, Columns];

            HeightIndent = (screenSize.Y - Rows * CellSize) / 2;
            WidthIndent  = (screenSize.X - Columns * CellSize) / 2;

            State = new GenerateState(this);
        }
Example #2
0
 public void ChangeState(MatrixState state)
 {
     if (!(State is EmptyState))
     {
         State.StateEnd();
         State = state;
         State.StateStart();
     }
 }
Example #3
0
 public SwapState(Matrix matrix, MatrixState oldState) : base(matrix)
 {
     this.oldState = oldState;
     Swap(matrix.selectedCellStart, matrix.selectedCellEnd);
 }
Example #4
0
 public GenerateState(Matrix matrix, MatrixState oldState) : base(matrix)
 {
     Generate();
 }
Example #5
0
 public IdleState(Matrix matrix, MatrixState oldState) : base(matrix)
 {
     matrix.selectedCellStart = null;
     matrix.selectedCellEnd   = null;
 }