public void SpawnNewMeteor(Point2 playerPosition) { var rotationSpeed = _random.Next(-10, 10) * 0.1f; var spawnCircle = new CircleF(playerPosition, 630); var spawnAngle = MathHelper.ToRadians(_random.Next(0, 360)); var spawnPosition = spawnCircle.GetPointAlongEdge(spawnAngle); var velocity = (playerPosition - spawnPosition).Rotate(MathHelper.ToRadians(_random.Next(-15, 15))) * _random.Next(3, 10) * 0.01f; var textureRegion = GetMeteorRegion(4); var meteor = new Meteor(textureRegion, spawnPosition, velocity, rotationSpeed, 3); _entityManager.AddEntity(meteor); }
public void SpawnNewMeteor(Vector2 playerPosition) { var rotationSpeed = _random.Next(-10, 10) * 0.1f; var spawnCircle = new CircleF(playerPosition, 630); var spawnAngle = MathHelper.ToRadians(_random.Next(0, 360)); var spawnPosition = spawnCircle.GetPointAlongEdge(spawnAngle); var velocity = (playerPosition - spawnPosition).Rotate(MathHelper.ToRadians(_random.Next(-15, 15))) * _random.Next(3, 10) * 0.01f; var textureRegion = GetMeteorRegion(4); var meteor = new Meteor(textureRegion, spawnPosition, velocity, rotationSpeed, 3); _entityManager.AddEntity(meteor); }
public void SplitMeteor(Meteor meteor) { if (meteor.Size <= 1) { throw new InvalidOperationException("Meteor size less than 2 can't be split"); } for (var i = 0; i < 2; i++) { var size = meteor.Size - 1; var rotationSpeed = _random.Next(-10, 10) * 0.1f; var spawnPosition = meteor.Position; var velocity = i == 0 ? meteor.Velocity.PerpendicularClockwise() + meteor.Velocity : meteor.Velocity.PerpendicularCounterClockwise() + meteor.Velocity; var textureRegion = GetMeteorRegion(size); var newMeteor = new Meteor(textureRegion, spawnPosition, velocity, rotationSpeed, size); _entityManager.AddEntity(newMeteor); } }