RoomEncounterConfig.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. using UnityEngine;
  2. namespace MazeGen
  3. {
  4. /// <summary>
  5. /// Configuration for monster encounters in a room. Attached to MazeSceneBuilder settings
  6. /// to control if/how many monsters spawn in newly generated rooms.
  7. /// </summary>
  8. [System.Serializable]
  9. public class RoomEncounterConfig
  10. {
  11. [SerializeField] private bool _enableEncounters = true;
  12. [SerializeField] private float _encounterChance = 0.7f; // Probability this room has monsters (0-1)
  13. [SerializeField] private int _minMonstersPerRoom = 1;
  14. [SerializeField] private int _maxMonstersPerRoom = 3;
  15. [SerializeField] private Monster[] _monsterPool; // Which monsters can spawn here
  16. public bool EnableEncounters => _enableEncounters;
  17. public float EncounterChance => _encounterChance;
  18. public int MinMonstersPerRoom => _minMonstersPerRoom;
  19. public int MaxMonstersPerRoom => _maxMonstersPerRoom;
  20. public Monster[] MonsterPool => _monsterPool ?? new Monster[0];
  21. /// <summary>Determine if this room should have an encounter.</summary>
  22. public bool ShouldHaveEncounter()
  23. {
  24. if (!_enableEncounters || _monsterPool == null || _monsterPool.Length == 0)
  25. return false;
  26. return Random.value < _encounterChance;
  27. }
  28. }
  29. }