using System.Collections.Generic;
|
using UnityEngine;
|
|
public class TimeRushTaskCell : MonoBehaviour
|
{
|
[SerializeField] ButtonEx clickButton;
|
[SerializeField] TextEx titleText;
|
[SerializeField] ImageEx sliderImage;
|
[SerializeField] ImageEx maskImage;
|
[SerializeField] TextEx sliderText;
|
[SerializeField] ItemCell[] itemCells;
|
[SerializeField] ImageEx[] grays;
|
[SerializeField] RotationTween[] tweens;
|
[SerializeField] UIEffectPlayer uiEffectPlayer;
|
|
int awardIndex;
|
int roundType;
|
int tabType;
|
TimeRushManager manager { get { return TimeRushManager.Instance; } }
|
|
private void OnEnable()
|
{
|
manager.PlayAnimationSync += OnPlaySyncAnimation;
|
for (int i = 0; i < tweens.Length; i++)
|
{
|
tweens[i].Stop();
|
tweens[i].SetStartState();
|
}
|
|
if (!manager.TryGetOperationInfo(out var act))
|
return;
|
if (!act.TryGetRoundInfoByIndex(roundType, awardIndex, out var awardInfo, out int listIndex) || awardInfo.AwardItemList == null)
|
return;
|
int state = manager.GetAwardState(roundType, awardIndex);
|
for (int i = 0; i < tweens.Length; i++)
|
{
|
if (i < awardInfo.AwardItemList.Length)
|
{
|
if (state == 1)
|
{
|
tweens[i].Play();
|
}
|
}
|
}
|
|
}
|
|
private void OnDisable()
|
{
|
manager.PlayAnimationSync -= OnPlaySyncAnimation;
|
}
|
|
private void OnPlaySyncAnimation()
|
{
|
if (tabType != 1)
|
return;
|
for (int i = 0; i < tweens.Length; i++)
|
{
|
tweens[i].Stop();
|
tweens[i].SetStartState();
|
}
|
if (!manager.TryGetOperationInfo(out var act))
|
return;
|
if (!act.TryGetRoundInfoByIndex(roundType, awardIndex, out var awardInfo, out int listIndex) || awardInfo.AwardItemList == null)
|
return;
|
int state = manager.GetAwardState(roundType, awardIndex);
|
for (int i = 0; i < tweens.Length; i++)
|
{
|
if (tweens[i].isActiveAndEnabled && state == 1)
|
{
|
tweens[i].Play();
|
}
|
}
|
}
|
|
public void Display(int index, CellView cell, List<HAA88_tagMCActLunhuidianInfo.tagMCActLunhuidianAward> taskList)
|
{
|
|
roundType = cell.info.Value.infoInt1;
|
tabType = cell.info.Value.infoInt2;
|
if (taskList.IsNullOrEmpty() || index < 0 || index >= taskList.Count)
|
return;
|
var task = taskList[index];
|
awardIndex = task.AwardIndex;
|
if (!manager.TryGetOperationInfo(out var act))
|
return;
|
if (!act.TryGetRound(roundType, out var round))
|
return;
|
if (!manager.TryGetPlayerInfo(roundType, out var playerInfo))
|
return;
|
int state = manager.GetAwardState(roundType, awardIndex);
|
maskImage.SetActive(state == 2);
|
uiEffectPlayer.SetActive(state == 1);
|
titleText.text = Language.Get($"TimeRushTaskTitle_{round.AwardType}_{round.AwardTypeValue}", task.NeedValue);
|
sliderImage.fillAmount = playerInfo.CurValue / (float)task.NeedValue;
|
sliderText.text = Language.Get("BoneField09", playerInfo.CurValue, task.NeedValue);
|
|
for (int i = 0; i < itemCells.Length; i++)
|
{
|
var itemBaisc = itemCells[i];
|
if (i < task.AwardItemList.Length)
|
{
|
var itemInfo = task.AwardItemList[i];
|
itemBaisc.SetActive(true);
|
grays[i].SetActive(state == 2);
|
ItemCellModel cellModel = new ItemCellModel((int)itemInfo.ItemID, false, itemInfo.ItemCount);
|
itemBaisc.Init(cellModel);
|
itemBaisc.button.AddListener(() =>
|
{
|
if (state == 1)
|
{
|
manager.HaveAllMissionAward(roundType);
|
}
|
else
|
{
|
ItemTipUtility.Show((int)itemInfo.ItemID);
|
}
|
});
|
}
|
else
|
{
|
itemBaisc.SetActive(false);
|
grays[i].SetActive(false);
|
}
|
}
|
|
clickButton.SetListener(() =>
|
{
|
if (state == 1)
|
{
|
manager.HaveAllMissionAward(roundType);
|
}
|
});
|
}
|
|
}
|