migration from new repo
This commit is contained in:
commit
423134a840
26930 changed files with 3458568 additions and 0 deletions
88
Assets/_/Features/UI/Runtime/Quests/QuestCardUI.cs
Normal file
88
Assets/_/Features/UI/Runtime/Quests/QuestCardUI.cs
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Core.Runtime;
|
||||
using EventSystem.Runtime;
|
||||
using Item.Runtime;
|
||||
using Quests.Runtime;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GameUI.Runtime
|
||||
{
|
||||
public class QuestCardUI : BaseMonobehaviour
|
||||
{
|
||||
|
||||
#region Publics
|
||||
|
||||
[Header("UI References")]
|
||||
public TMPro.TextMeshProUGUI m_title;
|
||||
public TMPro.TextMeshProUGUI m_description;
|
||||
public TMPro.TextMeshProUGUI m_objective;
|
||||
public TMPro.TextMeshProUGUI m_duration;
|
||||
public TMPro.TextMeshProUGUI m_difficulty;
|
||||
public TMPro.TextMeshProUGUI m_reward;
|
||||
public TMPro.TextMeshProUGUI m_minLevel;
|
||||
|
||||
public QuestClass Quest => _quest;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Unity API
|
||||
|
||||
void Start()
|
||||
{
|
||||
foreach (var txt in GetComponentsInChildren<TMP_Text>())
|
||||
{
|
||||
txt.text = LocalizationSystem.Instance.GetLocalizedText(txt.text);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Main Methods
|
||||
|
||||
public void Setup(QuestClass quest)
|
||||
{
|
||||
_quest = quest;
|
||||
m_title.text = quest.Name;
|
||||
m_description.text = quest.Description;
|
||||
m_objective.text = quest.Objective;
|
||||
//m_duration.text = quest.Duration.ToString();
|
||||
m_difficulty.text = quest.Difficulty.ToString();
|
||||
m_reward.text = RewardsListJoined(quest.Rewards);
|
||||
m_minLevel.text = quest.MinLevel.ToString();
|
||||
}
|
||||
|
||||
public void AcceptQuest()
|
||||
{
|
||||
List<QuestClass> quests = GetFact<List<QuestClass>>("quests");
|
||||
quests.Add(_quest);
|
||||
SaveFacts();
|
||||
QuestSignals.RaiseRefreshQuests();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Utils
|
||||
|
||||
string RewardsListJoined(List<ItemReward> rewards)
|
||||
{
|
||||
return string.Join(", ", rewards.Select(r => r.m_itemDefinition.DisplayNameKey != null
|
||||
? LocalizationSystem.Instance.GetLocalizedText(r.m_itemDefinition.DisplayNameKey)
|
||||
: "???"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Privates and Protected
|
||||
|
||||
QuestClass _quest;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue