Files
MinFt/Client/Assets/Scripts/UI/Fish Rank/FishingRankPanel.cs
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

132 lines
4.0 KiB
C#

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using GameCore;
using cfg;
using asap.core;
public class FishingRankPanel : MonoBehaviour
{
private Button btn_close;
private Button btn_left;
private Button btn_right;
public GameObject btn_left_icon;
public GameObject btn_left_icon_gray;
public GameObject btn_right_icon;
public GameObject btn_right_icon_gray;
public TMP_Text fishName;
private int index;
private Image fishIcon;
public List<FishItemData> fishItemData = new List<FishItemData>();
public GameObject item;
public PanelScroll scrollRect;
float itemHigh;
private void Awake()
{
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
btn_left = transform.Find("root/btn_close/btn_arrow_left").GetComponent<Button>();
btn_right = transform.Find("root/btn_close/btn_arrow_right").GetComponent<Button>();
btn_left_icon = transform.Find("root/btn_close/btn_arrow_left/icon").gameObject;
btn_left_icon_gray = transform.Find("root/btn_close/btn_arrow_left/icon_gray").gameObject;
btn_right_icon = transform.Find("root/btn_close/btn_arrow_right/icon").gameObject;
btn_right_icon_gray = transform.Find("root/btn_close/btn_arrow_right/icon_gray").gameObject;
//banner
fishName = transform.Find("root/banner/text_name").GetComponent<TMP_Text>();
fishIcon = transform.Find("root/banner/icon_fish").GetComponent<Image>();
//scrollview
scrollRect = transform.Find("root/leadboard/rank/ScrollView").GetComponent<PanelScroll>();
item = transform.Find("root/leadboard/rank/ScrollView/Viewport/Content/Item").gameObject;
itemHigh = item.GetComponent<RectTransform>().sizeDelta.y;
}
void Start()
{
btn_left.onClick.AddListener(OnLeftClick);
btn_right.onClick.AddListener(OnRightClick);
btn_close.onClick.AddListener(() =>
{
UIManager.Instance.DestroyUI(UITypes.FishingRankPanel);
FishCardReviewPopupPanel.Instance.SetFish(index);
});
Init();
}
public void SetFish(int _index, List<FishData> _fishDatas)
{
index = _index;
fishItemData.Clear();
for (int i = 0; i < _fishDatas.Count; i++)
{
fishItemData.Add(new FishItemData(_fishDatas[i]));
}
}
public void Init()
{
index = -1;
LoadBanner();
loadScrollView();
}
void LoadBanner()
{
if (index == -1)
{
index = FishCardReviewPopupPanel.Instance.panelScroll.currentIndex;
}
//Debug.Log("index:" + index);
//FishCardItemData fishCardItemData = FishCardReviewPopupPanel.Instance.fishCardItemData[index];
fishName.text = LocalizationMgr.GetText(fishItemData[index].fishData.Name_l10n_key);
GContext.container.Resolve<IUIService>().SetImageSprite(fishIcon, fishItemData[index].fishData.Portrait, BasePanel.PanelName);
OnLeftOrRight();
}
void OnLeftClick()
{
if (index > 0)
{
//btn_left.interactable = false;
index--;
LoadBanner();
loadScrollView();
}
}
void OnRightClick()
{
if (index < FishCardReviewPopupPanel.Instance.fishCardItemData.Count - 1)
{
//btn_right.interactable = false;
index++;
LoadBanner();
loadScrollView();
}
}
void OnLeftOrRight()
{
btn_left_icon.SetActive(index > 0);
btn_left_icon_gray.SetActive(index <= 0);
btn_right_icon.SetActive(index < fishItemData.Count - 1);
btn_right_icon_gray.SetActive(index >= fishItemData.Count - 1);
}
void loadScrollView()
{
}
public class FishItemData
{
public FishData fishData;
public FishItemData(FishData fishData)
{
this.fishData = fishData;
}
}
}