using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.UI; namespace Snxxz.UI { public class HumanTreasureTaskCell : CellView { [SerializeField] UIEffect m_EffectAppear; [SerializeField] UIEffect m_EffectGoto; [SerializeField] UIAlphaTween m_AlphaTween; [SerializeField] Text m_ClueName; [SerializeField] Transform m_ContainerCollected; [SerializeField] Transform m_ContainerCollecting; [SerializeField] Button m_Goto; [SerializeField] Transform m_ContainerCutline; public static int lastClue = 0; TreasureModel model { get { return ModelCenter.Instance.GetModel(); } } TaskModel taskModel { get { return ModelCenter.Instance.GetModel(); } } private void Awake() { m_Goto.AddListener(Goto); } private void OnDisable() { StopAllCoroutines(); } public void Display(int clue, bool animationStep, float displayTime) { var config = TreasureConfig.Get(model.selectedTreasure); Dictionary> clues; if (!model.TryGetTreasureClues(model.selectedTreasure, out clues) || !clues.ContainsKey(clue)) { return; } var tasks = clues[clue]; var taskConfig = TaskListConfig.Get(tasks[0]); m_ClueName.text = taskConfig.clueName; var clueState = model.GetClueState(model.selectedTreasure, clue); m_ContainerCollected.gameObject.SetActive(clueState == 2); m_ContainerCollecting.gameObject.SetActive(clueState == 1); m_ClueName.color = clueState == 0 ? UIHelper.s_Gray : UIHelper.s_LightYellow; m_ContainerCutline.gameObject.SetActive(lastClue != clue); if (!animationStep || !gameObject.activeInHierarchy) { m_AlphaTween.SetEndState(); m_EffectGoto.gameObject.SetActive(true); } else { m_AlphaTween.SetStartState(); StartCoroutine(Co_Display(displayTime)); m_EffectGoto.gameObject.SetActive(false); } } IEnumerator Co_Display(float time) { yield return WaitingForSecondConst.GetWaitForSeconds(time); m_EffectAppear.Play(); m_AlphaTween.Play(OnComplete); } private void OnComplete() { m_EffectGoto.gameObject.SetActive(true); } private void Goto() { WindowJumpMgr.Instance.ClearJumpData(); WindowCenter.Instance.Close(); WindowCenter.Instance.Open(); var taskId = taskModel.GetLatestMainTaskId(); taskModel.TaskMove(taskId); } } }