备份CatanBuilding瘦身独立工程
This commit is contained in:
131
Assets/Scripts/UI/Fish Rank/FishingRankPanel.cs
Normal file
131
Assets/Scripts/UI/Fish Rank/FishingRankPanel.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Fish Rank/FishingRankPanel.cs.meta
Normal file
11
Assets/Scripts/UI/Fish Rank/FishingRankPanel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81f4128d552108d40b262ccb72be27a8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user