91 lines
2.1 KiB
C#
91 lines
2.1 KiB
C#
using System;
|
|
using Core.Runtime;
|
|
using Quests.Runtime;
|
|
using UnityEngine;
|
|
|
|
namespace GameUI.Runtime
|
|
{
|
|
public class QuestMini : BaseMonoBehaviour
|
|
{
|
|
|
|
#region Publics
|
|
|
|
public GameObject m_check;
|
|
public GameObject m_hourglass;
|
|
|
|
#endregion
|
|
|
|
|
|
#region Unity API
|
|
|
|
void OnEnable()
|
|
{
|
|
QuestManager.OnQuestCompleted += HandleQuestState;
|
|
QuestManager.OnCheckStateQuest += HandleQuestState;
|
|
// Re-synchroniser l'état quand l'UI s'active
|
|
if (QuestManager.Instance != null)
|
|
{
|
|
QuestManager.Instance.CheckStateQuest();
|
|
}
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
QuestManager.OnQuestCompleted -= HandleQuestState;
|
|
QuestManager.OnCheckStateQuest -= HandleQuestState;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region Main Methods
|
|
|
|
public void SetQuestName(string name)
|
|
{
|
|
_questName = name;
|
|
}
|
|
|
|
public bool MatchesQuest(string questNameToCheck)
|
|
{
|
|
return _questName == questNameToCheck;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region Utils
|
|
|
|
/* Fonctions privées utiles */
|
|
void HandleQuestState(QuestClass quest)
|
|
{
|
|
if (!MatchesQuest(quest.Name)) return;
|
|
Info($"Etat de la quete {quest.Name} : {quest.State}", Color.burlywood);
|
|
switch (quest.State)
|
|
{
|
|
case QuestStateEnum.Disponible:
|
|
m_check.SetActive(false);
|
|
m_hourglass.SetActive(false);
|
|
break;
|
|
case QuestStateEnum.InProgress:
|
|
m_check.SetActive(false);
|
|
m_hourglass.SetActive(true);
|
|
break;
|
|
case QuestStateEnum.Completed:
|
|
Info("Completed !!", Color.green);
|
|
m_check.SetActive(true);
|
|
m_hourglass.SetActive(false);
|
|
break;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region Privates and Protected
|
|
|
|
// Variables privées
|
|
string _questName;
|
|
|
|
#endregion
|
|
}
|
|
}
|