备份CatanBuilding瘦身独立工程
This commit is contained in:
274
Assets/Scripts/UI/Rod/FishingRodHonorlevelPanel.cs
Normal file
274
Assets/Scripts/UI/Rod/FishingRodHonorlevelPanel.cs
Normal file
@@ -0,0 +1,274 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
/*
|
||||
UI_FishingRodHonorlevelPanel_1 精英荣耀等级 Elite Honor Level
|
||||
UI_FishingRodHonorlevelPanel_2 专家荣耀等级 Expert Honor Level
|
||||
UI_FishingRodHonorlevelPanel_3 大师荣耀等级 Master Honor Level
|
||||
UI_FishingRodHonorlevelPanel_4 精英荣耀属性 Elite Honor Attributes
|
||||
UI_FishingRodHonorlevelPanel_5 专家荣耀属性 Expert Honor Attributes
|
||||
UI_FishingRodHonorlevelPanel_6 大师荣耀属性 Master Honor Attributes
|
||||
UI_FishingRodHonorlevelPanel_7 对所有精英鱼竿生效 Applies to all Elite Rods
|
||||
UI_FishingRodHonorlevelPanel_8 对所有专家鱼竿生效 Applies to all Expert Rods
|
||||
UI_FishingRodHonorlevelPanel_9 对所有大师鱼竿生效 Applies to all Master Rods
|
||||
*/
|
||||
public class FishingRodHonorlevelPanel : MonoBehaviour
|
||||
{
|
||||
RodItem rod;
|
||||
TMP_Text text_level;
|
||||
Image honor;
|
||||
RodAttributeInfo rodAttribute;
|
||||
Button btn_levelup;
|
||||
Button btn_levelup_gray;
|
||||
Button btn_questionmark;
|
||||
GameObject icon_cost_2;
|
||||
TMP_Text icon_cost_1_num;
|
||||
TMP_Text icon_cost_2_num;
|
||||
TMP_Text icon_cost_3_num;
|
||||
Image icon_ticket_2;
|
||||
Image icon_ticket_3;
|
||||
|
||||
TMP_Text text_title;
|
||||
TMP_Text text_info_title;
|
||||
TMP_Text text_info;
|
||||
|
||||
GameObject tips_honorrod;
|
||||
GameObject item_rod;
|
||||
Button btn_close;
|
||||
FishingRodUpSystem upSystem;
|
||||
PlayerFishData playerFishData;
|
||||
Tables _tables;
|
||||
RodItemData data;
|
||||
RodAscend curRodAscend;
|
||||
RodRodLevelPeak rodLevelPeak;
|
||||
GameObject fx_rodpanel_honorlevel_upgrade;
|
||||
RawImage rawImageRod;
|
||||
IUIService uIService;
|
||||
string toastKey = "UI_ToastPanel_66";
|
||||
private void Awake()
|
||||
{
|
||||
uIService = GContext.container.Resolve<IUIService>();
|
||||
rawImageRod = transform.Find("root/RawImageRod").GetComponent<RawImage>();
|
||||
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||||
upSystem = GContext.container.Resolve<FishingRodUpSystem>();
|
||||
text_level = transform.Find("root/honor/text_level").GetComponent<TMP_Text>();
|
||||
honor = transform.Find("root/honor").GetComponent<Image>();
|
||||
rodAttribute = transform.Find("root/info/attribute1").GetComponent<RodAttributeInfo>();
|
||||
btn_levelup = transform.Find("root/btn_levelup/btn_green").GetComponent<Button>();
|
||||
btn_levelup_gray = transform.Find("root/btn_levelup_gray/btn_green").GetComponent<Button>();
|
||||
btn_questionmark = transform.Find("root/info/text_info/btn_questionmark").GetComponent<Button>();
|
||||
rod = transform.Find("root/rod").GetComponent<RodItem>();
|
||||
icon_cost_1_num = transform.Find("root/cost/icon_cost_1/text_num").GetComponent<TMP_Text>();
|
||||
icon_cost_2_num = transform.Find("root/cost/icon_cost_2/text_num").GetComponent<TMP_Text>();
|
||||
icon_cost_2 = transform.Find("root/cost/icon_cost_2").gameObject;
|
||||
icon_ticket_2 = transform.Find("root/cost/icon_cost_2/icon_ticket").GetComponent<Image>();
|
||||
icon_cost_3_num = transform.Find("root/cost/icon_cost_3/text_num").GetComponent<TMP_Text>();
|
||||
icon_ticket_3 = transform.Find("root/cost/icon_cost_3/icon_ticket").GetComponent<Image>();
|
||||
tips_honorrod = transform.Find("root/tips_honorrod").gameObject;
|
||||
item_rod = transform.Find("root/tips_honorrod/item_rod").gameObject;
|
||||
btn_close = transform.Find("bottom/btn_close").GetComponent<Button>();
|
||||
item_rod.SetActive(false);
|
||||
fx_rodpanel_honorlevel_upgrade = transform.Find("root/honor/fx_rodpanel_honorlevel_upgrade").gameObject;
|
||||
text_title = transform.Find("top/title/text_title").GetComponent<TMP_Text>();
|
||||
text_info_title = transform.Find("root/info/text_title").GetComponent<TMP_Text>();
|
||||
text_info = transform.Find("root/info/text_info").GetComponent<TMP_Text>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
btn_close.onClick.AddListener(OnClose);
|
||||
btn_levelup.onClick.AddListener(OnClickUp);
|
||||
btn_levelup_gray.onClick.AddListener(OnClickUpGray);
|
||||
btn_questionmark.onClick.AddListener(ShowHonorRod);
|
||||
data = upSystem.GetCurrentRodItemData();
|
||||
rod.Init(data);
|
||||
rawImageRod.gameObject.SetActive(true);
|
||||
rawImageRod.texture = upSystem.bagPanel.rt;
|
||||
RodData rodData = data.config;
|
||||
rodLevelPeak = _tables.TbRodRodLevelPeak.GetOrDefault(rodData.Quality);
|
||||
var dataMap = _tables.TbRodBasicStats.DataMap;
|
||||
|
||||
curRodAscend = _tables.TbRodAscend.GetOrDefault(rodData.AscendID);
|
||||
SetEnhance();
|
||||
|
||||
Item item = _tables.TbItem.GetOrDefault(curRodAscend.FragmentID);
|
||||
icon_ticket_3.sprite = uIService.GetSprite(item.Icon);
|
||||
RodFragmentExchange rodFragmentExchange = _tables.TbRodFragmentExchange.GetOrDefault(data.config.Quality);
|
||||
if (rodFragmentExchange != null)
|
||||
{
|
||||
item = _tables.TbItem.GetOrDefault(rodFragmentExchange.GeneralFragmentID);
|
||||
icon_ticket_2.sprite = uIService.GetSprite(item.Icon);
|
||||
}
|
||||
text_title.text = LocalizationMgr.GetText($"UI_FishingRodHonorlevelPanel_{rodData.Quality - 1}");
|
||||
text_info_title.text = LocalizationMgr.GetText($"UI_FishingRodHonorlevelPanel_{rodData.Quality + 2}");
|
||||
text_info.text = LocalizationMgr.GetText($"UI_FishingRodHonorlevelPanel_{rodData.Quality + 5}");
|
||||
honor.sprite = uIService.GetSprite(rodLevelPeak.Icon);
|
||||
InitHonorRod();
|
||||
}
|
||||
void InitHonorRod()
|
||||
{
|
||||
var idList = upSystem.HasRodID(data.config.Quality);
|
||||
var rodItemDatas = new List<RodItemData>();
|
||||
RodData _rodData;
|
||||
RodAscend _rodAscend;
|
||||
for (int i = 0; i < idList.Count; i++)
|
||||
{
|
||||
_rodData = _tables.TbRodData.DataMap[idList[i]];
|
||||
bool isLock = playerFishData.NotRod(_rodData.ID);
|
||||
_rodAscend = _tables.TbRodAscend.GetOrDefault(_rodData.AscendID);
|
||||
|
||||
int level = playerFishData.GetRodLevel(_rodData.ID);
|
||||
int star = playerFishData.GetRodPiece(_rodData.ID);
|
||||
bool isMax = star >= _rodAscend.MaxAscent;
|
||||
RodItemData rodItemData = new RodItemData()
|
||||
{
|
||||
config = _rodData,
|
||||
isLock = isLock,
|
||||
level = level + 1,
|
||||
star = star,
|
||||
isMax = isMax,
|
||||
};
|
||||
int skindID = playerFishData.GetRodSkin(_rodData.ID);
|
||||
rodItemData.skin = _tables.TbRodSkinData.GetOrDefault(skindID);
|
||||
rodItemData.SetRodPower();
|
||||
rodItemDatas.Add(rodItemData);
|
||||
}
|
||||
rodItemDatas.Sort(RodItemData.Sort);
|
||||
//弹出界面
|
||||
for (int i = 0; i < rodItemDatas.Count; i++)
|
||||
{
|
||||
GameObject go = Instantiate(item_rod, tips_honorrod.transform);
|
||||
go.SetActive(true);
|
||||
go.GetComponent<RodItem>().Init(rodItemDatas[i]);
|
||||
}
|
||||
}
|
||||
void ShowHonorRod()
|
||||
{
|
||||
tips_honorrod.SetActive(!tips_honorrod.activeSelf);
|
||||
}
|
||||
void OnClickUpGray()
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText(toastKey));
|
||||
}
|
||||
void OnClickUp()
|
||||
{
|
||||
///判断 材料是否足够
|
||||
playerFishData.HonorLevelUp(data.config);
|
||||
SetEnhance();
|
||||
fx_rodpanel_honorlevel_upgrade.SetActive(false);
|
||||
fx_rodpanel_honorlevel_upgrade.SetActive(true);
|
||||
}
|
||||
void ShowCost()
|
||||
{
|
||||
RodData rodData = data.config;
|
||||
if (rodLevelPeak == null)
|
||||
{
|
||||
Debug.LogError($"[FishingRodHonorlevelPanel]OnClickUpGray: No RodRodLevelPeak data found for Quality {data.config.Quality}");
|
||||
return;
|
||||
}
|
||||
int currentHonorLevel = playerFishData.GetHonorLevel(rodData.Quality);
|
||||
if (currentHonorLevel >= rodLevelPeak.ItemConsume.Count)
|
||||
{
|
||||
currentHonorLevel = rodLevelPeak.ItemConsume.Count - 1;
|
||||
}
|
||||
int requiredItems = rodLevelPeak.ItemConsume[currentHonorLevel];
|
||||
int fragmentItems = rodLevelPeak.FragmentConsume[currentHonorLevel];
|
||||
bool isUp = false;
|
||||
double consumeCount = GContext.container.Resolve<PlayerData>().pearl;
|
||||
if (consumeCount < requiredItems)
|
||||
{
|
||||
toastKey = "UI_ToastPanel_12";
|
||||
icon_cost_1_num.text = $"<color=red>{consumeCount}</color>/{requiredItems}";
|
||||
}
|
||||
else
|
||||
{
|
||||
toastKey = "UI_ToastPanel_66";
|
||||
isUp = true;
|
||||
icon_cost_1_num.text = $"<color=green>{consumeCount}</color>/{requiredItems}";
|
||||
}
|
||||
|
||||
|
||||
int fragment = GContext.container.Resolve<PlayerFishData>().GetRodPiece(curRodAscend.FragmentID);
|
||||
bool fraUp = false;
|
||||
|
||||
if (fragment < fragmentItems)
|
||||
{
|
||||
icon_cost_2.SetActive(true);
|
||||
fragmentItems -= fragment;
|
||||
fragmentItems = ShowCost(fragmentItems);
|
||||
if (fragmentItems <= 0)
|
||||
{
|
||||
fraUp = true;
|
||||
icon_cost_3_num.text = $"<color=green>{fragment}</color>/{fragment}";
|
||||
}
|
||||
else
|
||||
{
|
||||
icon_cost_3_num.text = $"<color=red>{fragment}</color>/{fragment + fragmentItems}";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
icon_cost_2.SetActive(false);
|
||||
icon_cost_3_num.text = $"<color=green>{fragment}</color>/{fragmentItems}";
|
||||
fraUp = true;
|
||||
}
|
||||
|
||||
isUp &= fraUp;
|
||||
btn_levelup.gameObject.SetActive(isUp);
|
||||
btn_levelup_gray.gameObject.SetActive(!isUp);
|
||||
}
|
||||
int ShowCost(int rquiredFragments)
|
||||
{
|
||||
RodFragmentExchange rodFragmentExchange = _tables.TbRodFragmentExchange.GetOrDefault(data.config.Quality);
|
||||
int fragment = GContext.container.Resolve<PlayerFishData>().GetRodPiece(rodFragmentExchange.GeneralFragmentID) / rodFragmentExchange.ExchangeRate;
|
||||
if (fragment == 0)
|
||||
{
|
||||
icon_cost_2.SetActive(false);
|
||||
return rquiredFragments;
|
||||
}
|
||||
int count;
|
||||
if (fragment >= rquiredFragments)
|
||||
{
|
||||
count = rquiredFragments * rodFragmentExchange.ExchangeRate;
|
||||
}
|
||||
else
|
||||
{
|
||||
count = fragment * rodFragmentExchange.ExchangeRate;
|
||||
}
|
||||
icon_cost_2_num.text = $"<color=green>{count}</color>/{count}";
|
||||
return rquiredFragments - fragment;
|
||||
}
|
||||
void SetEnhance()
|
||||
{
|
||||
ShowCost();
|
||||
RodData rodData = data.config;
|
||||
text_level.text = LocalizationMgr.GetFormatTextValue("UI_PlayerGradePopupPanel_1", playerFishData.GetHonorLevel(rodData.Quality));
|
||||
var values = playerFishData.GetHonorLevelAttribute(rodData.Quality);
|
||||
var values2 = playerFishData.GetHonorLevelAttribute(rodData.Quality, starAdd: 1);
|
||||
|
||||
var curValue = values;
|
||||
rodAttribute.text_num.text = curValue.ToString();
|
||||
var nextValue = values2;
|
||||
if (curValue != nextValue)
|
||||
{
|
||||
rodAttribute.text_after.text = nextValue.ToString();
|
||||
rodAttribute.text_after.gameObject.SetActive(true);
|
||||
rodAttribute.arrow.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
rodAttribute.text_after.gameObject.SetActive(false);
|
||||
rodAttribute.arrow.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
private async void OnClose()
|
||||
{
|
||||
await UIManager.Instance.ShowUI(UITypes.FishingRodPanel);
|
||||
UIManager.Instance.DestroyUI(gameObject.name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user