public void SpawnAirDrop(IntVector2 roomVector, GenericLootTable overrideTable = null, float EnemyOdds = 0f, float ExplodeOdds = 0f, bool playSoundFX = true, bool usePlayerPosition = true, string EnemyGUID = "01972dee89fc4404a5c408d50007dad5") { EmergencyCrateController lootCrate = Instantiate(EmergancyCratePrefab, roomVector.ToVector2().ToVector3ZUp(1f), Quaternion.identity).GetComponent <EmergencyCrateController>(); Dungeon dungeon = GameManager.Instance.Dungeon; PlayerController player = GameManager.Instance.PrimaryPlayer; RoomHandler currentRoom = GameManager.Instance.PrimaryPlayer.CurrentRoom; IntVector2 currentRoomSize = currentRoom.area.dimensions; int RoomSizeX = currentRoomSize.x; int RoomSizeY = currentRoomSize.y; lootCrate.ChanceToExplode = ExplodeOdds; lootCrate.ChanceToSpawnEnemy = EnemyOdds; lootCrate.EnemyPlaceable = CustomEnemyPlacable(EnemyGUID); if (overrideTable != null) { lootCrate.gunTable = overrideTable; } IntVector2 bestRewardLocation = new IntVector2(1, 1); if (RoomSizeX < 8 && RoomSizeY < 8) { currentRoomSize = bestRewardLocation; } if (!usePlayerPosition) { bestRewardLocation = player.CurrentRoom.GetBestRewardLocation(currentRoom.area.dimensions, RoomHandler.RewardLocationStyle.CameraCenter, true); lootCrate.Trigger(new Vector3(-5f, -5f, -5f), bestRewardLocation.ToVector3() + new Vector3(15f, 15f, 15f), player.CurrentRoom, overrideTable == null); GameManager.Instance.Dungeon.data[bestRewardLocation].PreventRewardSpawn = true; } else { bestRewardLocation = player.CurrentRoom.GetBestRewardLocation(new IntVector2(1, 1), RoomHandler.RewardLocationStyle.CameraCenter, true); lootCrate.Trigger(new Vector3(-5f, -5f, -5f), bestRewardLocation.ToVector3() + new Vector3(15f, 15f, 15f), player.CurrentRoom, overrideTable == null); GameManager.Instance.Dungeon.data[bestRewardLocation].PreventRewardSpawn = true; } dungeon.data[bestRewardLocation].PreventRewardSpawn = true; player.CurrentRoom.ExtantEmergencyCrate = lootCrate.gameObject; if (playSoundFX) { AkSoundEngine.PostEvent("Play_OBJ_supplydrop_activate_01", player.CurrentRoom.ExtantEmergencyCrate); } return; }
private void RandomToadieAirDrop(GameObject lootCratePrefab, RoomHandler currentRoom, IntVector2?Clearence = null) { if (!Clearence.HasValue) { Clearence = new IntVector2(2, 2); } IntVector2?DropLocation = FindRandomDropLocation(currentRoom, Clearence.Value); if (DropLocation.HasValue) { EmergencyCrateController lootCrate = Instantiate(lootCratePrefab, DropLocation.Value.ToVector2().ToVector3ZUp(1f), Quaternion.identity).GetComponent <EmergencyCrateController>(); if (lootCrate == null) { return; } lootCrate.ChanceToExplode = 0; lootCrate.ChanceToSpawnEnemy = 1; lootCrate.EnemyPlaceable = m_CustomEnemyPlacable(BraveUtility.RandomElement(ToadieGUIDs)); lootCrate.Trigger(new Vector3(-5f, -5f, -5f), DropLocation.Value.ToVector3() + new Vector3(15f, 15f, 15f), currentRoom, true); currentRoom.ExtantEmergencyCrate = lootCrate.gameObject; } return; }