Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 private void DestroyAsteroid()
 {
     circleColl.enabled = false;
     AsteroidDestroyed?.Invoke();
     Destroy(gameObject);
 }