Beispiel #1
0
        public void Clear()
        {
            _timer.Close();
            _activeCircles.Clear();

            _collisionsDetector = null;

            _circleSpawner   = null;
            _circleDestroyer = null;

            GC.Collect();
        }
Beispiel #2
0
        private void Init(Circle[] unspawnedCircles, Circle[] spawnedCircles, Settings settings)
        {
            Settings = settings;

            _activeCircles = new List <Circle>(spawnedCircles.Length + unspawnedCircles.Length);
            var size = new Vector2(settings.GameAreaWidth, settings.GameAreaHeight);

            CalculateSimulationRate(settings.MaxUnitSpeed, settings.MinUnitRadius);
            int elapsedTime = IterationsCount * DeltaTime();

            _circleSpawner   = new CirclesSpawner(unspawnedCircles, spawnedCircles, settings.UnitSpawnDelay, _activeCircles, elapsedTime);
            _circleDestroyer = new CirclesDestroyer(_activeCircles);

            _collisionsDetector = new CollisionsDetector(settings.NumUnitsToSpawn, size);
        }