private void GeneratePieces(Vector2 pieceLocation, Vector2 momentum, int piecesToGenerate) { for (int i = 0; i < piecesToGenerate; i++) { Sprite s = _tileSheet.SpriteAnimation(); Particle p = new Particle(s, Vector2.Zero, ExplosionMaxSpeed, DurationCount, InitialColor, FinalColor); p.Location = pieceLocation; p.Velocity = RandomDirection(PieceSpeed) + momentum; _particles.Add(p); } }
private void SpawnEnemy(EnemyPath path) { Enemy e = new Enemy(_tileSheet.SpriteAnimation(), path[0]); e.AddPath(path); _enemies.Add(e); e.ShotFired += EnemyShotFired; e.OnDestroy += HandleOnEnemyDestroy; }
public void CreateShot(ShotFiredEventArgs args) { Sprite s = _tileSheet.SpriteAnimation(); Shot shot = new Shot(s, args.FiredBy, args.Damage); shot.Location = args.Location; shot.Velocity = args.Velocity * args.ShotSpeed; shot.OnDestroy += HandleOnShotDestroy; _shots.Add(shot); }
private void GenerateStars(int starCount, Vector2 starVelocity) { for (int i = 0; i < starCount; i++) { Vector2 loc = new Vector2(_rand.Next(0, _screenBounds.Width), _rand.Next(0, _screenBounds.Height)); Star star = new Star(_tileSheet.SpriteAnimation()); star.Velocity = starVelocity * (_rand.Next(30, 100) / 100.0f); star.Location = loc; _stars.Add(star); } }
public void AddAsteroid() { Vector2 initPosition = new Vector2(-500, -500); // hack to force the asteroid to reposition itself when Update() is called Sprite asteroidSprite = _tileSheet.SpriteAnimation(); asteroidSprite.Location = initPosition; asteroidSprite.Rotation = MathHelper.ToRadians(_rand.Next(0, 360)); Asteroid a = new Asteroid(asteroidSprite); a.OnDestroy += HandleOnAsteroidDestroy; _asteroids.Add(a); }