备份CatanBuilding瘦身独立工程
This commit is contained in:
126
Assets/Scripts/UI/Shop/GiftRodSelectionSlot.cs
Normal file
126
Assets/Scripts/UI/Shop/GiftRodSelectionSlot.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GiftRodSelectionSlot : MonoBehaviour
|
||||
{
|
||||
private Button _btnInfo, _btnSelect;
|
||||
private TMP_Text _textLvl, _textRodName, _textRodNameSelected;
|
||||
private List<GameObject> _emptyStars = new List<GameObject>();
|
||||
private List<StarItem> _solidStars = new List<StarItem>();
|
||||
private GameObject _selectedMask, _emptyMask, _stars;
|
||||
private Image _rodIcon, _rodBg;
|
||||
private int _rodID;
|
||||
private RodSelectionPackData _rspd;
|
||||
private TbItem _item;
|
||||
private PlayerFishData _pfd;
|
||||
private TbRodAscend _rodAscend;
|
||||
private Toggle _tgl;
|
||||
private Tables _tables;
|
||||
|
||||
public Toggle Toggle { get => _tgl; }
|
||||
//public Button BtnSelect { get => _btnSelect; }
|
||||
//private RodSelectionPackData _rspd = GContext.container.Resolve<RodSelectionPackData>();
|
||||
private void Awake()
|
||||
{
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
_item = GContext.container.Resolve<Tables>().TbItem;
|
||||
_pfd = GContext.container.Resolve<PlayerFishData>();
|
||||
_rodAscend = GContext.container.Resolve<Tables>().TbRodAscend;
|
||||
_btnInfo = transform.Find("btn_green/rod/btn_questionmark").GetComponent<Button>();
|
||||
//_btnSelect = transform.Find("btn_green").GetComponent<Button>();
|
||||
_textLvl = transform.Find("btn_green/rod/text_level").GetComponent<TMP_Text>();
|
||||
_textRodName = transform.Find("btn_green/bg/text_map").GetComponent<TMP_Text>();
|
||||
_textRodNameSelected = transform.Find("btn_green/selected/text_map").GetComponent<TMP_Text>();
|
||||
int i = 1;
|
||||
_stars = transform.Find("btn_green/rod/star").gameObject;
|
||||
Transform emptyStar, star;
|
||||
while (true)
|
||||
{
|
||||
emptyStar = transform.Find($"btn_green/rod/star/star_empty/star{i}");
|
||||
star = transform.Find($"btn_green/rod/star/star/star{i}");
|
||||
if (emptyStar == null || star == null)
|
||||
break;
|
||||
_emptyStars.Add(emptyStar.gameObject);
|
||||
_solidStars.Add(star.GetComponent<StarItem>());
|
||||
i++;
|
||||
}
|
||||
_selectedMask = transform.Find("btn_green/selected").gameObject;
|
||||
_emptyMask = transform.Find("btn_green/rod/mask_empty").gameObject;
|
||||
_rodIcon = transform.Find("btn_green/rod/img_map").GetComponent<Image>();
|
||||
_rodBg = transform.Find("btn_green/rod/bg").GetComponent<Image>();
|
||||
_tgl = GetComponent<Toggle>();
|
||||
_tgl.onValueChanged.AddListener((isOn) =>
|
||||
{
|
||||
_selectedMask.SetActive(isOn);
|
||||
});
|
||||
}
|
||||
public void InitializeSlot(int rodID, RodSelectionPackData rspd)
|
||||
{
|
||||
_rodID = rodID;
|
||||
_rspd = rspd;
|
||||
int rodRid = _item[_rodID].RedirectID;
|
||||
int MaxAscent = _rodAscend[rodRid].MaxAscent;
|
||||
int fragID = _rodAscend[rodRid].FragmentID;
|
||||
string rodName = LocalizationMgr.GetText(_tables.TbRodSkinData[_item[_rodID].RedirectID].Name_l10n_key);
|
||||
_textRodName.text = rodName;
|
||||
_textRodNameSelected.text = rodName;
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(_rodIcon, _item[_rodID].Icon, BasePanel.PanelName);
|
||||
GContext.container.Resolve<IUIService>().SetImageSprite(_rodBg, Define.sp_rod_card[_tables.TbRodData[rodRid].Quality - 1], BasePanel.PanelName);
|
||||
//UIManager.Instance.SetImageSprite(_rodIcon, _item[_rodID].Icon);
|
||||
if (_pfd.NotRod(rodRid))
|
||||
{
|
||||
_emptyMask.SetActive(true);
|
||||
_textLvl.gameObject.SetActive(false);
|
||||
_stars.SetActive(false);
|
||||
return;
|
||||
}
|
||||
//_btnInfo
|
||||
//_btnSelect.onClick.RemoveAllListeners();
|
||||
//_btnSelect.onClick.AddListener(OnSlotSelected);
|
||||
int star = _pfd.GetRodPiece(rodRid);
|
||||
|
||||
int ShowCount = PlayerFishData.SetRodStar(star, MaxAscent,
|
||||
_emptyStars,
|
||||
null,
|
||||
_solidStars);
|
||||
|
||||
for (int i = 0; i < ShowCount; i++)
|
||||
{
|
||||
_solidStars[i].PlayShow();
|
||||
}
|
||||
//if (star <= MaxAscent / 2)
|
||||
//{
|
||||
// for (int i = 1; i <= star; i++)
|
||||
// {
|
||||
// _solidStars[i - 1].SetStar(1);
|
||||
// _solidStars[i - 1].PlayShow();
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// for (int i = 1; i <= MaxAscent / 2; i++)
|
||||
// {
|
||||
// _solidStars[i - 1].SetStar(i <= star - MaxAscent / 2 ? 2 : 1);
|
||||
// _solidStars[i - 1].PlayShow();
|
||||
// }
|
||||
//}
|
||||
_textLvl.text = (_pfd.GetRodLevel(rodRid) + 1).ToString();
|
||||
_btnInfo.onClick.AddListener(async () => { await OpenFishingRodPanel(); });
|
||||
}
|
||||
private async System.Threading.Tasks.Task OpenFishingRodPanel()
|
||||
{
|
||||
_pfd.RodSelectedInPack = _item[_rodID].RedirectID;
|
||||
await UIManager.Instance.ShowUI(UITypes.FishingRodBagPanel);
|
||||
_pfd.RodSelectedInPack = 0;
|
||||
}
|
||||
//public void ToggleSlotSelected(bool isSelected)
|
||||
//{
|
||||
// _selectedMask.SetActive(isSelected);
|
||||
//}
|
||||
}
|
||||
Reference in New Issue
Block a user