备份CatanBuilding瘦身独立工程
This commit is contained in:
147
Assets/Scripts/UI/Rod/ReviewNewRod.cs
Normal file
147
Assets/Scripts/UI/Rod/ReviewNewRod.cs
Normal file
@@ -0,0 +1,147 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ReviewNewRod : MonoBehaviour
|
||||
{
|
||||
Tables _tables;
|
||||
IUIService uIService;
|
||||
//PlayerFishData playerFishData;
|
||||
RodAscend curRodAscend;
|
||||
RodData config;
|
||||
Image icon_tag;
|
||||
Image title_image;
|
||||
TMP_Text text_name;
|
||||
|
||||
string[] sp_rod_title = { "sp_rod_title_blue", "sp_rod_title_blue", "sp_rod_title_purple", "sp_rod_title_yellow" };
|
||||
|
||||
Button nextButton;
|
||||
Button btn_equip;
|
||||
List<Button> peark_btns = new List<Button>();
|
||||
private readonly List<Perk> _perkList = new List<Perk>();
|
||||
Action NextNewRod;
|
||||
private void Awake()
|
||||
{
|
||||
uIService = GContext.container.Resolve<IUIService>();
|
||||
_tables = GContext.container.Resolve<Tables>();
|
||||
nextButton = transform.Find("nextButton").GetComponent<Button>();
|
||||
btn_equip = transform.Find("btn_equip/btn_green").GetComponent<Button>();
|
||||
//playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||||
title_image = transform.Find("bg_name").GetComponent<Image>();
|
||||
icon_tag = transform.Find("text_name/icon_tag").GetComponent<Image>();
|
||||
text_name = transform.Find("text_name").GetComponent<TMP_Text>();
|
||||
Transform perks = transform.Find("pearks");
|
||||
int count = perks.childCount;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_perkList.Add(perks.GetChild(i).GetComponent<Perk>());
|
||||
peark_btns.Add(perks.GetChild(i).Find("bg").GetComponent<Button>());
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
for (int i = 0; i < peark_btns.Count; i++)
|
||||
{
|
||||
int index = i;
|
||||
peark_btns[i].onClick.AddListener(() =>
|
||||
{
|
||||
ShowPeark(index);
|
||||
});
|
||||
}
|
||||
nextButton.onClick.AddListener(ClickNextNewRod);
|
||||
btn_equip.onClick.AddListener(OnClickEquip);
|
||||
}
|
||||
void ClickNextNewRod()
|
||||
{
|
||||
if (NextNewRod != null)
|
||||
{
|
||||
NextNewRod?.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.Instance.DestroyUI(UITypes.FishingAppearancePanel);
|
||||
}
|
||||
}
|
||||
|
||||
async void ShowPeark(int index)
|
||||
{
|
||||
item_tips _item_tips = await item_tips.Show();
|
||||
if (_item_tips == null /*|| trans.gameObject.GetInstanceID() == _item_tips.clickInstanceID*/)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_item_tips.ShowPerk(config.ID, index, peark_btns[index].transform.position);
|
||||
}
|
||||
|
||||
public void SetCurData(RodData config, Action nextNewRod)
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
NextNewRod = nextNewRod;
|
||||
SetCurData(config);
|
||||
}
|
||||
|
||||
|
||||
public void SetCurData(RodData config)
|
||||
{
|
||||
StartCoroutine(ShowNextButton());
|
||||
this.config = config;
|
||||
curRodAscend = _tables.TbRodAscend.GetOrDefault(config.AscendID);
|
||||
|
||||
//int skindID = playerFishData.GetRodSkin(config.ID);
|
||||
RodSkinData fishRodSkinData = _tables.TbRodSkinData.GetOrDefault(config.ID);
|
||||
if (fishRodSkinData != null)
|
||||
{
|
||||
text_name.text = LocalizationMgr.GetText(fishRodSkinData.Name_l10n_key);
|
||||
}
|
||||
uIService.SetImageSprite(title_image, sp_rod_title[config.Quality - 1], BasePanel.PanelName);
|
||||
|
||||
uIService.SetImageSprite(icon_tag, $"icon_rod_tag_{config.Quality - 1}", BasePanel.PanelName);
|
||||
InitPearksData();
|
||||
}
|
||||
|
||||
IEnumerator ShowNextButton()
|
||||
{
|
||||
nextButton.gameObject.SetActive(false);
|
||||
yield return new WaitForSeconds(1);
|
||||
nextButton.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
void InitPearksData()
|
||||
{
|
||||
PlayerFishData playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||||
int perkIDListCount = curRodAscend.PerkIDList.Count;
|
||||
int star = playerFishData.GetRodPiece(config.ID);
|
||||
var perkUnlockOrder = curRodAscend.PerkUnlockOrder;
|
||||
int[] lv = playerFishData.GetPerkLevel(perkIDListCount, star, curRodAscend.DefaultPerk, perkUnlockOrder);
|
||||
|
||||
for (int i = 0; i < _perkList.Count; i++)
|
||||
{
|
||||
if (i < perkIDListCount)
|
||||
{
|
||||
_perkList[i].gameObject.SetActive(true);
|
||||
_perkList[i].SetData(curRodAscend.PerkIDList[i], lv[i], config.Quality);
|
||||
}
|
||||
else
|
||||
{
|
||||
_perkList[i].gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async void OnClickEquip()
|
||||
{
|
||||
GContext.container.Resolve<PlayerFishData>().RodSelectedInPack = config.ID;
|
||||
await UIManager.Instance.ShowUI(UITypes.FishingRodBagPanel);
|
||||
GContext.Publish(new ShowData(RewardType.Destroy));
|
||||
UIManager.Instance.DestroyUI(UITypes.FishingAppearancePanel);
|
||||
GContext.container.Resolve<PlayerFishData>().RodSelectedInPack = 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user