using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine;
|
|
namespace vnxbqy.UI
|
{
|
public class FairyAffinityZhanLingCell : CellView
|
{
|
[SerializeField] ImageEx imgUnlockLV;
|
[SerializeField] ImageEx imgFreeHave;
|
[SerializeField] ImageEx imgFreeGrizzly;
|
[SerializeField] TextEx txtUnlockLV;
|
[SerializeField] ItemCell freeItemCell;
|
[SerializeField] List<ItemCell> paidItemCellList = new List<ItemCell>();
|
[SerializeField] List<ImageEx> imgPaidHaveList = new List<ImageEx>();
|
[SerializeField] List<ImageEx> imgPaidLockList = new List<ImageEx>();
|
[SerializeField] List<ImageEx> imgPaidGrizzlyList = new List<ImageEx>();
|
[SerializeField] ImageEx imgBrownProgressBar;
|
[SerializeField] ImageEx imgGreenProgressBar;
|
[SerializeField] ImageEx imgBG;
|
[SerializeField] RotationTween freeItemCellTween;
|
[SerializeField] List<RotationTween> paidItemCellTweenList = new List<RotationTween>();
|
FairyAffinityZhanLingModel model { get { return ModelCenter.Instance.GetModel<FairyAffinityZhanLingModel>(); } }
|
int curValue = 0;
|
|
private void OnEnable()
|
{
|
model.PlayAnimationSync += OnPlaySyncAnimation;
|
if (curValue == 0)
|
return;
|
int freeState = model.GetGiftState(model.ZhanLingType, curValue, true);
|
int paidState = model.GetGiftState(model.ZhanLingType, curValue, false);
|
freeItemCellTween.Stop();
|
freeItemCellTween.SetStartState();
|
for (int i = 0; i < paidItemCellTweenList.Count; i++)
|
{
|
paidItemCellTweenList[i].Stop();
|
paidItemCellTweenList[i].SetStartState();
|
}
|
if (freeState == 1)
|
{
|
freeItemCellTween.Play();
|
}
|
if (paidState == 1)
|
{
|
for (int i = 0; i < paidItemCellTweenList.Count; i++)
|
{
|
paidItemCellTweenList[i].Play();
|
}
|
}
|
}
|
|
public void Display(int needValue)
|
{
|
curValue = needValue;
|
int freeState = model.GetGiftState(model.ZhanLingType, needValue, true);
|
int paidState = model.GetGiftState(model.ZhanLingType, needValue, false);
|
imgFreeHave.SetActiveIL(freeState == 2);
|
imgFreeGrizzly.SetActiveIL(freeState == 2);
|
imgGreenProgressBar.SetActiveIL(freeState != 0);
|
for (int i = 0; i < paidItemCellList.Count; i++)
|
{
|
bool isBuy = model.IsBuy();
|
imgPaidGrizzlyList[i].SetActiveIL(paidState == 2 || !isBuy);
|
imgPaidHaveList[i].SetActiveIL(paidState == 2);
|
imgPaidLockList[i].SetActiveIL(!isBuy);
|
}
|
if (model.GetNowValue() < (ulong)needValue)
|
{
|
imgUnlockLV.gray = true;
|
}
|
else
|
{
|
imgUnlockLV.gray = false;
|
}
|
txtUnlockLV.text = needValue.ToString();
|
//ÈõÚÒ»¸öcellµÄ½ø¶ÈÌõ²»Í¹³ö
|
if (ILZhanlingConfig.GetTypeToIDDict(model.ZhanLingType).Keys.ToList()[0] == needValue)
|
{
|
imgBrownProgressBar.rectTransform.sizeDelta = new Vector2(imgBG.rectTransform.sizeDelta.x, imgBrownProgressBar.rectTransform.sizeDelta.y);
|
imgGreenProgressBar.rectTransform.sizeDelta = new Vector2(imgBG.rectTransform.sizeDelta.x, imgGreenProgressBar.rectTransform.sizeDelta.y);
|
}
|
else
|
{
|
imgBrownProgressBar.rectTransform.sizeDelta = new Vector2(imgBG.rectTransform.sizeDelta.x + 10, imgBrownProgressBar.rectTransform.sizeDelta.y);
|
imgGreenProgressBar.rectTransform.sizeDelta = new Vector2(imgBG.rectTransform.sizeDelta.x + 10, imgGreenProgressBar.rectTransform.sizeDelta.y);
|
}
|
//չʾItemCell
|
var itemId = model.GetItemCellID(model.ZhanLingType, needValue, true);
|
var model1 = new ItemCellModel(itemId, false, (ulong)model.GetItemCellCount(model.ZhanLingType, needValue, true));
|
freeItemCell.Init(model1);
|
freeItemCell.button.SetListener(() =>
|
{
|
if (freeState == 1)
|
{
|
model.HaveAllZhanLingGift(model.ZhanLingType);
|
}
|
else
|
{
|
ItemTipUtility.Show(itemId);
|
}
|
});
|
|
for (int i = 0; i < paidItemCellList.Count; i++)
|
{
|
var itemId2 = model.GetItemCellID(model.ZhanLingType, needValue, false, i);
|
var model2 = new ItemCellModel(itemId2, false, (ulong)model.GetItemCellCount(model.ZhanLingType, needValue, false, i));
|
paidItemCellList[i].Init(model2);
|
paidItemCellList[i].button.SetListener(() =>
|
{
|
if (paidState == 1)
|
{
|
model.HaveAllZhanLingGift(model.ZhanLingType);
|
}
|
else
|
{
|
ItemTipUtility.Show(itemId2);
|
}
|
});
|
}
|
//²¥·ÅÐýת¶¯»
|
freeItemCellTween.Stop();
|
freeItemCellTween.SetStartState();
|
for (int i = 0; i < paidItemCellTweenList.Count; i++)
|
{
|
paidItemCellTweenList[i].Stop();
|
paidItemCellTweenList[i].SetStartState();
|
}
|
|
if (freeItemCellTween.isActiveAndEnabled && freeState == 1)
|
{
|
freeItemCellTween.Play();
|
}
|
|
for (int i = 0; i < paidItemCellTweenList.Count; i++)
|
{
|
if (paidItemCellTweenList[i].isActiveAndEnabled && paidState == 1)
|
{
|
paidItemCellTweenList[i].Play();
|
}
|
}
|
}
|
|
private void OnDisable()
|
{
|
model.PlayAnimationSync -= OnPlaySyncAnimation;
|
}
|
|
private void OnPlaySyncAnimation()
|
{
|
int freeState = model.GetGiftState(model.ZhanLingType, curValue, true);
|
int paidState = model.GetGiftState(model.ZhanLingType, curValue, false);
|
freeItemCellTween.Stop();
|
freeItemCellTween.SetStartState();
|
for (int i = 0; i < paidItemCellTweenList.Count; i++)
|
{
|
paidItemCellTweenList[i].Stop();
|
paidItemCellTweenList[i].SetStartState();
|
}
|
|
if (freeItemCellTween.isActiveAndEnabled && freeState == 1)
|
{
|
freeItemCellTween.Play();
|
}
|
|
for (int i = 0; i < paidItemCellTweenList.Count; i++)
|
{
|
if (paidItemCellTweenList[i].isActiveAndEnabled && paidState == 1)
|
{
|
paidItemCellTweenList[i].Play();
|
}
|
}
|
}
|
}
|
}
|