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; [SerializeField] VerticalLayoutGroup m_ContainerTasks; [SerializeField] List m_TaskNames; public Text taskName { get { return m_TaskNames[0]; } } public VerticalLayoutGroup taskLayout { get { return m_ContainerTasks; } } 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_ContainerTasks.gameObject.SetActive(clueState == 1 && tasks.Count > 0); if (clueState == 1 && tasks.Count > 0) { CreateTaskNames(tasks.Count); var taskId = taskModel.GetLatestMainTaskId(); for (int i = 0; i < m_TaskNames.Count; i++) { m_TaskNames[i].gameObject.SetActive(i < tasks.Count); if (i < tasks.Count) { taskConfig = TaskListConfig.Get(tasks[i]); var taskInfoConfig = TASKINFOConfig.Get(taskConfig.TaskName); if (taskInfoConfig != null) { m_TaskNames[i].text = taskInfoConfig.show_writing; m_TaskNames[i].color = tasks[i] >= taskId ? UIHelper.s_Gray : UIHelper.s_LightYellow; } else { DebugEx.LogError("TASKINFOConfig 表格没有Key:" + taskConfig.TaskName); } } } } 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); } void CreateTaskNames(int count) { if (m_TaskNames.Count < count) { var delta = count - m_TaskNames.Count; for (int i = 0; i < delta; i++) { var go = GameObject.Instantiate(m_TaskNames[0].gameObject); var instance = go.GetComponent(); go.transform.SetParentEx(m_ContainerTasks.transform, Vector3.zero, Quaternion.identity, Vector3.one); m_TaskNames.Add(instance); } } } } }