先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
75 lines
2.5 KiB
C#
75 lines
2.5 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using game;
|
|
using GameCore;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class BenefitUpgrade : MonoBehaviour
|
|
{
|
|
public Button btnClose;
|
|
public ItemData itemData;
|
|
public Image icon;
|
|
TMP_Text text_name;
|
|
TMP_Text text_num_before;
|
|
TMP_Text text_num_after;
|
|
private void Awake()
|
|
{
|
|
text_name = transform.Find("bg_info/text_name").GetComponent<TMP_Text>();
|
|
btnClose = transform.Find("reward/btn_receive/btn_green").GetComponent<Button>();
|
|
icon = transform.Find("icon").GetComponent<Image>();
|
|
text_num_before = transform.Find("bg_info/change/text_num_before").GetComponent<TMP_Text>();
|
|
text_num_after = transform.Find("bg_info/change/text_num_after").GetComponent<TMP_Text>();
|
|
}
|
|
private void Start()
|
|
{
|
|
btnClose.onClick.AddListener(OnClickClose);
|
|
}
|
|
|
|
public void ShowPanel()
|
|
{
|
|
Item item = GContext.container.Resolve<Tables>().TbItem.GetOrDefault(itemData.id);
|
|
if (item.Type == 12)
|
|
{
|
|
int level = itemData.count;
|
|
var benefits = GContext.container.Resolve<Tables>().TbBenefits.GetOrDefault(item.SubType);
|
|
if (level >= benefits.BenefitsValue.Count)
|
|
{
|
|
level = benefits.BenefitsValue.Count - 1;
|
|
}
|
|
var curValue = benefits.BenefitsValue[level];
|
|
var preValue = benefits.BenefitsValue[level - 1];
|
|
if (item.SubType == 3 || item.SubType == 4 || item.SubType == 7)
|
|
{
|
|
text_num_before.text = preValue.ToString("F0");
|
|
text_num_after.text = curValue.ToString("F0");
|
|
}
|
|
else
|
|
{
|
|
text_num_before.text = preValue.ToPercentageString();
|
|
text_num_after.text = curValue.ToPercentageString();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
int curCount = (int)GContext.container.Resolve<PlayerItemData>().GetItemCount(itemData.id);
|
|
text_num_before.text = $"{curCount - itemData.count}%";
|
|
text_num_after.text = $"{curCount}%";
|
|
}
|
|
if (item != null)
|
|
{
|
|
text_name.text = LocalizationMgr.GetText(item.Name_l10n_key);
|
|
GContext.container.Resolve<IUIService>().SetImageSprite(icon, item.Icon, BasePanel.PanelName);
|
|
}
|
|
else
|
|
{
|
|
OnClickClose();
|
|
}
|
|
}
|
|
void OnClickClose()
|
|
{
|
|
GContext.Publish(new ShowData(RewardType.Destroy));
|
|
}
|
|
}
|