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
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Adventurer.Runtime;
|
||||
|
|
@ -12,9 +13,16 @@ namespace Quests.Runtime
|
|||
public class QuestManager : BaseMonobehaviour
|
||||
{
|
||||
#region Singleton
|
||||
|
||||
public static QuestManager Instance { get; set; }
|
||||
|
||||
static QuestManager _instance;
|
||||
public static QuestManager Instance => _instance ??= new QuestManager();
|
||||
void OnDestroy()
|
||||
{
|
||||
if (Instance == this)
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -25,25 +33,57 @@ namespace Quests.Runtime
|
|||
public static event Action<QuestClass> OnEventFromQuest;
|
||||
public static event Action<List<QuestTemplate>> OnAvailableQuestsUpdated;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Unity API
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (Instance != null && Instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
_disponibleQuests = _questDatabase.GetAll().SelectMany(f => f.questTemplates).Select(t => t.ToQuestClass(QuestStateEnum.Disponible)).ToList();
|
||||
|
||||
// Ensure quest lists are initialized to avoid null issues in consumers
|
||||
if (_activeQuests == null) _activeQuests = new List<QuestClass>();
|
||||
if (_completedQuests == null) _completedQuests = new List<QuestClass>();
|
||||
if (_disponibleQuests == null) _disponibleQuests = new List<QuestClass>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
QuestClass _currentQuest;
|
||||
List<QuestClass> _activeQuests;
|
||||
List<QuestClass> _disponibleQuests;
|
||||
List<QuestClass> _completedQuests;
|
||||
QuestClass _currentQuest;
|
||||
|
||||
public QuestClass CurrentQuest
|
||||
{
|
||||
get => _currentQuest;
|
||||
set => _currentQuest = value;
|
||||
}
|
||||
|
||||
public List<QuestClass> DisponibleQuests
|
||||
{
|
||||
get => _disponibleQuests;
|
||||
set => _disponibleQuests = value;
|
||||
}
|
||||
|
||||
List<QuestClass> _activeQuests;
|
||||
public List<QuestClass> ActiveQuests
|
||||
{
|
||||
get => _activeQuests;
|
||||
set => _activeQuests = value;
|
||||
}
|
||||
|
||||
List<QuestClass> _completedQuests;
|
||||
public List<QuestClass> CompletedQuests
|
||||
{
|
||||
get => _completedQuests;
|
||||
|
|
@ -183,7 +223,7 @@ namespace Quests.Runtime
|
|||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
#region Utils
|
||||
|
||||
/// <summary>
|
||||
/// Assigne des aventuriers à une quête
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue