| | 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_Single : MonoBehaviour, IQuestsPanelTask |
| | 10 | | { |
| | 11 | | [SerializeField] internal TextMeshProUGUI taskName; |
| | 12 | | [SerializeField] internal Toggle status; |
| | 13 | | [SerializeField] internal Button jumpInButton; |
| | 14 | | [SerializeField] internal TextMeshProUGUI progressText; |
| | 15 | | [SerializeField] internal Image ongoingProgress; |
| | 16 | | [SerializeField] internal Color ongoinColor; |
| | 17 | | [SerializeField] internal Color completedcolor; |
| | 18 | |
|
| | 19 | | internal TaskPayload_Single payload; |
| | 20 | |
|
| | 21 | | private Action jumpInDelegate; |
| | 22 | |
|
| 10 | 23 | | public void Awake() { jumpInButton.onClick.AddListener(() => { jumpInDelegate?.Invoke(); }); } |
| | 24 | |
|
| | 25 | | public void Populate( QuestModel quest, QuestTask task) |
| | 26 | | { |
| 5 | 27 | | payload = JsonUtility.FromJson<TaskPayload_Single>(task.payload); |
| | 28 | |
|
| 5 | 29 | | jumpInButton.gameObject.SetActive(task.progress < 1 && !string.IsNullOrEmpty(task.coordinates)); |
| 5 | 30 | | jumpInDelegate = () => |
| | 31 | | { |
| 0 | 32 | | WebInterface.SendChatMessage(new ChatMessage |
| | 33 | | { |
| | 34 | | messageType = ChatMessage.Type.NONE, |
| | 35 | | recipient = string.Empty, |
| | 36 | | body = $"/goto {task.coordinates}", |
| | 37 | | }); |
| | 38 | |
|
| 0 | 39 | | DataStore.i.HUDs.questsPanelVisible.Set(false); |
| 0 | 40 | | }; |
| | 41 | |
|
| 5 | 42 | | taskName.text = task.name; |
| 5 | 43 | | status.isOn = payload.isDone; |
| 5 | 44 | | progressText.text = $"{(int)task.progress}/1"; |
| 5 | 45 | | ongoingProgress.transform.localScale = new Vector3(task.progress, 1, 1); |
| 5 | 46 | | ongoingProgress.color = task.progress < 1 ? ongoinColor : completedcolor; |
| 5 | 47 | | } |
| | 48 | | } |
| | 49 | | } |