public void SoftDrop() { if (currentBlock == null || landed) { return; } moveDelta = MoveDelda.SoftDrop; }
public void NormalDrop() { if (currentBlock == null || landed) { return; } moveDelta = MoveDelda.Normal; }
public void HoldBlock() { if (currentBlock == null) { return; } if (holdedThisTurn) { return; } originSize = currentBlock.transform.localScale; if (holded != null) { var tmp = currentBlock; currentBlock = holded; holded = tmp; currentBlock.transform.position = new Vector3(Tetris.Width / 2, Tetris.Height); currentBlock.transform.localScale = originSize; DestroyPreview(); InitPreview(); UpdatePreview(); } else { DestroyPreview(); holded = currentBlock; NextBlock(); } vfx?.PlayClip(SV.ClipHold); // reset block state moveDelta = MoveDelda.Normal; holdedThisTurn = true; if (holded is BlockO || holded is BlockI) { holded.transform.position = new Vector3(holdedViewPosX - holdedViewPosOffset, holdedViewPosY, 0); } else { holded.transform.position = new Vector3(holdedViewPosX, holdedViewPosY, 0); } holded.transform.localScale = new Vector3(sizeScale, sizeScale); holded.transform.rotation = Quaternion.Euler(0, 0, 0); holded.ResetState(); }
public void Fall(float deltaTime) { if (gameOver) { return; } time += deltaTime; OnTimeChanged?.Invoke(time); if (currentBlock == null) { return; } if (!landed) { if (!isLanding) { if (lastFallTime >= FallDeltaTime) { isLanding = !currentBlock.MoveDown(); lastFallTime = 0; } else { lastFallTime += deltaTime; } } else { if (lastWaitTime >= waitLandTime) { landed = true; lastWaitTime = 0; vfx?.PlayClip(SV.ClipSoftDrop); } else { isLanding = !currentBlock.MoveDown(); lastWaitTime += Time.deltaTime; } } } else { // trigger vfx before check(), because the currentBlock reference has been cleared after check() method. vfx?.PlayClip(SV.ClipLanding); DestroyPreview(); AddToGrid(); if (gameOver) { return; } Check(); moveDelta = MoveDelda.Normal; isLanding = false; landed = false; } }