备份CatanBuilding瘦身独立工程
This commit is contained in:
103
Assets/Scripts/UI/Home/SupplyDropPopupPanel.cs
Normal file
103
Assets/Scripts/UI/Home/SupplyDropPopupPanel.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SupplyDropPopupPanel : MonoBehaviour
|
||||
{
|
||||
//[NonSerialized]
|
||||
public List<SupplyDropIntroItem> introItem;
|
||||
//[NonSerialized]
|
||||
public List<SupplyDropDetailsItem> detailsItems;
|
||||
|
||||
PlayerItemData playerItemData;
|
||||
Tables _tables;
|
||||
public void Init()
|
||||
{
|
||||
playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||||
Transform content = transform.Find("content");
|
||||
Transform supplyDrop = transform.Find("supplydrop");
|
||||
int count = content.childCount;
|
||||
introItem = new List<SupplyDropIntroItem>(count);
|
||||
detailsItems = new List<SupplyDropDetailsItem>(count);
|
||||
for (int i = 1; i <= count; i++)
|
||||
{
|
||||
introItem.Add(content.Find($"content{i}").GetComponent<SupplyDropIntroItem>());
|
||||
detailsItems.Add(supplyDrop.Find($"supplydrop{i}").GetComponent<SupplyDropDetailsItem>());
|
||||
}
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
var DataList = _tables.TbSupplyDrop.DataList;
|
||||
IUIService uIService = GContext.container.Resolve<IUIService>();
|
||||
SupplyDropDetailsItem detailsItem;
|
||||
for (int i = 0; i < DataList.Count; i++)
|
||||
{
|
||||
var item = DataList[i];
|
||||
introItem[i].text_num.text = $"x{item.ID}";
|
||||
introItem[i].text_title.text = LocalizationMgr.GetText(item.Name_l10n_key);
|
||||
detailsItem = detailsItems[i];
|
||||
detailsItem.text_title.text = $"x{item.ID}";
|
||||
//uIService.SetImageSprite(detailsItem[i].icon, item.Icon);
|
||||
ShowRewardItems(detailsItem, item.DropID, item.ID);
|
||||
}
|
||||
}
|
||||
|
||||
void ShowRewardItems(SupplyDropDetailsItem detailsItem, List<int> dropId, int id)
|
||||
{
|
||||
List<RewardItemNew> rewardItems = detailsItem.rewardItems;
|
||||
List<GameObject> lines = detailsItem.lines;
|
||||
|
||||
for (int j = 0; j < rewardItems.Count; j++)
|
||||
{
|
||||
var rewardItem = rewardItems[j];
|
||||
if (dropId.Count > j)
|
||||
{
|
||||
rewardItem.gameObject.SetActive(true);
|
||||
if (j == 0)
|
||||
{
|
||||
SupplyDropGameplayCash supplyDropGameplayCash = _tables.TbSupplyDropGameplayCash.DataMap[id];
|
||||
int max = playerItemData.GetExtraCoinMag(supplyDropGameplayCash.MaxRewardDisplay);
|
||||
rewardItem.text_num.text =LocalizationMgr.GetFormatTextValue("UI_SupplydropPopupPanel_3",ConvertTools.GetNumberString(max));
|
||||
}
|
||||
else if (j == 1)
|
||||
{
|
||||
SupplyDropGameplayLure supplyDropGameplayLure = _tables.TbSupplyDropGameplayLure.DataMap[id];
|
||||
int max = supplyDropGameplayLure.MaxRewardDisplay;
|
||||
rewardItem.text_num.text = LocalizationMgr.GetFormatTextValue("UI_SupplydropPopupPanel_3", ConvertTools.GetNumberString(max));
|
||||
}
|
||||
else
|
||||
{
|
||||
List<ItemData> itemData = playerItemData.GetItemDataByDropId(dropId[j]);
|
||||
rewardItem.SetData(itemData[0]);
|
||||
if (itemData.Count > 1)
|
||||
{
|
||||
float min = itemData[0].count;
|
||||
float max = itemData[^1].count;
|
||||
for (int i = 1; i < itemData.Count; i++)
|
||||
{
|
||||
if (itemData[i].count < min)
|
||||
{
|
||||
min = itemData[i].count;
|
||||
}
|
||||
max += itemData[i].count;
|
||||
}
|
||||
rewardItem.text_num.text = $"{ConvertTools.GetNumberString((int)min)}-{ConvertTools.GetNumberString((int)max)}";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rewardItem.gameObject.SetActive(false);
|
||||
lines[j - 1].SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Show(int index)
|
||||
{
|
||||
for (int i = 0; i < detailsItems.Count; i++)
|
||||
{
|
||||
detailsItems[i].gameObject.SetActive(i == index);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user