Files
MinFt/Client/Assets/Scripts/UI/Buff/BuffInfoPopup.cs
2026-04-27 12:07:32 +08:00

122 lines
5.3 KiB
C#

using asap.core;
using cfg;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class BuffInfoPopup : MonoBehaviour
{
public TMP_Text text_title;
public TMP_Text text_time;
public Image icon;
public TMP_Text text_content;
int buffId;
private void Reset()
{
text_title = transform.Find("text_title").GetComponent<TMP_Text>();
text_time = transform.Find("bg_time/text_time").GetComponent<TMP_Text>();
icon = transform.Find("btn_buff/Ani_Container/icon").GetComponent<Image>();
text_content = transform.Find("text_content").GetComponent<TMP_Text>();
}
public void InitPanel(FishBuff buff)
{
SetBuffPanel(buff);
buffId = buff.ID;
string title = LocalizationMgr.GetText(buff.Title_l10n_key);
string desc = LocalizationMgr.GetText(buff.Desc_l10n_key);
string iconName = buff.Icon;
if (buff.BuffParam is ExtraGold)
{
ExtraGold extraGold = buff.BuffParam as ExtraGold;
desc = LocalizationMgr.GetFormatTextValue(buff.Desc_l10n_key, extraGold.Param.ToPercentageString());
}
else if (buff.BuffParam is CollectionTargetExtraPoint)
{
string str = "";
//新目标奖励活动特殊地图 Todo
str = GContext.container.Resolve<FishingEventData>().collectingTargetInit.Title_l10n_key;
str = LocalizationMgr.GetText(str);
CollectionTargetExtraPoint collectionTargetExtraPoint = buff.BuffParam as CollectionTargetExtraPoint;
desc = LocalizationMgr.GetFormatTextValue(buff.Desc_l10n_key, collectionTargetExtraPoint.Param.ToPercentageString(), str);
}
else if (buff.BuffParam is SpMapExtraPoint)
{
SpMapExtraPoint spMapExtraPoint = buff.BuffParam as SpMapExtraPoint;
desc = LocalizationMgr.GetFormatTextValue(buff.Desc_l10n_key, spMapExtraPoint.Param.ToPercentageString());
}
else if (buff.BuffParam is SuperBomb)
{
SuperBomb superBomb = buff.BuffParam as SuperBomb;
desc = LocalizationMgr.GetFormatTextValue(buff.Desc_l10n_key, superBomb.CashBonus.ToPercentageString());
}
else if (buff.BuffParam is SuperRob)
{
SuperRob superRob = buff.BuffParam as SuperRob;
desc = LocalizationMgr.GetFormatTextValue(buff.Desc_l10n_key, superRob.CashBonus.ToPercentageString());
}
else if (buff.BuffParam is SuperHunt)
{
SuperHunt superHunt = buff.BuffParam as SuperHunt;
desc = LocalizationMgr.GetFormatTextValue(buff.Desc_l10n_key, superHunt.CashBonus.ToPercentageString());
}
else if (buff.BuffParam is CollectionTargetWeight)
{
string str = "";
//新目标奖励活动 Todo
CollectionTargetWeight collectionTargetWeight = buff.BuffParam as CollectionTargetWeight;
CollectingTargetInit collectingTargetInit = GContext.container.Resolve<FishingEventData>().collectingTargetInit;
if (collectingTargetInit != null)
{
EventTargetExtraDrop eventTargetExtraDrop = collectingTargetInit.FishingExtraDrop;
if (eventTargetExtraDrop is ETKeepsake)
{
ETKeepsake eTKeepsake = eventTargetExtraDrop as ETKeepsake;
int fishItemId = eTKeepsake.FishIDList[collectionTargetWeight.TargetFishIndex - 1];
Item item = GContext.container.Resolve<Tables>().TbItem.GetOrDefault(fishItemId);
str = LocalizationMgr.GetText(item.Name_l10n_key);
iconName = collectingTargetInit.BuffIcon;
}
}
title = LocalizationMgr.GetFormatTextValue(buff.Title_l10n_key, str);
desc = LocalizationMgr.GetFormatTextValue(buff.Desc_l10n_key, str);
}
else if (buff.BuffParam is ConstructionCost)
{
ConstructionCost constructionCost = buff.BuffParam as ConstructionCost;
desc = LocalizationMgr.GetFormatTextValue(buff.Desc_l10n_key, constructionCost.Param.ToPercentageString());
}
else if (buff.BuffParam is SuperSavingPot)
{
SuperSavingPot superSavingPot = buff.BuffParam as SuperSavingPot;
desc = LocalizationMgr.GetFormatTextValue(buff.Desc_l10n_key, superSavingPot.Param.ToPercentageString());
}
else if (buff.BuffParam is Event1v1RodBuff)
{
Event1v1RodBuff event1V1RodBuff = buff.BuffParam as Event1v1RodBuff;
desc = LocalizationMgr.GetFormatTextValue(buff.Desc_l10n_key, event1V1RodBuff.Param.ToPercentageString());
}
else if (buff.BuffParam is EventSlapDamageBuff)
{
EventSlapDamageBuff eventSlapDamageBuff = buff.BuffParam as EventSlapDamageBuff;
desc = LocalizationMgr.GetFormatTextValue(buff.Desc_l10n_key, eventSlapDamageBuff.Param.ToPercentageString());
}
text_title.text = title;
text_content.text = desc;
if (!string.IsNullOrEmpty(iconName))
{
GContext.container.Resolve<IUIService>().SetImageSprite(icon, iconName);
}
}
protected virtual void SetBuffPanel(FishBuff buff)
{
}
public void SetBuffTime(string str)
{
text_time.text = str;
}
}