private bool TryTetraminoRotate(Tetramino activeTetramino) { bool result = true; Rotation checkingRotation = (Rotation)(((int)_rotation + 1) % 4); int chekingNumberRotate = (int)checkingRotation; Vector2Int checkingShiftPos = _activeTetraminoPos + activeTetramino.ShiftVector[chekingNumberRotate];; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (!activeTetramino[j, i, checkingRotation].State) { continue; } if ((j + checkingShiftPos.y >= _glassfulHigh || i + checkingShiftPos.x >= _glassfulWidth || i + checkingShiftPos.x < 0 || _glassful[j + checkingShiftPos.y, i + checkingShiftPos.x].State)) { result = false; } } } if (result) { _rotation = checkingRotation; _activeTetraminoPos = checkingShiftPos; } return(result); }
public void GameStart() { int tetraminoIndex = TetraminoIndexGenerate(); _incomingTetramino = new Tetramino(_tetraminoTypes.TetraminoTypesArray[tetraminoIndex], _tetraminoTypes.TetraminoShiftVectorsArray[tetraminoIndex], tetraminoIndex); NewTetraminoCreate(); GameRun(); }
private void TetraminoInsert(Tetramino activeTetramino) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (activeTetramino[j, i, _rotation].State) { _glassful[_activeTetraminoPos.y + j, _activeTetraminoPos.x + i] = activeTetramino[j, i, _rotation]; } } } }
private void NewTetraminoCreate() { _activeTetramino = _incomingTetramino; _activeTetraminoPos = _incomingTetraminoPos; _rotation = Rotation.Angle0; if (!TryTetraminoMove(_startPosition)) { GameStop(); onGameOver?.Invoke(this, EventArgs.Empty); } int tetraminoIndex = TetraminoIndexGenerate(); _incomingTetramino = new Tetramino(_tetraminoTypes.TetraminoTypesArray[tetraminoIndex], _tetraminoTypes.TetraminoShiftVectorsArray[tetraminoIndex], tetraminoIndex); }