| 123456789101112131415161718192021222324252627282930313233 |
- using UnityEngine;
- namespace MazeGen
- {
- /// <summary>
- /// Configuration for monster encounters in a room. Attached to MazeSceneBuilder settings
- /// to control if/how many monsters spawn in newly generated rooms.
- /// </summary>
- [System.Serializable]
- public class RoomEncounterConfig
- {
- [SerializeField] private bool _enableEncounters = true;
- [SerializeField] private float _encounterChance = 0.7f; // Probability this room has monsters (0-1)
- [SerializeField] private int _minMonstersPerRoom = 1;
- [SerializeField] private int _maxMonstersPerRoom = 3;
- [SerializeField] private Monster[] _monsterPool; // Which monsters can spawn here
- public bool EnableEncounters => _enableEncounters;
- public float EncounterChance => _encounterChance;
- public int MinMonstersPerRoom => _minMonstersPerRoom;
- public int MaxMonstersPerRoom => _maxMonstersPerRoom;
- public Monster[] MonsterPool => _monsterPool ?? new Monster[0];
- /// <summary>Determine if this room should have an encounter.</summary>
- public bool ShouldHaveEncounter()
- {
- if (!_enableEncounters || _monsterPool == null || _monsterPool.Length == 0)
- return false;
- return Random.value < _encounterChance;
- }
- }
- }
|