using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
public class QYAchievementCell : CellView
|
{
|
[SerializeField] Text rankText;
|
[SerializeField] Image rankImg;
|
[SerializeField] ItemCell[] itemCells;
|
[SerializeField] Transform notActiveText;
|
[SerializeField] Button getBtn;
|
[SerializeField] Transform finishImg;
|
|
public void Display(int rank)
|
{
|
var rankAwards = QunyingManager.Instance.achievementAwards[rank];
|
|
if (rank <= 3)
|
{
|
rankImg.SetActive(true);
|
rankText.SetActive(false);
|
rankImg.SetSprite($"Rank{rank}");
|
}
|
else
|
{
|
rankImg.SetActive(false);
|
rankText.SetActive(true);
|
rankText.text = rank.ToString();
|
}
|
|
for (int i = 0; i < itemCells.Length; i++)
|
{
|
var itemCell = itemCells[i];
|
if (i < rankAwards.Length)
|
{
|
itemCell.SetActive(true);
|
int itemID = rankAwards[i][0];
|
itemCell.Init(new ItemCellModel(itemID, true, rankAwards[i][1]));
|
itemCell.button.SetListener(() => ItemTipUtility.Show(itemID));
|
}
|
else
|
{
|
itemCell.SetActive(false);
|
}
|
}
|
|
var state = QunyingManager.Instance.GetAchievementState(rank);
|
if (state == 1)
|
{
|
notActiveText.SetActive(false);
|
getBtn.SetActive(true);
|
finishImg.SetActive(false);
|
}
|
else if (state == 2)
|
{
|
notActiveText.SetActive(false);
|
getBtn.SetActive(false);
|
finishImg.SetActive(true);
|
}
|
else
|
{
|
notActiveText.SetActive(true);
|
getBtn.SetActive(false);
|
finishImg.SetActive(false);
|
}
|
|
getBtn.AddListener(() =>
|
{
|
var pack = new CA504_tagCMPlayerGetReward();
|
pack.RewardType = 7;
|
GameNetSystem.Instance.SendInfo(pack);
|
});
|
}
|
|
}
|