using LitJson;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.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] Image m_GotoGuide;
|
[SerializeField] Transform m_ContainerCutline;
|
[SerializeField] VerticalLayoutGroup m_ContainerTasks;
|
[SerializeField] List<Text> m_TaskNames;
|
[SerializeField] Transform awardObj;
|
[SerializeField] List<ItemCell> itemCells;
|
[SerializeField] Button getAward;
|
[SerializeField] ImageEx getAwardImg;
|
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<TreasureModel>(); } }
|
TaskModel taskModel { get { return ModelCenter.Instance.GetModel<TaskModel>(); } }
|
RoleModel roleModel { get { return ModelCenter.Instance.GetModel<RoleModel>(); } }
|
|
private void Awake()
|
{
|
m_Goto.AddListener(Goto);
|
}
|
|
private void OnDisable()
|
{
|
StopAllCoroutines();
|
}
|
|
public void Display(int clue, bool animationStep, float displayTime)
|
{
|
//m_GotoGuide.SetActive(model.isClickInduction);
|
//var config = TreasureConfig.Get(model.selectedTreasure);
|
//Dictionary<int, List<int>> clues;
|
//if (!model.TryGetTreasureClues(model.selectedTreasure, out clues)
|
// || !clues.ContainsKey(clue))
|
//{
|
// return;
|
//}
|
//var tasks = clues[clue];
|
//var taskConfig = TaskListConfig.Get(tasks[0]);
|
//this.gameObject.name = StringUtility.Contact("HumanTreasureTaskCell_", taskConfig.TaskID);
|
//m_ClueName.text = taskConfig.clueName;
|
|
//var clueState = model.GetClueState(model.selectedTreasure, clue);
|
|
//m_ContainerCollected.SetActive(clueState == 2);
|
//m_ContainerCollecting.SetActive(clueState == 1);
|
//m_ContainerTasks.SetActive(clueState == 1 && tasks.Count > 0);
|
//if (clueState == 1 && tasks.Count > 0)
|
//{
|
// CreateTaskNames(tasks.Count);
|
// var taskId = taskModel.GetLatestMainTaskId();
|
// int curTaskIndex = TaskListConfig.GetMissionIndex(taskId);
|
|
// for (int i = 0; i < m_TaskNames.Count; i++)
|
// {
|
// m_TaskNames[i].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;
|
// int lastTaskIndex = TaskListConfig.GetMissionIndex(tasks[i]);
|
// m_TaskNames[i].color = lastTaskIndex >= curTaskIndex ? 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.SetActive(lastClue != clue);
|
|
//if (!animationStep || !gameObject.activeInHierarchy)
|
//{
|
// m_AlphaTween.SetEndState();
|
// m_EffectGoto.SetActive(true);
|
//}
|
//else
|
//{
|
// m_AlphaTween.SetStartState();
|
// StartCoroutine(Co_Display(displayTime));
|
// m_EffectGoto.SetActive(false);
|
//}
|
|
//TaskListConfig awardTaskConfig = null;
|
//for (int i = 0; i < tasks.Count; i++)
|
//{
|
// var task = tasks[i];
|
// var taskConfig1 = TaskListConfig.Get(task);
|
// if (taskConfig1.AwardID != 0)
|
// {
|
// awardTaskConfig = taskConfig1;
|
// break;
|
// }
|
//}
|
//if (awardTaskConfig != null && awardTaskConfig.AwardID != 0)
|
//{
|
// awardObj.SetActive(true);
|
// var awardConfig = CustomAwardConfig.Get(awardTaskConfig.AwardID);
|
// var awardJson = JsonMapper.ToObject<int[][]>(awardConfig.AwardItemList);
|
// for (int i = 0; i < itemCells.Count; i++)
|
// {
|
// if (i < awardJson.Length)
|
// {
|
// itemCells[i].SetActive(true);
|
// int itemID = awardJson[i][0];
|
// itemCells[i].Init(new ItemCellModel(itemID, false, (ulong)awardJson[i][1]));
|
// itemCells[i].button.SetListener(() =>
|
// {
|
// ItemTipUtility.Show(itemID);
|
// });
|
// }
|
// else
|
// {
|
// itemCells[i].SetActive(false);
|
// }
|
// }
|
// var state = roleModel.GetCustomAwardState(awardTaskConfig.AwardID);
|
|
// getAwardImg.SetActive(state == 2);
|
// getAward.SetActive(state == 1);
|
// getAward.SetListener(() => {
|
|
// model.RequestTheTreasureAllAward(clues);
|
// });
|
//}
|
//else
|
//{
|
// awardObj.SetActive(false);
|
//}
|
}
|
|
IEnumerator Co_Display(float time)
|
{
|
yield return WaitingForSecondConst.GetWaitForSeconds(time);
|
m_EffectAppear.Play();
|
m_AlphaTween.Play(OnComplete);
|
}
|
|
private void OnComplete()
|
{
|
m_EffectGoto.SetActive(true);
|
}
|
|
private void Goto()
|
{
|
WindowJumpMgr.Instance.ClearJumpData();
|
WindowCenter.Instance.Close<TreasureBaseWin>();
|
WindowCenter.Instance.Open<MainInterfaceWin>();
|
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<Text>();
|
go.transform.SetParentEx(m_ContainerTasks.transform, Vector3.zero, Quaternion.identity, Vector3.one);
|
m_TaskNames.Add(instance);
|
}
|
}
|
}
|
}
|
}
|
|