private static void ProcessHorizontal(Grid grid, TetraminoMono tetraminoMono, Vector2Int offset)
    {
        if (offset.sqrMagnitude == 0)
        {
            return;
        }
        Tetramino tetraminoData = tetraminoMono.tetramino;
        //bool collision =
        //    Grid.Collision(grid, tetraminoData, offset, Tetramino.RotationType.None);
        //if (!collision)
        //{
        //    tetraminoMono.TranslateCenterPosition(offset);
        //}
        Vector2Int projectionDir                = VectorUtil.V2_V2Int(((Vector2)offset).normalized);
        Vector2Int stopPosition                 = Grid.StopPosition(Grid.Ins, tetraminoData, projectionDir);
        Vector2Int stopDeltaPosition            = stopPosition - tetraminoData.centerPos;
        int        stopDeltaPositionSqrManitude = stopDeltaPosition.sqrMagnitude;
        int        offsetPositionSqrManitude    = offset.sqrMagnitude;

        if ((stopDeltaPositionSqrManitude < offsetPositionSqrManitude))
        {
            tetraminoMono.SetCenterPosition(stopPosition);
            Debug.Log("stopDeltaPositionSqrManitude < offsetPositionSqrManitude");
        }
        else
        {
            tetraminoMono.TranslateCenterPosition(offset);
        }
    }
Exemplo n.º 2
0
        public void DeveDesenharFormaZ()
        {
            var forma = Tetramino.Draw(PieceType.Z, new Point(), 0);

            Assert.AreEqual(4, forma.Blocks.Count());
            Assert.AreEqual("1+0,1+1,0+1,0+2", forma.ToString());
        }
Exemplo n.º 3
0
    // for each colummn in each row check if null
    public void UpdateGrid(Tetramino tetramino)
    {
        for (int y = 0; y < gridHeight; ++y)
        {
            for (int x = 0; x < gridWidth; ++x)
            {
                if (grid[x, y] != null)
                {
                    if (grid[x, y].parent == tetramino.transform)
                    {
                        grid[x, y] = null;
                    }
                }
            }
        }

        foreach (Transform mino in tetramino.transform)
        {
            Vector2 pos = Round(mino.position);
            if (pos.y < gridHeight)
            {
                grid[(int)pos.x, (int)pos.y] = mino;
            }
        }
    }
Exemplo n.º 4
0
 private static int[] RowsToCheckForSweep(Tetramino tetramino)
 {
     Vector2Int[] absPoses = tetramino.AbsPoses;
     int[]        rowsToCheckForSweepNotUnique = LoopUtil.LoopFunc <int>((i) => absPoses[i].y, 4);
     int[]        rowsToCheckForSweepUnique    = rowsToCheckForSweepNotUnique.Distinct().OrderBy(i => i).ToArray();
     return(rowsToCheckForSweepUnique);
 }
Exemplo n.º 5
0
    // coordinates where tetramino stop after moving in projection direction
    // tetramino stops because of the grid's stopping blocks(saved in grid.blocks 2D array)
    public static Vector2Int StopPosition(Grid grid, Tetramino tetramino, Vector2Int projectionDir)
    {
        int offsetCount = 0;

        while (!Grid.Collision
                   (grid, tetramino, projectionDir * offsetCount, Tetramino.RotationType.None))
        {
            offsetCount++;
            if (offsetCount > 100)
            {
                Debug.LogError("Collision doesn't work properly apparentlly.");
                break;
            }
        }
        if (offsetCount == 0)
        {
            Debug.Log("Tetramino already is in position where it can't be.");
            Debug.LogError("?");
            Debug.Log(projectionDir);
            Debug.Break();
        }
        offsetCount--;
        Vector2Int stopPosition = tetramino.centerPos
                                  + projectionDir * offsetCount;

        return(stopPosition);
    }
Exemplo n.º 6
0
    private static void ProcessHorizontal(Grid grid, TetraminoMono tetraminoMono, Vector2Int offset)
    {
        if (offset.sqrMagnitude == 0)
        {
            return;
        }
        Tetramino tetraminoData = tetraminoMono.tetramino;

        //Vector2Int projectionDir = VectorUtil.V2_V2Int(((Vector2)offset).normalized);
        Vector2Int projectionDir                = offset;
        Vector2Int stopPosition                 = Grid.StopPosition(grid, tetraminoData, projectionDir);
        Vector2Int stopDeltaPosition            = stopPosition - tetraminoData.centerPos;
        int        stopDeltaPositionSqrManitude = stopDeltaPosition.sqrMagnitude;
        int        offsetPositionSqrManitude    = offset.sqrMagnitude;

        if (stopDeltaPositionSqrManitude < offsetPositionSqrManitude)
        {
            tetraminoMono.SetCenterPosition(stopPosition);
            Debug.Log("stopDeltaPositionSqrManitude < offsetPositionSqrManitude");
            // tetramino can't move because of grid blocks being occupied
        }
        else
        {
            tetraminoMono.TranslateCenterPosition(offset);
        }
    }
Exemplo n.º 7
0
        public static Tetramino SetUp(Tetramino tetramino, Tetramino.TetraminoType type)
        {
            tetramino.type = type;
            switch (type)
            {
            case TetraminoType.I:
                tetramino.Poses = GetPoses(new int[4, 2] {
                    { 0, 0 }, { 1, 0 }, { 2, 0 }, { 3, 0 }
                });
                tetramino.rotationPoint = new Vector2(3f / 2f, -1f / 2f);
                break;

            case TetraminoType.J:
                tetramino.Poses = GetPoses(new int[4, 2] {
                    { 0, 0 }, { 1, 0 }, { 1, 1 }, { 1, 2 }
                });
                tetramino.rotationPoint = new Vector2(1f, 1f);
                break;

            case TetraminoType.L:
                tetramino.Poses = GetPoses(new int[4, 2] {
                    { 0, 0 }, { 1, 0 }, { 0, 1 }, { 0, 2 }
                });
                tetramino.rotationPoint = new Vector2(0f, 1f);
                break;

            case TetraminoType.O:
                tetramino.Poses = GetPoses(new int[4, 2] {
                    { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 }
                });
                tetramino.rotationPoint = new Vector2(1f / 2f, 1f / 2f);
                break;

            case TetraminoType.S:
                tetramino.Poses = GetPoses(new int[4, 2] {
                    { 0, 0 }, { 1, 0 }, { 1, 1 }, { 2, 1 }
                });
                tetramino.rotationPoint = new Vector2(1f, 0f);
                break;

            case TetraminoType.T:
                tetramino.Poses = GetPoses(new int[4, 2] {
                    { 1, 0 }, { 0, 1 }, { 1, 1 }, { 2, 1 }
                });
                tetramino.rotationPoint = new Vector2(1f, 1f);
                break;

            case TetraminoType.Z:
                tetramino.Poses = GetPoses(new int[4, 2] {
                    { 0, 1 }, { 1, 1 }, { 1, 0 }, { 2, 0 }
                });
                tetramino.rotationPoint = new Vector2(1f, 0f);
                break;

            default:
                Debug.LogError("Unsupported tetramino type: " + type);
                break;
            }
            return(tetramino);
        }
Exemplo n.º 8
0
    void Start()
    {
        print("Started");
        takenMatrixPositions      = new bool[rows, cols];
        initialTetraminoYAddition = (cols / 2) - 3;
        tetraminos = new Tetramino[predefinedStates.Length];

        for (int r = 0; r < rows; r++)
        {
            for (int c = 0; c < cols; c++)
            {
                Transform instance = Instantiate(squarePrefab, new Vector3(r, c, 0), Quaternion.identity) as Transform;
                instance.transform.SetParent(transform.Find("Manager"));
            }
        }

        for (int i = 0; i < predefinedStates.Length; i++)
        {
            Tetramino currTetramino = new Tetramino();
            currTetramino.States = predefinedStates [i];
            tetraminos [i]       = currTetramino;
        }


        GenerateNewTetramino();
        if (isWithStupidAI)
        {
            controlsEnabled = false;
        }
        lastRoutine = StartCoroutine(MoveTetraminos());
    }
Exemplo n.º 9
0
    void GenerateNewTetramino()
    {
        currentCubesArr    = new List <GameObject> ();
        currTetramino      = tetraminos [Random.Range(0, tetraminos.Length)];
        currTetraminoState = currTetramino.getRandomState();

        currTetraminoCoords = new int[8];
        horizontalAddition  = initialTetraminoYAddition;
        isFirstRotation     = true;
        verticalAddition    = 0;
        for (int i = 0; i < currTetramino.States [currTetraminoState].Length; i += 2)
        {
            currTetraminoCoords [i]     = currTetramino.States [currTetraminoState] [i];
            currTetraminoCoords [i + 1] = currTetramino.States [currTetraminoState] [i + 1] + horizontalAddition;
            if (takenMatrixPositions [currTetraminoCoords [i], currTetraminoCoords [i + 1]])
            {
                isGameOver      = true;
                controlsEnabled = false;
                print("GAME OVER");
                break;
            }
        }
        if (!isGameOver)
        {
            for (int i = 0; i < 4; i++)
            {
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.GetComponent <Renderer> ().material.color = currTetramino.color;
                currentCubesArr.Add(cube);
            }
            UpateCurrentCubesPosition();
        }
    }
Exemplo n.º 10
0
    public void UpdateGrid(Tetramino tetramino)
    {
        for(int y = 0; y < gridHeight; y++)
        {
            for(int x = 0; x < gridWidth; ++x)
            {
                if(grid[x, y] != null)
                {
                    if(grid[x, y].parent == tetramino.transform)
                    {
                        grid[x, y] = null;
                    }
                }
            }
        }

        foreach(Transform mino in tetramino.transform)
        {
            Vector2 pos = Round(mino.position);
                if(pos.y < gridHeight)
            {
                grid[(int)pos.x, (int)pos.y] = mino;
            }
        }
    }
    private void Build(Tetramino.TetraminoType tetrominoType)
    {
        Tetramino tetromino     = new Tetramino(tetrominoType);
        Vector3   rotationPoint = tetromino.rotationPoint;

        Vector2Int[] poses = tetromino.Poses;


        Vector3 w_tetrominoPosition         = transform.position;
        Vector3 l_rotationTransformPosition = rotationPoint;

        Vector3[] l_cellTransformPositions = CellPosesRelative2RotationPoint(poses, rotationPoint);

        GameObject rotation_gameObject = new GameObject("Rotation transform");

        rotationTransform = AssignParentAndLocalPosition(rotation_gameObject, transform, l_rotationTransformPosition);

        List <Transform> cellTransformsList = new List <Transform>();
        int cellIndex = 0;

        foreach (Vector3 pos in l_cellTransformPositions)
        {
            GameObject cell_go = Instantiate(tetrominoCellPrefab).gameObject;
            cell_go.name = $"Cell index: {cellIndex++}";
            cellTransformsList.Add
            (
                AssignParentAndLocalPosition(cell_go, rotationTransform, pos)
            );
        }

        cellTransforms = cellTransformsList.ToArray();
    }
Exemplo n.º 12
0
 public Block(Vector2Int _spawnPosition, Tetramino _tetramino, Game.SquareDefinition[,] _grid)
 {
     position     = _spawnPosition;
     tetramino    = _tetramino;
     grid         = _grid;
     needToUpdate = true;
 }
Exemplo n.º 13
0
    private static List <int> RowsToSweepExtended(Tetramino tetramino, out bool sweep)
    {
        List <int> rowsToSweep         = RowsToSweep(tetramino, out sweep);
        List <int> rowsToSweepExtended = rowsToSweep.ToList();// copy list

        int rowCount = Grid.gridSize.y;

        rowsToSweepExtended.Add(rowCount + 1);
        return(rowsToSweepExtended);
    }
Exemplo n.º 14
0
        public GameBoard(Board board)
        {
            rows = board.GetMainGridRow;
            cols = board.GetMainGridCol;
            ROWS = board.GetExtraGridRow;
            COLS = board.GetExtraGridCol;

            tetraminoRandom = new Random();
            curNumber       = tetraminoRandom.Next(0, 7);
            nextNumber      = tetraminoRandom.Next(0, 7);


            score       = 0;
            linesFilled = 0;

            BlockControls = new PictureBox[cols, rows]; // block trong main grid
            BlockShape    = new PictureBox[COLS, ROWS]; // block tiếp theo

            for (int h = 0; h < COLS; h++)
            {
                for (int k = 0; k < ROWS; k++)
                {
                    BlockShape[h, k] = new PictureBox
                    {
                        BackgroundImage       = NoImage,
                        BackgroundImageLayout = ImageLayout.Stretch,
                        BackColor             = Color.Transparent,
                        Width  = 27,
                        Height = 27,
                    };
                    board.GetExtraGrid.Add(BlockShape[h, k], h, k);
                }
            }

            for (int i = 0; i < cols; i++)
            {
                for (int j = 0; j < rows; j++)
                {
                    BlockControls[i, j] = new PictureBox
                    {
                        BackgroundImage       = NoImage,
                        BackgroundImageLayout = ImageLayout.Stretch,
                        Width     = 27,
                        Height    = 27,
                        BackColor = Color.Transparent,
                    };
                    board.GetMainGrid.Add(BlockControls[i, j], i, j);
                }
            }
            curTetramino  = new Tetramino(this.curNumber);
            nextTetramino = new Tetramino(nextNumber);
            CurTetraminoDraw();
            NextTetraminoDraw();
        }
Exemplo n.º 15
0
 public bool CheckIfAboveGrid(Tetramino tetramino)
 {
     foreach (Transform mino in tetramino.transform)
     {
         Vector2 pos = mino.position;
         if (pos.y > gridHeight - 1)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 16
0
    public static Dictionary <TetraminoName, Tetramino> DefineTetraminos()
    {
        Dictionary <TetraminoName, Tetramino> tetraminoMap = new Dictionary <TetraminoName, Tetramino>();

        bool[,] longyGrid = new bool[1, 4] {
            { true, true, true, true }
        };
        Tetramino longy = new Tetramino(TetraminoName.LongBoi, longyGrid, Color.red, new Vector2Int(0, 2));

        tetraminoMap.Add(longy.name, longy);

        return(tetraminoMap);
    }
    private static string VectorPosesString(Tetramino.TetraminoType tetraminoType, RotationDirection rotationDirection)
    {
        Vector2Int[] tetraminoPoses      = TetraminoTransformUtil.GetPoses(tetraminoType, RotationDirection.None);
        Vector2Int[] rotationVectorPoses = new Vector2Int[4];
        Vector2      rotationPoint       = new Tetramino(tetraminoType).rotationPoint;

        for (int i = 0; i < 4; i++)
        {
            Vector2 rotated = RotateVector.Rotate(tetraminoPoses[i], rotationPoint, rotationDirection);
            rotationVectorPoses[i] = VectorUtil.V2_V2Int(rotated);
        }
        return(string.Join("\t", rotationVectorPoses));
    }
Exemplo n.º 18
0
    // makes cells occupied by tetramino impassable
    public void FreezeTetraminoArea(TetraminoMono tetraminoMono)
    {
        Tetramino tetramino = tetraminoMono.tetramino;

        Vector2Int[] absPoses = tetramino.AbsPoses;
        LoopUtil.LoopAction((i) =>
        {
            this[absPoses[i]] =
                new WallBlock(BlockType.Unspecified, tetraminoMono.GetChildGameObject(i));
        }
                            , absPoses.Length);
        DisplayBlocks.UpdateBlocks();
    }
Exemplo n.º 19
0
        public void CurTetraminoMovDown()
        {
            Point Position = curTetramino.GetPosition;

            Point[] Shape = curTetramino.GetShape;
            bool    move  = true;

            CurTetraminoErase();

            foreach (Point S in Shape)
            {
                if (((int)(S.Y + Position.Y) + 1 + 1) >= rows)
                {
                    move = false;
                }

                else if (BlockControls[((int)(S.X + Position.X) + ((cols / 2) - 1)),
                                       (int)(S.Y + Position.Y) + 1 + 1].BackgroundImage != NoImage)
                {
                    move = false;
                }
            }

            if (move)
            {
                curTetramino.MoveDown();
                CurTetraminoDraw();
            }

            else
            {
                CurTetraminoDraw();
                CheckRows();

                if ((int)Position.Y <= 1)
                {
                    gameOver = true;
                }

                else
                {
                    curNumber    = nextNumber;
                    nextNumber   = tetraminoRandom.Next(0, 7);
                    curTetramino = new Tetramino(curNumber);
                    NextTetraminoErase();
                    nextTetramino = new Tetramino(nextNumber);
                    NextTetraminoDraw();
                }
            }
        }
Exemplo n.º 20
0
 private void TetraminoViewSet(Tetramino tetramino, TileView[,] tetraminoView)
 {
     for (int i = 0; i < _size; i++)
     {
         for (int j = 0; j < _size; j++)
         {
             if (tetramino[j, i, _game.Rotation].State)
             {
                 int colorIndex = tetramino[j, i, _game.Rotation].Color;
                 tetraminoView[j, i] = GetTile(_colorsArray[colorIndex]);
             }
         }
     }
 }
Exemplo n.º 21
0
    private static List <int> RowsToSweepExtended(Tetramino tetramino, out bool sweep)
    {
        List <int> rowsToSweep         = RowsToSweep(tetramino, out sweep);
        List <int> rowsToSweepExtended = new List <int>();

        foreach (int rowToSweep in rowsToSweep)
        {
            rowsToSweepExtended.Add(rowToSweep);
        }
        int rowCount = Grid.gridSize.y;

        rowsToSweepExtended.Add(rowCount + 1);
        return(rowsToSweepExtended);
    }
Exemplo n.º 22
0
 //Checks if blocks are above grid for game over
 public bool CheckIsAboveGrid(Tetramino tetromino)
 {
     for (int x = 0; x < gridWidth; x++)
     {
         foreach (Transform mino in tetromino.transform)
         {
             Vector2 pos = Round(mino.position);
             if (pos.y > gridHeight - 1)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 23
0
    private static List <int> RowsToSweep(Tetramino tetramino, out bool sweep)
    {
        List <int> rowsToSweep = new List <int>();

        int[] rowsToCheckForSweep = RowsToCheckForSweep(tetramino);
        foreach (int row in rowsToCheckForSweep)
        {
            if (Grid.FullRow(row))
            {
                rowsToSweep.Add(row);
            }
        }
        sweep = rowsToSweep.Count != 0;
        return(rowsToSweep);
    }
Exemplo n.º 24
0
 public bool CheckIsAboveGrid(Tetramino tetramino)
 {
     for(int x = 0; x < gridWidth; ++x)
     {
         foreach(Transform mino in tetramino.transform)
         {
             Vector2 pos = Round(mino.position);
             if(pos.y > gridHeight -1)
             {
                 return true;
             }
         }
     }
     return false;
 }
    private static void ProcessRotation(TetraminoMono tetraminoMono, TetraminoMono projection)
    {
        Tetramino tetraminoData = tetraminoMono.tetramino;

        if (Input.GetKeyDown(KeyCode.W))
        {
            bool collision =
                Grid.Collision(Grid.Ins, tetraminoData, Vector2Int.zero, Tetramino.RotationType.Clockwise);
            if (!collision)
            {
                tetraminoMono.RotateClockwise();
                projection.RotateClockwise();
            }
        }
    }
Exemplo n.º 26
0
    // makes cells occupied by tetramino impassable
    public void FreezeTetraminoArea(TetraminoMono tetraminoMono)
    {
        //foreach (Vector2Int pos in )
        //{
        //    blocks[pos.x, pos.y] = new WallBlock(BlockType.Unspecified);
        //}
        Tetramino tetramino = tetraminoMono.tetramino;

        Vector2Int[] absPoses = tetramino.AbsPoses;
        LoopUtil.LoopAction((i) =>
        {
            blocks[absPoses[i].x, absPoses[i].y] =
                new WallBlock(BlockType.Unspecified, tetraminoMono.GetChildGameObject(i));
        }
                            , absPoses.Length);
        DisplayBlocks.UpdateBlocks();
    }
Exemplo n.º 27
0
 //Game loop
 private async Task CreateNewBlock()
 {
     await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         actualTetramino = TetraminoesFactory.CreateRandomTetramino();
         //actualTetramino = TetraminoesFactory.CreateTetramino(TetraminoShape.I);
         CheckForBottomCollision();
         if (bottomCollision)
         {
             gameOver = true;
         }
         else
         {
             view.ActualTetramino = actualTetramino;
             view.DrawTetramino();
         }
     });
 }
Exemplo n.º 28
0
 private void NewTetramino()
 {
     tetramino     = nextTetramino;
     nextTetramino = new Tetramino();
     for (int i = 0; i < Height; i++)
     {
         for (int j = 0; j < BORDERS_COUNT; j++)
         {
             float H, S, V;
             Color.RGBToHSV(tetramino.Color, out H, out S, out V);
             S = (float)(i + 1) / Height;
             SpriteRenderer renderer = borders[i, j].GetComponent <SpriteRenderer>();
             renderer.color = Color.HSVToRGB(H, S, V);
         }
     }
     scoreTitle.color      = tetramino.Color;
     scoreNumber.color     = tetramino.Color;
     tetraminoTitle.color  = nextTetramino.Color;
     tetraminoImage.color  = nextTetramino.Color;
     tetraminoImage.sprite = Resources.Load <Sprite>("TetraminoImages/tetramino_" + nextTetramino.Id.ToString());
 }
        public MainWindowController(Board BOARD, MainWindow mainWindow, int level)
        {
            this.board        = BOARD;
            mainWindowControl = mainWindow;

            tetramino          = new Tetramino();
            te_moving          = new TetraminoMoving(tetramino);
            shapeRandom        = new Random();
            currentShapeNumber = shapeRandom.Next(1, 8);
            nextShapeNumber    = shapeRandom.Next(1, 8);

            this.gameSpeed = GAMESPEED;
            setLevel(level);
            timer          = new DispatcherTimer();
            timer.Interval = new TimeSpan(0, 0, 0, 0, gameSpeed);
            timer.Tick    += Timer_Tick;

            mainWindow.txtfinish.Visibility = Visibility.Collapsed;
            mainWindow.scoreTxt.Visibility  = mainWindow.nextTxt.Visibility = mainWindow.restartStopBtn.Visibility = mainWindow.levelTxt.Visibility = Visibility.Hidden;
            startGame(mainWindow);
        }
Exemplo n.º 30
0
    public static void Sweep(Tetramino tetramino)
    {
        bool       sweep;
        List <int> rowsToSweepExtended = RowsToSweepExtended(tetramino, out sweep);

        if (!sweep)
        {
            return;
        }
        List <List <int> > splitList = SplitList(rowsToSweepExtended);

        for (int dropCount = 1; dropCount <= splitList.Count; dropCount++)
        {
            int sweepRowIndex = rowsToSweepExtended[dropCount - 1];
            Grid.EmptyAndDestroyBricksInRow(sweepRowIndex);
            foreach (int rowIndex in splitList[dropCount - 1])
            {
                Grid.DropBricksInRow(rowIndex, dropCount);
            }
        }
    }
Exemplo n.º 31
0
    // Update is called once per frame
    void Update()
    {
        bool update      = UpdateTimer(Time.deltaTime);
        bool instantMove = Input.GetKeyDown(KeyCode.Space);

        if (update || instantMove)
        {
            Grid       grid              = Grid.Ins;
            Tetramino  tetramino         = tetraminoMono.tetramino;
            Vector2Int offset            = Vector2Int.down;
            bool       spawnNewTetramino = false;
            if (instantMove)
            {
                //Vector2Int projectionPos = projection.projection.GetComponent<TetraminoMono>().tetramino.centerPos;
                //Vector2Int tetraminoPos = tetramino.centerPos;
                //offset = projectionPos - tetraminoPos;
                spawnNewTetramino = true;
            }
            else
            {
                bool collision = Grid.Collision(grid, tetramino, Vector2Int.down, Tetramino.RotationType.None);
                if (collision)
                {
                    //Debug.Log("collision");
                    spawnNewTetramino = true;
                }
                else
                {
                    tetraminoMono.TranslateCenterPosition(offset);
                }
            }
            if (spawnNewTetramino)
            {
                Tetramino tetraminoProjectionCopy = projection.DropProjection();  //TODO Check exact spawn time
                SpawnNewTetramino();
                SweepLine.Sweep(tetraminoProjectionCopy);
            }
        }
    }
    public static Vector2Int[] GetPoses(Tetramino.TetraminoType tetraminoType, RotationDirection rotationDirection)
    {
        Tetramino tetramino = new Tetramino(tetraminoType);

        switch (rotationDirection)
        {
        case RotationDirection.None:
            break;

        case RotationDirection.Clockwise:
            tetramino.RotateClockwise();
            break;

        case RotationDirection.CounterClockwise:
            tetramino.RotateAntiClockwise();
            break;

        default:
            throw new UnityException($"RotationDirection type<{rotationDirection}> not supported!");
        }
        return(tetramino.Poses);
    }
Exemplo n.º 33
0
 //Game loop
  private async Task CreateNewBlock()
  {
      await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
      {
          actualTetramino = TetraminoesFactory.CreateRandomTetramino();
          //actualTetramino = TetraminoesFactory.CreateTetramino(TetraminoShape.I);                
          CheckForBottomCollision();
          if (bottomCollision)
              gameOver = true;
          else
          {
              view.ActualTetramino = actualTetramino;
              view.DrawTetramino();
          }
      });
  }