/// <summary> /// Constructs a new projectile. /// </summary> /// <param name="world">The world that this projectile belongs to.</param> /// <param name="owner">The ship that fired this projectile, if any.</param> /// <param name="direction">The initial direction for this projectile.</param> public Projectile(World world, Ship owner, Vector2 direction) : base(world) { this.owner = owner; this.position = owner.Position; this.velocity = direction; }
/// <summary> /// Constructs a new power-up. /// </summary> /// <param name="world">The world that this power-up belongs to.</param> public PowerUp(World world) : base(world) { this.mass = 500f; this.polygon = VectorPolygon.CreateCircle(Vector2.Zero, 16f, 16); this.innerPolygon = VectorPolygon.CreateCircle(Vector2.Zero, 10f, 16); }
/// <summary> /// Constructs a new actor. /// </summary> /// <param name="world">The world that this actor belongs to.</param> public Actor(World world) { if (world == null) { throw new ArgumentNullException("world"); } this.world = world; }
/// <summary> /// Constructs a new laser projectile. /// </summary> /// <param name="world">The world that this projectile belongs to.</param> /// <param name="owner">The ship that fired this projectile, if any.</param> /// <param name="direction">The initial direction for this projectile.</param> public LaserProjectile(World world, Ship owner, Vector2 direction) : base(world, owner, direction) { this.radius = 0.5f; this.speed = 640f; this.duration = 5f; this.damageAmount = 20f; this.damageOwner = false; this.mass = 0.5f; this.explodes = false; this.explosionColors = new Color[] { Color.White, Color.Gray, Color.Gray, Color.Silver, Color.Yellow }; }
/// <summary> /// Constructs a new rocket projectile. /// </summary> /// <param name="world">The world that this projectile belongs to.</param> /// <param name="owner">The ship that fired this projectile, if any.</param> /// <param name="direction">The initial direction for this projectile.</param> public RocketProjectile(World world, Ship owner, Vector2 direction) : base(world, owner, direction) { this.radius = 8f; this.life = 80f; this.mass = 3f; this.speed = 520f; this.duration = 4f; this.damageAmount = 100f; this.damageOwner = false; this.damageRadius = 128f; this.explodes = true; this.explosionColors = new Color[] { Color.Orange, Color.Gray, Color.Gray, Color.Silver }; this.polygon = VectorPolygon.CreateRocket(); this.color = Color.Orange; }
/// <summary> /// Constructs a new mine projectile. /// </summary> /// <param name="world">The world that this projectile belongs to.</param> /// <param name="owner">The ship that fired this projectile, if any.</param> /// <param name="direction">The initial direction for this projectile.</param> public MineProjectile(World world, Ship owner, Vector2 direction) : base(world, owner, direction) { this.radius = 16f; this.life = 15f; this.speed = 64f; this.duration = 15f; this.mass = 5f; this.damageAmount = 200f; this.damageOwner = true; this.damageRadius = 80f; this.explodes = true; this.explosionColors = new Color[] { Color.Red, Color.Maroon, Color.White, Color.Silver }; this.polygon = VectorPolygon.CreateMine(); this.color = Color.Red; }
/// <summary> /// Construct a new asteroid. /// </summary> /// <param name="world">The world that this asteroid belongs to.</param> /// <param name="radius">The size of the asteroid.</param> public Asteroid(World world, float radius) : base(world) { // all asteroids are gray this.color = Color.Gray; // create the polygon this.polygon = VectorPolygon.CreateAsteroid(radius); // the asteroid polygon might not be as big as the original radius, // so find out how big it really is for (int i = 0; i < this.polygon.Points.Length; i++) { float length = this.polygon.Points[i].Length(); if (length > this.radius) { this.radius = length; } } // calculate the mass this.mass = radius * massRadiusRatio; }
/// <summary> /// Construct a new ship, for the given player. /// </summary> /// <param name="world">The world that this ship belongs to.</param> /// <param name="playerIndex"> /// The Gamepad player index that controls this ship. /// </param> public Ship(World world, PlayerIndex playerIndex) : base(world) { this.playerIndex = playerIndex; this.radius = 20f; this.mass = 32f; this.color = shipColorsByPlayerIndex[(int)this.playerIndex]; this.polygon = VectorPolygon.CreatePlayer(); this.shieldPolygon = VectorPolygon.CreateCircle(Vector2.Zero, 20f, 16); }
/// <summary> /// Initialize the game, after the ScreenManager is set, but not every time /// the graphics are reloaded. /// </summary> public void Initialize() { // create and add the bloom effect bloomComponent = new BloomComponent(ScreenManager.Game); ScreenManager.Game.Components.Add(bloomComponent); // do not automatically draw the bloom component bloomComponent.Visible = false; // create the world world = new World(new Vector2(ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height)); // retrieve the audio manager audio = (AudioManager)ScreenManager.Game.Services.GetService( typeof(AudioManager)); world.AudioManager = audio; // start up the music audio.PlayMusic("gameMusic"); // start up the game world.StartNewGame(); gameOver = false; }
/// <summary> /// Construct a new world actor. /// </summary> /// <param name="world">The world that this world-actor belongs to.</param> public WorldActor(World world) : base(world) { radius = 0f; mass = 100f; }
/// <summary> /// Constructs a new rocket-launcher power-up. /// </summary> /// <param name="world">The world that this power-up belongs to.</param> public RocketPowerUp(World world) : base(world) { this.color = Color.Orange; }