private DungeonPlaceable m_CustomEnemyPlacable(string EnemyGUID = "b5e699a0abb94666bda567ab23bd91c4", bool forceBlackPhantom = false) { DungeonPlaceableVariant EnemyVariant = new DungeonPlaceableVariant(); EnemyVariant.percentChance = 1f; EnemyVariant.unitOffset = Vector2.zero; EnemyVariant.enemyPlaceableGuid = EnemyGUID; EnemyVariant.pickupObjectPlaceableId = -1; EnemyVariant.forceBlackPhantom = forceBlackPhantom; EnemyVariant.addDebrisObject = false; EnemyVariant.prerequisites = null; EnemyVariant.materialRequirements = null; List <DungeonPlaceableVariant> EnemyTiers = new List <DungeonPlaceableVariant>(); EnemyTiers.Add(EnemyVariant); DungeonPlaceable m_cachedPlacable = ScriptableObject.CreateInstance <DungeonPlaceable>(); m_cachedPlacable.name = "CustomEnemyPlacable"; m_cachedPlacable.width = 1; m_cachedPlacable.height = 1; m_cachedPlacable.roomSequential = false; m_cachedPlacable.respectsEncounterableDifferentiator = false; m_cachedPlacable.UsePrefabTransformOffset = false; m_cachedPlacable.MarkSpawnedItemsAsRatIgnored = false; m_cachedPlacable.DebugThisPlaceable = false; m_cachedPlacable.variantTiers = EnemyTiers; return(m_cachedPlacable); }
private DungeonPlaceable CustomItemPlacable(int ItemID = 70) { DungeonPlaceableVariant ItemVariant = new DungeonPlaceableVariant(); ItemVariant.percentChance = 1f; ItemVariant.unitOffset = Vector2.zero; ItemVariant.enemyPlaceableGuid = string.Empty; ItemVariant.pickupObjectPlaceableId = ItemID; ItemVariant.forceBlackPhantom = false; ItemVariant.addDebrisObject = false; ItemVariant.prerequisites = null; ItemVariant.materialRequirements = null; List <DungeonPlaceableVariant> ItemTiers = new List <DungeonPlaceableVariant>(); ItemTiers.Add(ItemVariant); DungeonPlaceable m_cachedPlacable = ScriptableObject.CreateInstance <DungeonPlaceable>(); m_cachedPlacable.name = "CustomItemPlacable"; m_cachedPlacable.width = 1; m_cachedPlacable.height = 1; m_cachedPlacable.roomSequential = false; m_cachedPlacable.respectsEncounterableDifferentiator = false; m_cachedPlacable.UsePrefabTransformOffset = false; m_cachedPlacable.MarkSpawnedItemsAsRatIgnored = false; m_cachedPlacable.DebugThisPlaceable = false; m_cachedPlacable.variantTiers = ItemTiers; return(m_cachedPlacable); }
public static DungeonPlaceable GenerateDungeonPlacable(GameObject ObjectPrefab = null, bool spawnsEnemy = false, bool useExternalPrefab = false, bool spawnsItem = false, string EnemyGUID = "479556d05c7c44f3b6abb3b2067fc778", int itemID = 307, Vector2?CustomOffset = null, bool itemHasDebrisObject = true, float spawnChance = 1f) { AssetBundle m_assetBundle = ResourceManager.LoadAssetBundle("shared_auto_001"); AssetBundle m_assetBundle2 = ResourceManager.LoadAssetBundle("shared_auto_002"); AssetBundle m_resourceBundle = ResourceManager.LoadAssetBundle("brave_resources_001"); // Used with custom DungeonPlacable GameObject ChestBrownTwoItems = m_assetBundle.LoadAsset <GameObject>("Chest_Wood_Two_Items"); GameObject Chest_Silver = m_assetBundle.LoadAsset <GameObject>("chest_silver"); GameObject Chest_Green = m_assetBundle.LoadAsset <GameObject>("chest_green"); GameObject Chest_Synergy = m_assetBundle.LoadAsset <GameObject>("chest_synergy"); GameObject Chest_Red = m_assetBundle.LoadAsset <GameObject>("chest_red"); GameObject Chest_Black = m_assetBundle.LoadAsset <GameObject>("Chest_Black"); GameObject Chest_Rainbow = m_assetBundle.LoadAsset <GameObject>("Chest_Rainbow"); // GameObject Chest_Rat = m_assetBundle.LoadAsset<GameObject>("Chest_Rat"); m_assetBundle = null; m_assetBundle2 = null; m_resourceBundle = null; DungeonPlaceableVariant BlueChestVariant = new DungeonPlaceableVariant(); BlueChestVariant.percentChance = 0.35f; BlueChestVariant.unitOffset = new Vector2(1, 0.8f); BlueChestVariant.enemyPlaceableGuid = string.Empty; BlueChestVariant.pickupObjectPlaceableId = -1; BlueChestVariant.forceBlackPhantom = false; BlueChestVariant.addDebrisObject = false; BlueChestVariant.prerequisites = null; BlueChestVariant.materialRequirements = null; BlueChestVariant.nonDatabasePlaceable = Chest_Silver; DungeonPlaceableVariant BrownChestVariant = new DungeonPlaceableVariant(); BrownChestVariant.percentChance = 0.28f; BrownChestVariant.unitOffset = new Vector2(1, 0.8f); BrownChestVariant.enemyPlaceableGuid = string.Empty; BrownChestVariant.pickupObjectPlaceableId = -1; BrownChestVariant.forceBlackPhantom = false; BrownChestVariant.addDebrisObject = false; BrownChestVariant.prerequisites = null; BrownChestVariant.materialRequirements = null; BrownChestVariant.nonDatabasePlaceable = ChestBrownTwoItems; DungeonPlaceableVariant GreenChestVariant = new DungeonPlaceableVariant(); GreenChestVariant.percentChance = 0.25f; GreenChestVariant.unitOffset = new Vector2(1, 0.8f); GreenChestVariant.enemyPlaceableGuid = string.Empty; GreenChestVariant.pickupObjectPlaceableId = -1; GreenChestVariant.forceBlackPhantom = false; GreenChestVariant.addDebrisObject = false; GreenChestVariant.prerequisites = null; GreenChestVariant.materialRequirements = null; GreenChestVariant.nonDatabasePlaceable = Chest_Green; DungeonPlaceableVariant SynergyChestVariant = new DungeonPlaceableVariant(); SynergyChestVariant.percentChance = 0.2f; SynergyChestVariant.unitOffset = new Vector2(1, 0.8f); SynergyChestVariant.enemyPlaceableGuid = string.Empty; SynergyChestVariant.pickupObjectPlaceableId = -1; SynergyChestVariant.forceBlackPhantom = false; SynergyChestVariant.addDebrisObject = false; SynergyChestVariant.prerequisites = null; SynergyChestVariant.materialRequirements = null; SynergyChestVariant.nonDatabasePlaceable = Chest_Synergy; DungeonPlaceableVariant RedChestVariant = new DungeonPlaceableVariant(); RedChestVariant.percentChance = 0.15f; RedChestVariant.unitOffset = new Vector2(0.5f, 0.5f); RedChestVariant.enemyPlaceableGuid = string.Empty; RedChestVariant.pickupObjectPlaceableId = -1; RedChestVariant.forceBlackPhantom = false; RedChestVariant.addDebrisObject = false; RedChestVariant.prerequisites = null; RedChestVariant.materialRequirements = null; RedChestVariant.nonDatabasePlaceable = Chest_Red; DungeonPlaceableVariant BlackChestVariant = new DungeonPlaceableVariant(); BlackChestVariant.percentChance = 0.1f; BlackChestVariant.unitOffset = new Vector2(0.5f, 0.5f); BlackChestVariant.enemyPlaceableGuid = string.Empty; BlackChestVariant.pickupObjectPlaceableId = -1; BlackChestVariant.forceBlackPhantom = false; BlackChestVariant.addDebrisObject = false; BlackChestVariant.prerequisites = null; BlackChestVariant.materialRequirements = null; BlackChestVariant.nonDatabasePlaceable = Chest_Black; DungeonPlaceableVariant RainbowChestVariant = new DungeonPlaceableVariant(); RainbowChestVariant.percentChance = 0.005f; RainbowChestVariant.unitOffset = new Vector2(0.5f, 0.5f); RainbowChestVariant.enemyPlaceableGuid = string.Empty; RainbowChestVariant.pickupObjectPlaceableId = -1; RainbowChestVariant.forceBlackPhantom = false; RainbowChestVariant.addDebrisObject = false; RainbowChestVariant.prerequisites = null; RainbowChestVariant.materialRequirements = null; RainbowChestVariant.nonDatabasePlaceable = Chest_Rainbow; DungeonPlaceableVariant ItemVariant = new DungeonPlaceableVariant(); ItemVariant.percentChance = spawnChance; if (CustomOffset.HasValue) { ItemVariant.unitOffset = CustomOffset.Value; } else { ItemVariant.unitOffset = Vector2.zero; } // ItemVariant.unitOffset = new Vector2(0.5f, 0.8f); ItemVariant.enemyPlaceableGuid = string.Empty; ItemVariant.pickupObjectPlaceableId = itemID; ItemVariant.forceBlackPhantom = false; if (itemHasDebrisObject) { ItemVariant.addDebrisObject = true; } else { ItemVariant.addDebrisObject = false; } RainbowChestVariant.prerequisites = null; RainbowChestVariant.materialRequirements = null; List <DungeonPlaceableVariant> ChestTiers = new List <DungeonPlaceableVariant>(); ChestTiers.Add(BrownChestVariant); ChestTiers.Add(BlueChestVariant); ChestTiers.Add(GreenChestVariant); ChestTiers.Add(SynergyChestVariant); ChestTiers.Add(RedChestVariant); ChestTiers.Add(BlackChestVariant); ChestTiers.Add(RainbowChestVariant); DungeonPlaceableVariant EnemyVariant = new DungeonPlaceableVariant(); EnemyVariant.percentChance = spawnChance; EnemyVariant.unitOffset = Vector2.zero; EnemyVariant.enemyPlaceableGuid = EnemyGUID; EnemyVariant.pickupObjectPlaceableId = -1; EnemyVariant.forceBlackPhantom = false; EnemyVariant.addDebrisObject = false; EnemyVariant.prerequisites = null; EnemyVariant.materialRequirements = null; List <DungeonPlaceableVariant> EnemyTiers = new List <DungeonPlaceableVariant>(); EnemyTiers.Add(EnemyVariant); List <DungeonPlaceableVariant> ItemTiers = new List <DungeonPlaceableVariant>(); ItemTiers.Add(ItemVariant); DungeonPlaceable m_cachedCustomPlacable = ScriptableObject.CreateInstance <DungeonPlaceable>(); m_cachedCustomPlacable.name = "CustomChestPlacable"; if (spawnsEnemy | useExternalPrefab) { m_cachedCustomPlacable.width = 2; m_cachedCustomPlacable.height = 2; } else if (spawnsItem) { m_cachedCustomPlacable.width = 1; m_cachedCustomPlacable.height = 1; } else { m_cachedCustomPlacable.width = 4; m_cachedCustomPlacable.height = 1; } m_cachedCustomPlacable.roomSequential = false; m_cachedCustomPlacable.respectsEncounterableDifferentiator = true; m_cachedCustomPlacable.UsePrefabTransformOffset = false; m_cachedCustomPlacable.isPassable = true; if (spawnsItem) { m_cachedCustomPlacable.MarkSpawnedItemsAsRatIgnored = true; } else { m_cachedCustomPlacable.MarkSpawnedItemsAsRatIgnored = false; } m_cachedCustomPlacable.DebugThisPlaceable = false; if (useExternalPrefab && ObjectPrefab != null) { DungeonPlaceableVariant ExternalObjectVariant = new DungeonPlaceableVariant(); ExternalObjectVariant.percentChance = spawnChance; if (CustomOffset.HasValue) { ExternalObjectVariant.unitOffset = CustomOffset.Value; } else { ExternalObjectVariant.unitOffset = Vector2.zero; } ExternalObjectVariant.enemyPlaceableGuid = string.Empty; ExternalObjectVariant.pickupObjectPlaceableId = -1; ExternalObjectVariant.forceBlackPhantom = false; ExternalObjectVariant.addDebrisObject = false; ExternalObjectVariant.nonDatabasePlaceable = ObjectPrefab; List <DungeonPlaceableVariant> ExternalObjectTiers = new List <DungeonPlaceableVariant>(); ExternalObjectTiers.Add(ExternalObjectVariant); m_cachedCustomPlacable.variantTiers = ExternalObjectTiers; } else if (spawnsEnemy) { m_cachedCustomPlacable.variantTiers = EnemyTiers; } else if (spawnsItem) { m_cachedCustomPlacable.variantTiers = ItemTiers; } else { m_cachedCustomPlacable.variantTiers = ChestTiers; } return(m_cachedCustomPlacable); }
private IEnumerator Trigger() { if (m_triggered) { yield break; } if (!string.IsNullOrEmpty(TriggerAnimation)) { spriteAnimator.Play(TriggerAnimation); } if (!string.IsNullOrEmpty(TriggerSFX)) { AkSoundEngine.PostEvent(TriggerSFX, gameObject); } m_triggered = true; Vector2 SpawnOffset = Vector2.zero; if (EnemySpawnOffset.HasValue) { SpawnOffset = EnemySpawnOffset.Value; } if (TriggerVFX) { SpawnManager.SpawnVFX(TriggerVFX, specRigidbody.UnitCenter + SpawnOffset, Quaternion.identity); } if (useAirDropSpawn) { EmergencyCrateController spawnedEnemyCrate = null; if (!EnemySpawnPlacableOverride) { RobotDaveIdea targetIdea = (!GameManager.Instance.Dungeon.UsesCustomFloorIdea) ? GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultProceduralIdea : GameManager.Instance.Dungeon.FloorIdea; GameObject eCrateInstance = ExpandUtility.SpawnAirDrop(m_room, sprite.WorldCenter, null, targetIdea.ValidEasyEnemyPlaceables[UnityEngine.Random.Range(0, targetIdea.ValidEasyEnemyPlaceables.Length)], 0.2f); if (eCrateInstance) { spawnedEnemyCrate = eCrateInstance.GetComponent <EmergencyCrateController>(); } // spawnedEnemyCrate = EnemyAirDrop(m_room, sprite.WorldCenter, targetIdea.ValidEasyEnemyPlaceables[UnityEngine.Random.Range(0, targetIdea.ValidEasyEnemyPlaceables.Length)]); } else { // spawnedEnemyCrate = EnemyAirDrop(m_room, sprite.WorldCenter, EnemySpawnPlacableOverride); GameObject eCrateInstance = ExpandUtility.SpawnAirDrop(m_room, sprite.WorldCenter, null, EnemySpawnPlacableOverride, 0.2f); if (eCrateInstance) { spawnedEnemyCrate = eCrateInstance.GetComponent <EmergencyCrateController>(); } } if (!m_room.IsSealed && spawnedEnemyCrate) { m_room.npcSealState = RoomHandler.NPCSealState.SealAll; m_room.SealRoom(); } yield return(new WaitForSeconds(2.25f)); DestroyMushroom(false); if (spawnedEnemyCrate) { while (ReflectionHelpers.ReflectGetField <bool?>(typeof(EmergencyCrateController), "m_hasBeenTriggered", spawnedEnemyCrate).HasValue&& ReflectionHelpers.ReflectGetField <bool?>(typeof(EmergencyCrateController), "m_hasBeenTriggered", spawnedEnemyCrate).Value) { if (!spawnedEnemyCrate) { break; } yield return(null); } } yield return(new WaitForSeconds(1f)); m_room.npcSealState = RoomHandler.NPCSealState.SealNone; if (spriteAnimator.IsPlaying(BreakAnimation)) { while (spriteAnimator.IsPlaying(BreakAnimation)) { yield return(null); } } Destroy(gameObject); } else { AIActor selectedEnemy = null; if (EnemySpawnPlacableOverride) { DungeonPlaceableVariant enemyVariant = EnemySpawnPlacableOverride.SelectFromTiersFull(); selectedEnemy = enemyVariant.GetOrLoadPlaceableObject.GetComponent <AIActor>(); } else { RobotDaveIdea targetIdea = (!GameManager.Instance.Dungeon.UsesCustomFloorIdea) ? GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultProceduralIdea : GameManager.Instance.Dungeon.FloorIdea; DungeonPlaceable backupEnemyPlaceable = targetIdea.ValidEasyEnemyPlaceables[UnityEngine.Random.Range(0, targetIdea.ValidEasyEnemyPlaceables.Length)]; DungeonPlaceableVariant enemyVariant = backupEnemyPlaceable.SelectFromTiersFull(); } if (selectedEnemy) { AIActor targetAIActor = AIActor.Spawn(selectedEnemy, specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor) + SpawnOffset.ToIntVector2(), m_room, true, AIActor.AwakenAnimationType.Spawn, true); targetAIActor.reinforceType = AIActor.ReinforceType.SkipVfx; targetAIActor.HandleReinforcementFallIntoRoom(0.8f); if (!m_room.IsSealed) { m_room.SealRoom(); } while (targetAIActor.IsGone) { yield return(null); } DestroyMushroom(); } } yield break; }
private IEnumerator Trigger() { if (m_triggered) { yield break; } if (!string.IsNullOrEmpty(TriggerAnimation)) { spriteAnimator.Play(TriggerAnimation); } if (!string.IsNullOrEmpty(TriggerSFX)) { AkSoundEngine.PostEvent(TriggerSFX, gameObject); } m_triggered = true; Vector2 SpawnOffset = Vector2.zero; if (EnemySpawnOffset.HasValue) { SpawnOffset = EnemySpawnOffset.Value; } if (TriggerVFX) { if (useAirDropSpawn) { m_TriggerVFX = SpawnManager.SpawnVFX(TriggerVFX, specRigidbody.UnitBottomCenter - new Vector2(0, 0.25f), Quaternion.identity); } else { m_TriggerVFX = SpawnManager.SpawnVFX(TriggerVFX, specRigidbody.UnitBottomCenter + SpawnOffset, Quaternion.identity); } } if (useAirDropSpawn) { Vector2 SpawnPosition = transform.position; DungeonPlaceable selectedPlacable = null; bool isExplodyBarrel = false; if (EnemySpawnPlacableOverride) { selectedPlacable = EnemySpawnPlacableOverride; } else { RobotDaveIdea targetIdea = (!GameManager.Instance.Dungeon.UsesCustomFloorIdea) ? GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultProceduralIdea : GameManager.Instance.Dungeon.FloorIdea; selectedPlacable = BraveUtility.RandomElement(targetIdea.ValidEasyEnemyPlaceables); } DungeonPlaceableVariant selectedVarient = BraveUtility.RandomElement(selectedPlacable.variantTiers); if (selectedVarient != null && UnityEngine.Random.value > 0.2f) { if (!string.IsNullOrEmpty(selectedVarient.enemyPlaceableGuid)) { GameObject enemyObject = Instantiate(EnemyDatabase.GetOrLoadByGuid(selectedVarient.enemyPlaceableGuid).gameObject, SpawnPosition, Quaternion.identity); enemyObject.GetComponent <AIActor>().ConfigureOnPlacement(m_room); ExpandUtility.SpawnParaDrop(m_room, SpawnPosition, enemyObject, DropHorizontalOffset: 10, useLandingVFX: false); } else if (selectedVarient.nonDatabasePlaceable) { GameObject ParaDroppedObject = Instantiate(selectedVarient.nonDatabasePlaceable, SpawnPosition, Quaternion.identity); ExpandUtility.SpawnParaDrop(m_room, SpawnPosition, ParaDroppedObject, DropHorizontalOffset: 10, useLandingVFX: false); } else { ExpandUtility.SpawnParaDrop(m_room, SpawnPosition, DropHorizontalOffset: 10, useLandingVFX: false); isExplodyBarrel = true; } } else { ExpandUtility.SpawnParaDrop(m_room, SpawnPosition, DropHorizontalOffset: 10, useLandingVFX: false); isExplodyBarrel = true; } if (!m_room.IsSealed && !isExplodyBarrel) { m_room.SealRoom(); } yield return(null); DestroyMushroom(); } else { AIActor selectedEnemy = null; if (EnemySpawnPlacableOverride) { DungeonPlaceableVariant enemyVariant = EnemySpawnPlacableOverride.SelectFromTiersFull(); selectedEnemy = enemyVariant.GetOrLoadPlaceableObject.GetComponent <AIActor>(); } else { RobotDaveIdea targetIdea = (!GameManager.Instance.Dungeon.UsesCustomFloorIdea) ? GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultProceduralIdea : GameManager.Instance.Dungeon.FloorIdea; DungeonPlaceable backupEnemyPlaceable = targetIdea.ValidEasyEnemyPlaceables[UnityEngine.Random.Range(0, targetIdea.ValidEasyEnemyPlaceables.Length)]; DungeonPlaceableVariant enemyVariant = backupEnemyPlaceable.SelectFromTiersFull(); } if (selectedEnemy) { AIActor targetAIActor = AIActor.Spawn(selectedEnemy, specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor) + SpawnOffset.ToIntVector2(), m_room, true, AIActor.AwakenAnimationType.Spawn, true); targetAIActor.reinforceType = AIActor.ReinforceType.SkipVfx; targetAIActor.HandleReinforcementFallIntoRoom(0.8f); if (!m_room.IsSealed) { m_room.SealRoom(); } while (targetAIActor.IsGone) { yield return(null); } DestroyMushroom(); } } yield break; }