/// <summary> /// Method for firing projectiles from a star, for Boss mode. /// Generates a single line of projectiles rotating clockwise around the star. /// TODO: need to modify fire counter and fire delay to be star properties so that boss mode works with multiple stars. /// </summary> /// <param name="currentStar">Star firing this projectile.</param> public void bossFireMode1(Star currentStar) { if (starFireCounter % starFireDelay == 0) { starFireDir.Rotate(2.5); SpawnProjectile(currentStar, this.starFireDir); } starFireCounter++; }
/// <summary> /// Spawns an explosion of projectiles at the component's location. /// Used for the explosive game mode. /// </summary> /// <param name="component">The component at which to "explode."</param> private void Explode(GameComponent component) { // Store the last rotation vector var rotationVector = new Vector2D(0, 1); // Spawn projectiles in a circle. for (var i = 0; i < 20; i++) { // Create a copy of the rotation vector var direction = new Vector2D(rotationVector); // Create a new projectile var projectile = new Projectile(component.Id) { Direction = direction, Location = component.Location, Velocity = direction * Configuration.ProjectileSpeed }; // Add the projectile to the world. _world.PutComponent(projectile); // Rotate the rotation vector rotationVector.Rotate(18); } }
public void Rotate(int num, double turnRate) { if (dir.Length() != 0) { dir.Normalize(); } dir.Rotate(num * turnRate); }
/// <summary> /// Rotates a ship left for the given shipID. /// </summary> public void RotateShipLeft(int shipID) { Ship ship = theShips[shipID]; Vector2D newDir = ship.GetOrientation(); newDir.Rotate(-turningRate); ship.SetOrientation(newDir); }
/// <summary> /// Creates a ship at a random location in the world in a random direction /// </summary> public void Respawn(Ship ship) { // find random empty location in the world FindRandomLocation(ship); // make a new normalized direction vector pointing up Vector2D dir = new Vector2D(0, -1); dir.Normalize(); // make a randomizing object Random r = new Random(); int randAngle = r.Next(0, 360); //rotate by random angle dir.Rotate(randAngle); // sets a random direction for the ship ship.SetDirection(dir); // reset ship's velocity ship.SetVelocity(new Vector2D(0, 0)); // if dead ship is king if (ship.IsKing()) { // hit points go up beacuse ship is now king ship.SetHP(startingHitPoints + 3); } else { // reset the ship's health to original health ship.SetHP(startingHitPoints); } // reset ships death timer ship.ResetRespawnTimer(); }
/// <summary> /// The default constructor for the world /// </summary> public World() { // Initialize data structures. shipDictionary = new Dictionary <int, Ship>(); projectileDictionary = new Dictionary <int, Projectile>(); starDictionary = new Dictionary <int, Star>(); deadShipDictionary = new Dictionary <int, Ship>(); shipsToRespawn = new List <int>(); deadStarDictionary = new Dictionary <int, Star>(); starsToRespawn = new List <int>(); rand = new Random(); worldSize = 750; // initialize ID counters. projIDs = 0; starIDs = 0; // initialize boss mode variables starFireCounter = 0; starFireDir = new Vector2D(1, 0); starFireDir.Rotate(rand.NextDouble() * 360); // randomize starting fire location. starFireDelay = 2; }