public void Update(float deltaTime) { if (!started) { return; } var colliders = new List <ICollider>(circles); simulationField.UpdateStaticColliders(); var notCollided = CheckCollisions(colliders.ToArray(), deltaTime); foreach (var collider in notCollided) { collider.Update(deltaTime); } if (ballsSpawner != null) { var newBalls = ballsSpawner.Update(deltaTime); foreach (var ball in newBalls) { SpawnBallCallback?.Invoke(ball); } if (ballsSpawner.IsFinished) { ballsSpawner = null; BallSpawingFinished?.Invoke(); } circles.AddRange(newBalls); } }
public void SpawnBalls(uint count, float radius, Vector2 direction, Vector2 startBallPosition, float speedMultiplier) { ballsSpawner = new BallsSpawner(radius, startBallPosition, direction, count, 23 * speedMultiplier); float delay = 0.05f / (speedMultiplier * 0.8f); ballsSpawner.SetDelay(delay); started = true; }