备份CatanBuilding瘦身独立工程
This commit is contained in:
90
Assets/Scripts/UI/Social/Chest/ChestRewardItem.cs
Normal file
90
Assets/Scripts/UI/Social/Chest/ChestRewardItem.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ChestRewardItem : PanelItemBase<ChestRewardItemData>
|
||||
{
|
||||
GameObject bar_root;
|
||||
Image bar;
|
||||
GameObject bg_normal;
|
||||
GameObject bg_gray;
|
||||
GameObject bg_next;
|
||||
RewardItemNew[] rewardItems;
|
||||
TMP_Text text_grade;
|
||||
Image icon_chest;
|
||||
TMP_Text text_point;
|
||||
private void Awake()
|
||||
{
|
||||
bar_root = transform.Find("bg_bar").gameObject;
|
||||
bar = transform.Find("bg_bar/bar").GetComponent<Image>();
|
||||
bg_normal = transform.Find("bg_normal").gameObject;
|
||||
bg_gray = transform.Find("bg_gray").gameObject;
|
||||
bg_next = transform.Find("bg_next").gameObject;
|
||||
rewardItems = transform.Find("reward").GetComponentsInChildren<RewardItemNew>();
|
||||
|
||||
icon_chest = transform.Find("icon_chest").GetComponent<Image>();
|
||||
text_grade = transform.Find("bg_grade/text_grade").GetComponent<TMP_Text>();
|
||||
text_point = transform.Find("text_point").GetComponent<TMP_Text>();
|
||||
}
|
||||
public void SetData(Account account)
|
||||
{
|
||||
text_grade.text = account.ID.ToString();
|
||||
var itemDatas = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(account.Rewards);
|
||||
int len = 0;
|
||||
if (itemDatas != null)
|
||||
{
|
||||
len = itemDatas.Count;
|
||||
for (int i = 0; i < itemDatas.Count; i++)
|
||||
{
|
||||
if (i >= rewardItems.Length)
|
||||
{
|
||||
break;
|
||||
}
|
||||
rewardItems[i].SetData(itemDatas[i]);
|
||||
}
|
||||
}
|
||||
for (int i = len; i < rewardItems.Length; i++)
|
||||
{
|
||||
rewardItems[i].gameObject.SetActive(false);
|
||||
}
|
||||
bg_next.SetActive(data.next);
|
||||
//此处 等级相关转为工会积分相关
|
||||
if (GContext.container.Resolve<PlayerData>().lv >= account.ID)
|
||||
{
|
||||
bar.fillAmount = 1;
|
||||
bg_gray.SetActive(true);
|
||||
bg_normal.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
bar.fillAmount = 0;
|
||||
bg_gray.SetActive(false);
|
||||
bg_normal.SetActive(!data.next);
|
||||
}
|
||||
for (int i = 0; i < rewardItems.Length; i++)
|
||||
{
|
||||
rewardItems[i].SetReceived(GContext.container.Resolve<PlayerData>().lv >= account.ID);
|
||||
}
|
||||
if (data.nextIndex - 1 == index)
|
||||
{
|
||||
bar.fillAmount = data.fillAmount;
|
||||
}
|
||||
bar_root.SetActive(data.bar);
|
||||
}
|
||||
|
||||
public override void OnInit()
|
||||
{
|
||||
SetData(data.account);
|
||||
}
|
||||
}
|
||||
public class ChestRewardItemData
|
||||
{
|
||||
public Account account;
|
||||
public int nextIndex;
|
||||
public float fillAmount;
|
||||
public bool next;
|
||||
public bool bar = true;
|
||||
}
|
||||
Reference in New Issue
Block a user