| | 1 | | using DCL.Interface; |
| | 2 | | using System; |
| | 3 | | using TMPro; |
| | 4 | | using UnityEngine; |
| | 5 | | using UnityEngine.UI; |
| | 6 | |
|
| | 7 | | namespace DCL.Huds.QuestsPanel |
| | 8 | | { |
| | 9 | | public class QuestsPanelTask_Numeric : MonoBehaviour, IQuestsPanelTask |
| | 10 | | { |
| | 11 | | [SerializeField] internal TextMeshProUGUI taskName; |
| | 12 | | [SerializeField] internal TextMeshProUGUI progressText; |
| | 13 | | [SerializeField] internal Image ongoingProgress; |
| | 14 | | [SerializeField] internal Button jumpInButton; |
| | 15 | | [SerializeField] internal Toggle status; |
| | 16 | | [SerializeField] internal Color ongoinColor; |
| | 17 | | [SerializeField] internal Color completedcolor; |
| | 18 | |
|
| | 19 | | internal TaskPayload_Numeric payload; |
| | 20 | | private Action jumpInDelegate; |
| | 21 | |
|
| 4 | 22 | | public void Awake() { jumpInButton.onClick.AddListener(() => { jumpInDelegate?.Invoke(); }); } |
| | 23 | |
|
| | 24 | | public void Populate( QuestModel quest, QuestTask task) |
| | 25 | | { |
| 2 | 26 | | payload = JsonUtility.FromJson<TaskPayload_Numeric>(task.payload); |
| | 27 | |
|
| 2 | 28 | | jumpInButton.gameObject.SetActive(task.progress < 1 && !string.IsNullOrEmpty(task.coordinates)); |
| 2 | 29 | | jumpInDelegate = () => |
| | 30 | | { |
| 0 | 31 | | QuestsUIAnalytics.SendJumpInPressed(quest.id, task.id, task.coordinates, QuestsUIAnalytics.UIContext.Que |
| 0 | 32 | | WebInterface.SendChatMessage(new ChatMessage |
| | 33 | | { |
| | 34 | | messageType = ChatMessage.Type.NONE, |
| | 35 | | recipient = string.Empty, |
| | 36 | | body = $"/goto {task.coordinates}", |
| | 37 | | }); |
| 0 | 38 | | }; |
| | 39 | |
|
| 2 | 40 | | taskName.text = task.name; |
| 2 | 41 | | progressText.text = $"{payload.current}/{payload.end}"; |
| 2 | 42 | | status.isOn = task.progress >= 1; |
| 2 | 43 | | ongoingProgress.transform.localScale = new Vector3(task.progress, 1, 1); |
| 2 | 44 | | ongoingProgress.color = task.progress < 1 ? ongoinColor : completedcolor; |
| 2 | 45 | | } |
| | 46 | | } |
| | 47 | | } |