private void KillRemainingBalls() { var balls = GameObject.FindObjectsOfType <Ball>(); foreach (var b in balls) { if (b != null) { LevelAuthor.SafeDestroy(b.gameObject); } } }
public IEnumerator KillRoutine() { float t = 0; transform.localScale = Vector3.one; Vector3 initScale = transform.localScale; while (t < manager.KillTime) { float l = t / manager.KillTime; float scale = manager.KillCurve.Evaluate(l); float rot = Mathf.Lerp(0, 90, l); transform.localRotation = Quaternion.Euler(0, 0, rot); transform.localScale = initScale * scale; t += Time.deltaTime; yield return(null); } LevelAuthor.SafeDestroy(gameObject); }
private void LateUpdate() { // Stop editing while playing if (GameSystem.Instance && GameSystem.Instance.Sequence.State != SequenceState.STOPPED) { return; } var ray = Cam.ScreenPointToRay(Input.mousePosition); bool hit = Physics.Raycast(ray, out var hitInfo, float.MaxValue) && hitInfo.collider == collider; hovered = dragging || hit; var dT = Time.deltaTime; var d = hovered ? 1f : 0f; var s = hovered ? Config.enterSpeed * dT : -Config.exitSpeed * dT; if (math.abs(hoverTransition - d) > 0.0001f) { hoverTransition = math.clamp(hoverTransition + s, 0, 1); var c = Config.curve.Evaluate(hoverTransition); var g = Config.gradient.Evaluate(hoverTransition); line.startWidth = line.endWidth = math.lerp(Config.minWidth, Config.maxWidth, c); line.startColor = line.endColor = g; for (int i = 0; i < line.positionCount; i++) { line.SetPosition(i, directions[i] * math.lerp(Config.minRadius, Config.maxRadius, c)); } } if (hovered) { bool click = Input.GetMouseButtonDown(0); bool hold = Input.GetMouseButton(0); bool rClick = Input.GetMouseButtonDown(1); if (!dragging) { if (click) { dragging = true; dragPlane = new Plane(tr.forward, tr.position); dragPlane.Raycast(ray, out float enter); var point = ray.GetPoint(enter); startDragDiff = tr.position - point; } } else { if (!hold) { dragging = false; } else { if (rClick) { LevelAuthor.SafeDestroy(gameObject); } else { if (dragPlane.Raycast(ray, out float enter)) { tr.position = (float3)ray.GetPoint(enter) + startDragDiff; } } } } } tr.position = new Vector3(Mathf.FloorToInt(tr.position.x) + 0.5f, Mathf.FloorToInt(tr.position.y) + 0.5f, Mathf.FloorToInt(tr.position.z)); }