备份CatanBuilding瘦身独立工程
This commit is contained in:
122
Assets/Scripts/UI/Rod/FishingRodAscendPopupPanel.cs
Normal file
122
Assets/Scripts/UI/Rod/FishingRodAscendPopupPanel.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FishingRodAscendPopupPanel : MonoBehaviour
|
||||
{
|
||||
Tables _tables;
|
||||
Button btn_confirm;
|
||||
//星级影响最大等级
|
||||
TMP_Text text_num_before;
|
||||
TMP_Text text_num_after;
|
||||
//
|
||||
RodAttributeInfoRoot rodAttributeInfoRoot;
|
||||
|
||||
Image perk_bg;
|
||||
Image perk_icon;
|
||||
TMP_Text text_level;
|
||||
TMP_Text text_info;
|
||||
RodItem rodItem;
|
||||
RodItemData currentRodItemData;
|
||||
RodAscend curRodAscend;
|
||||
public void Awake()
|
||||
{
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
|
||||
text_num_before = transform.Find("root/content/level/num/text_num").GetComponent<TMP_Text>();
|
||||
text_num_after = transform.Find("root/content/level/num/text_after").GetComponent<TMP_Text>();
|
||||
|
||||
rodAttributeInfoRoot = transform.Find("root/content").GetComponent<RodAttributeInfoRoot>();
|
||||
|
||||
text_level = transform.Find("root/content/skill/perk/bg/text_level").GetComponent<TMP_Text>();
|
||||
perk_bg = transform.Find("root/content/skill/perk/bg").GetComponent<Image>();
|
||||
perk_icon = transform.Find("root/content/skill/perk/bg/icon").GetComponent<Image>();
|
||||
text_info = transform.Find("root/content/skill/text_info").GetComponent<TMP_Text>();
|
||||
rodItem = transform.Find("root/content/rod").GetComponent<RodItem>();
|
||||
btn_confirm = transform.Find("root/content/btn_confirm/btn_green").GetComponent<Button>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_confirm.onClick.AddListener(() => { UIManager.Instance.DestroyUI(gameObject.name); });
|
||||
}
|
||||
|
||||
public void SetCurData(RodItemData currentRodItemData, Sprite sprite)
|
||||
{
|
||||
this.currentRodItemData = currentRodItemData;
|
||||
rodItem.Init(currentRodItemData);
|
||||
perk_bg.sprite = sprite;
|
||||
Init();
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
IUIService uiService = GContext.container.Resolve<IUIService>();
|
||||
RodData rodData = currentRodItemData.config;
|
||||
curRodAscend = _tables.TbRodAscend.GetOrDefault(rodData.AscendID);
|
||||
var dataMap = _tables.TbRodBasicStats.DataMap;
|
||||
RodBasicStats rodBasicStats;
|
||||
PlayerFishData playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||||
int star = playerFishData.GetRodPiece(rodData.ID);
|
||||
RodLevelup rodLevelup = _tables.TbRodLevelup.GetOrDefault(rodData.LevelupID);
|
||||
List<int> Millestones = rodLevelup.Millestones;
|
||||
int perkIDListCount = curRodAscend.PerkIDList.Count;
|
||||
int[] lv = playerFishData.GetPerkLevel(perkIDListCount, star, curRodAscend.DefaultPerk, curRodAscend.PerkUnlockOrder);
|
||||
|
||||
int index = curRodAscend.PerkUnlockOrder[star - 1] - 1;
|
||||
int perkID = curRodAscend.PerkIDList[index];
|
||||
var rodEngancePerk = _tables.TbRodAscendPerk.GetOrDefault(perkID);
|
||||
int level = lv[index];
|
||||
text_level.text = LocalizationMgr.GetFormatTextValue("UI_PlayerGradePopupPanel_1", level);
|
||||
|
||||
List<string> PerkDataList = curRodAscend.PerkDataList[index];
|
||||
if (level > PerkDataList.Count)
|
||||
{
|
||||
Debug.LogError($"钓竿ID:{rodData.ID}的{perkID}第{level}阶提升属性不存在");
|
||||
return;
|
||||
}
|
||||
string perkValue = PerkDataList[level - 1];
|
||||
|
||||
text_info.text = PlayerFishData.GetPerkDesc(rodEngancePerk.PerkType, rodEngancePerk.Desc_l10n_key, perkValue);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(perk_icon, rodEngancePerk.Icon, BasePanel.PanelName);
|
||||
|
||||
text_num_after.gameObject.SetActive(true);
|
||||
if (star == Millestones.Count)
|
||||
{
|
||||
text_num_before.text = Millestones[star - 1].ToString();
|
||||
text_num_after.text = rodLevelup.MaxLevel.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
text_num_before.text = Millestones[star - 1].ToString();
|
||||
text_num_after.text = Millestones[star].ToString();
|
||||
}
|
||||
|
||||
var values = playerFishData.GetRodAttribute(rodData.ID, starAdd: -1);
|
||||
var values2 = playerFishData.GetRodAttribute(rodData.ID);
|
||||
|
||||
for (int i = 0; i < values.Count; i++)
|
||||
{
|
||||
rodBasicStats = dataMap[i + 1];
|
||||
rodAttributeInfoRoot.rodAttributes[i].gameObject.SetActive(true);
|
||||
rodAttributeInfoRoot.rodAttributes[i].icon.sprite = uiService.GetSprite(rodBasicStats.Icon);
|
||||
rodAttributeInfoRoot.rodAttributes[i].text_name.text = LocalizationMgr.GetText(rodBasicStats.Title_l10n_key);
|
||||
|
||||
var curValue = values[i];
|
||||
var nextValue = values2[i];
|
||||
if (curValue != nextValue)
|
||||
{
|
||||
rodAttributeInfoRoot.rodAttributes[i].gameObject.SetActive(true);
|
||||
rodAttributeInfoRoot.rodAttributes[i].text_num.text = curValue.ToString();
|
||||
rodAttributeInfoRoot.rodAttributes[i].text_after.text = nextValue.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
rodAttributeInfoRoot.rodAttributes[i].gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user