using System.Collections.Generic; using UnityEngine; namespace CharacterSystem { [CreateAssetMenu(fileName = "ReplicasContainer", menuName = "Scriptable Objects/ReplicasContainer")] public class ReplicasContainer : ScriptableObject { [SerializeField] private ReplicasSet _appearReplicas; [SerializeField] private ReplicasSet _playerTurnReplicas; [SerializeField] private ReplicasSet _botTurnReplicas; [SerializeField] private ReplicasSet _playerWinReplicas; [SerializeField] private ReplicasSet _botWinReplicas; [SerializeField] private ReplicasSet _returnReplicas; [SerializeField] private ReplicasSet _drawReplicas; private Dictionary _replicaDictionary; private bool _isInit = false; public static readonly IReadOnlyDictionary ShouldForceMessage = new Dictionary { { GameEvent.Appear, false }, { GameEvent.PlayerTurn, false }, { GameEvent.BotTurn, false }, { GameEvent.PlayerWin, true }, { GameEvent.BotWin, true }, { GameEvent.Return, true }, { GameEvent.Draw, true } }; public void Initialize() { _replicaDictionary = new Dictionary { { GameEvent.Appear, _appearReplicas }, { GameEvent.PlayerTurn, _playerTurnReplicas }, { GameEvent.BotTurn, _botTurnReplicas }, { GameEvent.PlayerWin, _playerWinReplicas }, { GameEvent.BotWin, _botWinReplicas }, { GameEvent.Return, _returnReplicas }, { GameEvent.Draw, _drawReplicas } }; _isInit = true; } public Replica GetNextReplica(GameEvent type) => _replicaDictionary[type].GetNext(); public bool WillPlay(GameEvent type) { if (_isInit == false) { Debug.LogError($"Не инициализирован контейнер реплик {name}"); return false; } var set = _replicaDictionary[type]; if (set == null) { Debug.LogWarning($"Не заполнен набор реплик {type}"); return false; } return Random.Range(0f, 1f) < set.PlayProbability; } } }