public void DeleteLines() { var eraseGroups = groups.Where(g => g.EnteredAll); var lineCount = eraseGroups.Count(); var objectCount = eraseGroups.Sum(g => g.EnteredObjectCount); if (lineCount == 0) { return; } foreach (var group in eraseGroups) { group.DeleteLine(); } var info = new DeleteMinoInfo(lineCount, objectCount); Debug.Log($"lines: {info.LineCount}, objects: {info.ObjectCount}"); LineDeleted?.Invoke(this, info); sfxManager.Play(TetoSfxType.Delete); }
public void Update() { var velocity = new Vector2(rigidbody.velocity.x, -fallSpeed); var torque = 0.0f; var horizontal = Input.GetAxis(@"Horizontal"); if (prevHorizontal <= 0 && horizontal > 0 || prevHorizontal >= 0 && horizontal < 0) { sfxManager.Play(TetoSfxType.Move); } if (horizontal < 0) { velocity.x -= settings.HorizontalVelocity * Time.deltaTime; } if (horizontal > 0) { velocity.x += settings.HorizontalVelocity * Time.deltaTime; } velocity.x = Mathf.Clamp(velocity.x, -settings.LimitHorizontalVelocity, settings.LimitHorizontalVelocity); prevHorizontal = horizontal; var vertical = Input.GetAxis(@"Vertical"); if (vertical != 0) { var t1 = Mathf.Clamp(DropTime, 0, settings.AccelarationTime); var t2 = t1 / settings.AccelarationTime; var t3 = settings.AccelarationCurve.Evaluate(t2); var peek = (vertical < 0) ? settings.SoftdropPeekAccelaration : settings.HarddropPeekAccelaration; fallAccelaration = peek * t3; DropTime += Time.deltaTime; ReleaseTime = 0.0f; } else { var t1 = Mathf.Clamp(ReleaseTime, 0, settings.DecelerationTime); var t2 = t1 / settings.DecelerationTime; var t3 = settings.DecelerationCurve.Evaluate(t2); fallAccelaration = Mathf.Lerp(fallAccelaration, 0.0f, t3); ReleaseTime += Time.deltaTime; DropTime = 0.0f; } if (Input.GetButtonDown(@"Rotate Left") || Input.GetButtonDown(@"Rotate Right")) { sfxManager.Play(TetoSfxType.Rotate); } if (Input.GetButton(@"Rotate Left")) { torque += settings.AngularVelocity * Time.deltaTime; } if (Input.GetButton(@"Rotate Right")) { torque -= settings.AngularVelocity * Time.deltaTime; } velocity.y -= fallAccelaration; rigidbody.AddTorque(torque); rigidbody.velocity = velocity; rigidbody.angularVelocity = Mathf.Clamp(rigidbody.angularVelocity, -settings.LimitAngularVelocity, settings.LimitAngularVelocity); // dropEffect.transform.rotation = Quaternion.identity; }
public void Set(MinoType type) { frame.Set(type); sfxManager.Play(TetoSfxType.Hold); animator.Play(@"HoldAnimation", 0, 0.0f); }