private void SpawnWave() { // Set the current wave to the selected wave. currentSpawnWave = GetNextWaveToSpawn(); // Handle the selected wave. HandleWave(currentSpawnWave); previousWave = currentSpawnWave; }
private void Start() { spawnedBosses = new HashSet <Boss>(); chanceToSpawnBoss = 0f; BossFight = false; // To spawn a wave immediately. currentSpawnWave = spawnDetails[0]; waveTimer = currentSpawnWave.SpawnWaveDuration; }
private void HandleRequiredSpawnPoints(SpawnDetail waveDetail) { // For each spawnpoint that exists foreach (var spawnPoint in waveDetail.SpawnPointsObj) { // Handle them StartCoroutine(HandleSpawnPoint(spawnPoint)); } }
private void HandleOptionalSpawnPoints(SpawnDetail waveDetail) { // Foreach optional spawnpoint that exists foreach (var opSpawnPoint in waveDetail.OptionalSpawnPointsObj) { var chance = Random.Range(0, 100); // If the chance to spawn them has occured if (chance <= opSpawnPoint.spawnInvokedChance) { // Handle spawning. StartCoroutine(HandleSpawnPoint(opSpawnPoint.spawnPoint)); } } }
private SpawnDetail GetNextWaveToSpawn() { int genWaveNo = Random.Range(0, spawnDetails.Length); SpawnDetail waveToSpawn = spawnDetails[genWaveNo]; // If there was a wave before this. if (previousWave != null) { // Ensure that we do not select the previous wave again. while (previousWave == waveToSpawn) { genWaveNo = Random.Range(0, spawnDetails.Length); waveToSpawn = spawnDetails[genWaveNo]; } } return(waveToSpawn); }
/// <summary> /// Creates a new spawn object into its spawn area. /// Hand-placed objects are deserialized and added to the area. /// Spawn tables run their own logic to determine which object to spawn. /// </summary> /// <param name="spawnId">The ID of the spawn</param> /// <param name="detail">The details of the spawn</param> private static uint SpawnObject(Guid spawnId, SpawnDetail detail) { // Hand-placed spawns are stored as a serialized string. // Deserialize and add it to the area. if (!string.IsNullOrWhiteSpace(detail.SerializedObject)) { var deserialized = Object.Deserialize(detail.SerializedObject); var position = new Vector(detail.X, detail.Y, detail.Z); Object.AddToArea(deserialized, detail.Area, position); AssignCommand(deserialized, () => SetFacing(detail.Facing)); SetLocalString(deserialized, "SPAWN_ID", spawnId.ToString()); return(deserialized); } // Spawn tables have their own logic which must be run to determine the spawn to use. // Create the object at the stored location. else if (detail.SpawnTableId > 0) { var spawnTable = _spawnTables[detail.SpawnTableId]; var(objectType, resref) = spawnTable.GetNextSpawnResref(); // It's possible that the rules of the spawn table don't have a spawn ready to be created. // In this case, exit early. if (string.IsNullOrWhiteSpace(resref)) { return(OBJECT_INVALID); } var position = new Vector(detail.X, detail.Y, detail.Z); var location = Location(detail.Area, position, detail.Facing); var spawn = CreateObject(objectType, resref, location); SetLocalString(spawn, "SPAWN_ID", spawnId.ToString()); return(spawn); } return(OBJECT_INVALID); }
private void HandleWave(SpawnDetail waveDetail) { HandleRequiredSpawnPoints(waveDetail); HandleOptionalSpawnPoints(waveDetail); }