/// <summary> /// Spawns a ship using the properties of an existing ship. Used for respawning existing ships which have been killed. Spawn location is randomized. /// </summary> /// <param name="ship">ship to be respawned</param> public void RespawnShip(Ship ship) { Vector2D newLoc = new Vector2D(rand.Next(-worldSize / 2, worldSize / 2), rand.Next(-worldSize / 2, worldSize / 2)); Vector2D newOrient = new Vector2D(0, -1); Ship newShip = new Ship(ship.GetID(), newLoc, newOrient, false, ship.GetName(), ShipHealth, ship.GetScore()); // Set ship's modifiable variables newShip.setAccelRate(ShipAccel); newShip.SetRespawnDelay(ShipRespawnRate); newShip.SetFireDelay(FireDelay); newShip.setWorldSize(this.worldSize); this.addShip(newShip); }
/// <summary> /// Creates a new ship at a random world location, and adds this ship to the world. /// </summary> /// <param name="id">id of this ship</param> /// <param name="name">name of the player controlling this ship</param> public void SpawnShip(int id, string name) { // This probably won't work as ships can spawn on a center star, but for now should make ships randomly initialize. // Create new ship for this client. Vector2D newLoc = new Vector2D(rand.Next(-worldSize / 2, worldSize / 2), rand.Next(-worldSize / 2, worldSize / 2)); Vector2D newOrient = new Vector2D(0, -1); Ship newShip = new Ship(id, newLoc, newOrient, false, name, ShipHealth, 0); // Set ship's modifiable variables newShip.setAccelRate(ShipAccel); newShip.SetRespawnDelay(ShipRespawnRate); newShip.SetFireDelay(FireDelay); newShip.setWorldSize(this.worldSize); this.addShip(newShip); }