void OnEnable() { // Drop time reduces when the game level goes up dropTime = 1 - GameSystem.gsInstance.gameLevel * 0.1f; // Assign TetrominoSystem Component tetroSystem = GameObject.FindObjectOfType <TetrominoSystem>(); // Assign attached blocks to blocks list blocks = new TetrominoBlockController[4]; for (int i = 0; i < blocks.Length; i++) { TetrominoBlockController newBlock = transform.GetChild(0).GetChild(i).GetComponent <TetrominoBlockController>(); blocks[i] = newBlock; } // Assign TetrominoController to current tetromino variable curTetroController = gameObject.GetComponent <TetrominoController>(); curBlocks = gameObject; // Assign touch controller event TouchController.swipeEvent += SwipeHandler; TouchController.swipeEndEvent += SwipeEndHandler; TouchController.tapEvent += TapHandler; }
/// <summary> /// Move a block down one unit. /// </summary> /// <param name="curGrid">The grid that contains the blocks to be moved down</param> void MoveBlockDown(TetrisGrid curGrid) { TetrominoBlockController curTile = curGrid.blockOnGrid.GetComponent <TetrominoBlockController>(); curTile.MoveBlock(Vector2Int.down); curTile.SetBlock(); // Set coordinate of the grid empty and set occupied false curGrid.blockOnGrid = null; curGrid.isOccupied = false; }