private void CreateGridObject(SpawnStep spawnStep) { /* SUMMARY * - Process SpawnStep data to identify hazard to spawn and spawn location * - Instantiate hazard * - Prepare hazard for gameplay * ~ Set Animation Mode * ~ Toggle Invincibility * ~ Activates Rotator * ~ Sets MovePattern */ if (VerboseConsole) { Debug.Log("GridObjectManager.CreateHazard() called."); } GridObject newSpawn = Instantiate(spawnStep.gridObject); string borderName = ""; if (spawnStep.SpawnLocation.y == gm.BoundaryBottomActual) { borderName = "Bottom"; } else if (spawnStep.SpawnLocation.y == gm.BoundaryTopActual) { borderName = "Top"; } else if (spawnStep.SpawnLocation.x == gm.BoundaryRightActual) { borderName = "Right"; } else if (spawnStep.SpawnLocation.x == gm.BoundaryLeftActual) { borderName = "Left"; } newSpawn.Init(borderName); //Debug line //Hazard hazardToSpawn = Instantiate(hazardPrefabs[1]); AddObjectToGrid(newSpawn, spawnStep.SpawnLocation); if (VerboseConsole) { Debug.Log("GridObjectManager.CreateGridObject() completed."); } }
private void AddSpawnStep(GridObject objectForSpawn) { /* SUMMARY * - Randomly selects a spawn location * - Instantiates SpawnStep ScriptableObject * - Initializes the new SpawnStep * - Enqueue the new SpawnStep */ if (VerboseConsole) { Debug.Log("GridObjectManager.CreateSpawnStep() called."); } //int gridObjectSelector = Random.Range(0, gridObjectPrefabs.Length); Vector2Int hazardSpawnLocation = new Vector2Int(); // DEBUG: Make sure spawn selection is working appropriately //if (VerboseConsole) Debug.LogFormat("Array Length: {0}, Random value: {1}", gridObjectPrefabs.Length, gridObjectSelector); // Identify an appropriate spawn location // List<Vector2Int> availableSpawns = gm.GetSpawnLocations(gridObjectPrefabs[gridObjectSelector].spawnRules); List <Vector2Int> availableSpawns = gm.GetSpawnLocations(objectForSpawn.spawnRules); Vector2Int targetLocation = availableSpawns[Random.Range(0, availableSpawns.Count)]; hazardSpawnLocation.Set(targetLocation.x, targetLocation.y); // Create the SpawnStep SpawnStep newSpawnStep = ScriptableObject.CreateInstance <SpawnStep>(); // newSpawnStep.Init(gridObjectPrefabs[gridObjectSelector], hazardSpawnLocation); newSpawnStep.Init(objectForSpawn, hazardSpawnLocation); spawnQueue.Enqueue(newSpawnStep); }