Le quêtes sont désormais bien retirés quand choisis.
This commit is contained in:
parent
9f2e4c1063
commit
838f91ede7
7 changed files with 107 additions and 24 deletions
|
|
@ -168,17 +168,31 @@ namespace Quests.Runtime
|
|||
public void InitializeEvents(QuestEventPackSO pack)
|
||||
{
|
||||
ActiveEvents.Clear();
|
||||
|
||||
|
||||
if (pack == null || pack.availableEvents == null || pack.availableEvents.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var pool = new List<QuestEventSO>(pack.availableEvents);
|
||||
int toPick = Mathf.Min(pack.maxEventsToPick, pool.Count);
|
||||
|
||||
int currentTime = 0;
|
||||
if (QuestManager.Instance != null)
|
||||
{
|
||||
currentTime = QuestManager.Instance.currentTimeInQuest;
|
||||
}
|
||||
|
||||
for (int i = 0; i < toPick; i++)
|
||||
{
|
||||
int index = UnityEngine.Random.Range(0, pool.Count);
|
||||
var pickedSO = pool[index];
|
||||
pool.RemoveAt(index);
|
||||
|
||||
ActiveEvents.Add(pickedSO.ToQuestEventClass(QuestManager.Instance.currentTimeInQuest));
|
||||
if (pickedSO != null)
|
||||
{
|
||||
ActiveEvents.Add(pickedSO.ToQuestEventClass(currentTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue