using vnxbqy.UI;
|
using System;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
class TreasurePavilionCell : ILBehaviour
|
{
|
ButtonEx gubaoBtn;
|
ImageEx gubaoImg;
|
ImageEx gubaoGrayImg;
|
List<Transform> starObjs = new List<Transform>();
|
ImageEx labImg;
|
Text name;
|
RedpointBehaviour redpoint;
|
IntensifySmoothSlider slider;
|
Text process;
|
UIEffect uieffect;
|
|
PackModel packModel { get { return ModelCenter.Instance.GetModelEx<PackModel>(); } }
|
|
protected override void Awake()
|
{
|
gubaoBtn = proxy.GetWidgtEx<ButtonEx>("gubaoBtn");
|
//特效层级和mask的遮挡问题未解决,目前用两张图片灰色正常遮挡
|
gubaoImg = proxy.GetWidgtEx<ImageEx>("gubaoIcon");
|
gubaoGrayImg = proxy.GetWidgtEx<ImageEx>("gubaoIconGray");
|
var canvas = gubaoImg.AddMissingComponent<Canvas>();
|
canvas.sortingLayerName = "UI"; //使图片在特效上层
|
|
for (int i = 0; i < 10; i++)
|
{
|
starObjs.Add(proxy.GetWidgtEx<Transform>("starBG" + i));
|
}
|
labImg = proxy.GetWidgtEx<ImageEx>("lab");
|
name = proxy.GetWidgtEx<Text>("name");
|
redpoint = proxy.GetWidgtEx<RedpointBehaviour>("RedPoint");
|
slider = proxy.GetWidgtEx<IntensifySmoothSlider>("ExpSlider");
|
process = proxy.GetWidgtEx<Text>("ExpNum");
|
uieffect = proxy.GetWidgtEx<UIEffect>("uieffect");
|
}
|
|
|
|
public void Display(int gubaoID, float scale = 1)
|
{
|
uieffect.StopImediatly();
|
var gubaoInfo = TreasurePavilionModel.Instance.TryGetGubaoInfo(gubaoID);
|
var config = ILGubaoConfig.Get(gubaoID);
|
var cnt = TreasurePavilionModel.Instance.GetGubaoItemCount(gubaoID); //packModel.GetItemCountByID(PackType.Item, config.UnlockItemID);
|
|
gubaoImg.SetSprite(config.Icon);
|
gubaoGrayImg.SetSprite(config.Icon);
|
if (gubaoInfo.Count == 0 && cnt < config.UnlockItemCnt)
|
{
|
gubaoGrayImg.SetActiveIL(true);
|
gubaoImg.SetActiveIL(false);
|
}
|
else
|
{
|
gubaoGrayImg.SetActiveIL(false);
|
gubaoImg.SetActiveIL(true);
|
}
|
gubaoBtn.SetListener(()=> {
|
OpenGubaoTip(gubaoID);
|
});
|
var maxStar = ILGubaoStarConfig.GetMaxStar(gubaoID);
|
for (int i = 0; i < starObjs.Count; i++)
|
{
|
if (i < maxStar)
|
{
|
starObjs[i].SetActiveIL(true);
|
if (gubaoInfo.Count > 0 && gubaoInfo[0] > i)
|
{
|
Image star = starObjs[i].Find("star").GetComponent<Image>();
|
star.SetActiveIL(true);
|
// 根据星级设置不同颜色的星星
|
if (gubaoInfo[0] <= 10)
|
{
|
star.SetSprite("TreasureStar1"); // 黄色星星
|
}
|
else if (gubaoInfo[0] <= 20)
|
{
|
int blueStars = gubaoInfo[0] - 10;
|
if (i < blueStars)
|
{
|
star.SetSprite("TreasureStar2"); // 蓝色星星
|
}
|
else
|
{
|
star.SetSprite("TreasureStar1"); // 黄色星星
|
}
|
}
|
else
|
{
|
int purpleStars = gubaoInfo[0] - 20;
|
if (i < purpleStars)
|
{
|
star.SetSprite("TreasureStar3"); // 紫色星星
|
}
|
else
|
{
|
star.SetSprite("TreasureStar2"); // 蓝色星星
|
}
|
}
|
}
|
else
|
{
|
starObjs[i].Find("star").GetComponent<Image>().SetActiveIL(false);
|
}
|
}
|
else
|
{
|
starObjs[i].SetActiveIL(false);
|
}
|
}
|
|
labImg.SetSprite(TreasurePavilionModel.Instance.gubaoDiIconDict[config.GubaoQuality]);
|
|
if (gubaoInfo.Count > 0 && gubaoInfo[1] > 0)
|
{
|
name.text = config.Name + UIHelper.AppendColor(TextColType.Green, "+" + gubaoInfo[1]);
|
}
|
else
|
{
|
name.text = config.Name;
|
}
|
redpoint.redpointId = MainRedPoint.cbgRedpoint * 10000 + config.GubaoID;
|
if (gubaoInfo.Count == 0)
|
{
|
slider.SetActiveIL(true);
|
|
slider.value = Math.Min(1, (float)cnt / config.UnlockItemCnt);
|
process.text = cnt + "/" + config.UnlockItemCnt;
|
uieffect.effect = TreasurePavilionModel.Instance.gubaoEffectDict[config.GubaoQuality];
|
uieffect.effectScl = Vector3.one * scale;
|
if (cnt >= config.UnlockItemCnt)
|
{
|
uieffect.Play();
|
}
|
else
|
{
|
uieffect.StopImediatly();
|
}
|
}
|
else
|
{
|
|
slider.SetActiveIL(false);
|
uieffect.effect = TreasurePavilionModel.Instance.gubaoEffectDict[config.GubaoQuality];
|
uieffect.effectScl = Vector3.one * scale;
|
uieffect.Play();
|
}
|
}
|
|
void OpenGubaoTip(int gubaoID)
|
{
|
TreasurePavilionModel.Instance.selectGubao = gubaoID;
|
WindowCenter.Instance.OpenIL<TreasurePavilionTipWin>();
|
if (TreasurePavilionModel.Instance.selectTagIndex == 1)
|
{
|
TreasurePavilionModel.Instance.selectResonanceID = GubaoResonanceConfig.GetGubaoIDToResonanceIDDict()[gubaoID];
|
}
|
}
|
}
|