private void ShowSavedShape() { ClearGrid(); List <Vector2Int> _blocks = ShapeCodeProcessor.ShapeCodeToCoordinates(savedShape.shape, mainBlockCoordinate); for (int i = 0; i < _blocks.Count; i++) { allBlocks[_blocks[i]].AssignMaterial(savedShape.material); allBlocks[_blocks[i]].gameObject.SetActive(true); } }
private void UpdateCurrentUsedBlocks() { //Clears the list currentUsedBlocks.Clear(); List <Vector2Int> _currentUsedBlocksCoordinates = ShapeCodeProcessor.ShapeCodeToCoordinates(currentShape.shape, currentMainBlockCoordinate); //Finds the blocks linked with the coordinates and adds them to the list for (int i = 0; i < _currentUsedBlocksCoordinates.Count; i++) { currentUsedBlocks.Add(Grid.allBlocks[_currentUsedBlocksCoordinates[i]]); } }
public void RotateShape() { //Checks if shape can rotate if (grid.AreTheseCoordinatesAvailable(ShapeCodeProcessor.RotateAndGiveCoordinates(currentShape.shape, currentMainBlockCoordinate))) { //Resets current shape to base color ColorShapeAroundMainBlock(GameController.baseMaterial); //RotatesShape currentShape.shape = ShapeCodeProcessor.RotateShapeCode(currentShape.shape); //Updates the list of blocks the shape is made of UpdateCurrentUsedBlocks(); //Colors the shape around the main block ColorShapeAroundMainBlock(currentShape.material); } }
public void MoveShapeTowards(Direction _direction) { if (currentShape.material == null) { SpawnShape(); } //Checks if shape can move towards specified direction if (grid.CanShapeMove(ShapeCodeProcessor.ShapeCodeToCoordinates(currentShape.shape, currentMainBlockCoordinate), _direction)) { //Resets current shape to base color ColorShapeAroundMainBlock(GameController.baseMaterial); //Moves the main block down MoveMainBlockTowards(grid.DirectionToCoords(_direction, currentMainBlockCoordinate)); //Updates the list of blocks the shape is made of UpdateCurrentUsedBlocks(); //Colors the shape around the main block ColorShapeAroundMainBlock(currentShape.material); } }