public List <Asteroid> Destroy() { List <Asteroid> result = new List <Asteroid>(); ToRemove = true; AsteroidDestroyed?.Invoke(this, new EventArgs()); Remove(); if (_asteroidSize != 1) { Asteroid a1 = new Asteroid(_grid, _pos.Copy(), _vec.Copy(), asteroidSize: (byte)(_asteroidSize - 1)); Position p2 = _pos.Copy(); p2.X += DefaultSize; p2.Y += DefaultSize; PRandom pr = new PRandom(); GBsharp2.Primitives.Vector v2 = new GBsharp2.Primitives.Vector(pr.Next((int)(-AsteroidsDefaultSpeed * 2), (int)(-AsteroidsDefaultSpeed)), pr.Next((int)(-AsteroidsDefaultSpeed / 2), (int)(AsteroidsDefaultSpeed / 2))); Asteroid a2 = new Asteroid(_grid, p2, v2, asteroidSize: (byte)(_asteroidSize - 1)); result.Add(a1); result.Add(a2); } return(result); }
private void DestroyAsteroid() { circleColl.enabled = false; AsteroidDestroyed?.Invoke(); Destroy(gameObject); }