// Tetris Update data private void Tick() { // slowdown for player since they don't play at framerate speed if (_Controller == Control.PLAYER) { _Stall += Time.deltaTime; if (_Stall > 0.04f) { _Stall = 0.0f; } else { return; } } // Check if current piece is empty if (_Piece._Type == Tetrominoes.NONE) { // Piece becomes a random new piece _Piece.BecomeNewPiece(); // Check if overlaps at start bool Failure = _Piece.CheckOverlapsSolid(); if (Failure) { EndGame(); return; } } // Overlap bool Overlap = false; // Do Move switch (_CurrentMove) { case Move.MOVE_LEFT: if (_Piece.MoveLeft()) { IncreaseFitness(ScoreSystemManager.GetCurrent().Move_Left); } break; case Move.MOVE_RIGHT: if (_Piece.MoveRight()) { IncreaseFitness(ScoreSystemManager.GetCurrent().Move_Right); } break; case Move.MOVE_DOWN: if (_Piece.MoveDown()) { IncreaseFitness(ScoreSystemManager.GetCurrent().Move_Down); } else { Overlap = true; } break; case Move.COLLAPSE: // Alternate Skip Mode if (GameplayManager.GetInstance().CollapseDoesNothing) { break; } float sc = _Piece.Collapse(); IncreaseFitness(ScoreSystemManager.GetCurrent().DropDown_Per_Tile *sc); break; case Move.ROTATE_CCW: if (_Piece.Rotate(false)) { IncreaseFitness(ScoreSystemManager.GetCurrent().Rotate); if (_Piece._Type == Tetrominoes.O) { IncreaseFitness(ScoreSystemManager.GetCurrent().RotatingCube); } } break; case Move.ROTATE_CW: if (_Piece.Rotate(true)) { IncreaseFitness(ScoreSystemManager.GetCurrent().Rotate); if (_Piece._Type == Tetrominoes.O) { IncreaseFitness(ScoreSystemManager.GetCurrent().RotatingCube); } } break; } // Update Move Text GameplayManager.GetInstance()._MoveText.text = GetMove().ToString(); // Reset Move _CurrentMove = Move.WAIT; // If 5th tick go down by one regardless if (_TickCounter % 5 == 0 && !Overlap) { if (!_Piece.MoveDown()) { Overlap = true; } } // Check if Piece is overlapping if (Overlap) { _Piece._y++; _Piece.UpdatePiece(); AddPieceToBoard(); } // TICK ++ UpdateTickCounter(); // Limited Pieces Game if ( GameplayManager.GetInstance().LimitPieces > 0 && _PiecesUsed > GameplayManager.GetInstance().LimitPieces - 1 ) { EndGame(); } }