备份CatanBuilding瘦身独立工程
This commit is contained in:
171
Assets/Scripts/Duel/UI/event_fishingduel_rod_change.cs
Normal file
171
Assets/Scripts/Duel/UI/event_fishingduel_rod_change.cs
Normal file
@@ -0,0 +1,171 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class event_fishingduel_rod_change : MonoBehaviour
|
||||
{
|
||||
public Image[] traits;
|
||||
FishingDuelManager FDM;
|
||||
public Button btn_confrim;
|
||||
public Button btn_questionmark;
|
||||
public GameObject item;
|
||||
public Transform Content;
|
||||
public TMP_Text p_text;
|
||||
public TMP_Text text_title;
|
||||
public duel_rod_trait_tips trait_tips;
|
||||
List<RodItemData> rodItemDatas = new List<RodItemData>();
|
||||
List<DuelRodItem> rodItems = new List<DuelRodItem>();
|
||||
private DuelRodItem currentRodItem;
|
||||
Tables tables;
|
||||
public int allTime;
|
||||
private void Awake()
|
||||
{
|
||||
tables = GContext.container.Resolve<Tables>();
|
||||
FDM = GContext.container.Resolve<FishingDuelManager>();
|
||||
item.SetActive(false);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
IUIService uiService = GContext.container.Resolve<IUIService>();
|
||||
List<int> traitID = FDM.TraitID;
|
||||
for (int i = 0; i < traits.Length; i++)
|
||||
{
|
||||
if (i < traitID.Count)
|
||||
{
|
||||
RodAscendPerk rodAscendPerk = tables.TbRodAscendPerk.GetOrDefault(traitID[i]);
|
||||
string iconName = rodAscendPerk.Icon;
|
||||
uiService.SetImageSprite(traits[i], iconName);
|
||||
uiService.SetImageSprite(trait_tips.trait_icons[i], iconName);
|
||||
trait_tips.trait_names[i].text = LocalizationMgr.GetText(rodAscendPerk.Title_l10n_key);
|
||||
}
|
||||
else
|
||||
{
|
||||
traits[i].transform.parent.gameObject.SetActive(false);
|
||||
trait_tips.tips[i].SetActive(false);
|
||||
}
|
||||
}
|
||||
btn_confrim.onClick.AddListener(OnClickConfrim);
|
||||
btn_questionmark.onClick.AddListener(OnClickQuestion);
|
||||
InitRodList();
|
||||
}
|
||||
void OnClickQuestion()
|
||||
{
|
||||
trait_tips.gameObject.SetActive(true);
|
||||
}
|
||||
void OnClickConfrim()
|
||||
{
|
||||
if (currentRodItem.data.isLock)
|
||||
{
|
||||
//弹提示
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_85"));
|
||||
return;
|
||||
}
|
||||
if (GContext.container.Resolve<PlayerData>().equipRodID != currentRodItem.data.config.ID)
|
||||
{
|
||||
GContext.container.Resolve<PlayerData>().SetEquipRodID(currentRodItem.data.config.ID);
|
||||
}
|
||||
GContext.Publish(new ActChangeRodDataEvent(currentRodItem.data.config.ID));
|
||||
FDM.SetRodData(currentRodItem.data.config.ID);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
void InitRodList()
|
||||
{
|
||||
var _tables = GContext.container.Resolve<Tables>();
|
||||
var dataList = _tables.TbRodData.DataList;
|
||||
int count = dataList.Count;
|
||||
RodData _rodData;
|
||||
PlayerFishData playerFishData = GContext.container.Resolve<PlayerFishData>();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
_rodData = dataList[i];
|
||||
bool isLock = playerFishData.NotRod(_rodData.ID);
|
||||
int level = playerFishData.GetRodLevel(_rodData.ID);
|
||||
int star = playerFishData.GetRodPiece(_rodData.ID);
|
||||
|
||||
RodItemData rodItemData = new RodItemData()
|
||||
{
|
||||
config = dataList[i],
|
||||
isLock = isLock,
|
||||
level = level + 1,
|
||||
star = star,
|
||||
};
|
||||
if (!isLock)
|
||||
{
|
||||
FDM.GetDuelPerk(rodItemData);
|
||||
}
|
||||
|
||||
int skindID = playerFishData.GetRodSkin(_rodData.ID);
|
||||
|
||||
rodItemData.skin = _tables.TbRodSkinData.GetOrDefault(skindID);
|
||||
|
||||
rodItemDatas.Add(rodItemData);
|
||||
}
|
||||
rodItemDatas.Sort(RodItemData.Sort);
|
||||
for (int i = 0; i < rodItemDatas.Count; i++)
|
||||
{
|
||||
GameObject go = Instantiate(item, Content);
|
||||
go.SetActive(true);
|
||||
DuelRodItem rodItem = go.GetComponent<DuelRodItem>();
|
||||
rodItems.Add(rodItem);
|
||||
rodItem.Init(rodItemDatas[i]);
|
||||
rodItem.onClick = OnRodItemClick;
|
||||
|
||||
}
|
||||
currentRodItem = rodItems[0];
|
||||
currentRodItem.SetSelected(true);
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
if (currentRodItem != null && rodItems.Count > 0)
|
||||
{
|
||||
currentRodItem = rodItems[0];
|
||||
currentRodItem.SetSelected(true);
|
||||
}
|
||||
}
|
||||
|
||||
void OnRodItemClick(DuelRodItem duelRodItem)
|
||||
{
|
||||
if (duelRodItem.data.isLock)
|
||||
{
|
||||
ToastPanel.Show(LocalizationMgr.GetText("UI_ToastPanel_85"));
|
||||
return;
|
||||
}
|
||||
if (currentRodItem != null)
|
||||
{
|
||||
currentRodItem.SetSelected(false);
|
||||
}
|
||||
currentRodItem = duelRodItem;
|
||||
currentRodItem.SetSelected(true);
|
||||
}
|
||||
|
||||
public void SetTimer()
|
||||
{
|
||||
StartCoroutine(Close());
|
||||
}
|
||||
IEnumerator Close()
|
||||
{
|
||||
while (allTime > 0)
|
||||
{
|
||||
p_text.text = LocalizationMgr.GetFormatTextValue("UI_EventFishingDuelPanel_41", allTime);
|
||||
allTime--;
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
p_text.text = LocalizationMgr.GetFormatTextValue("UI_EventFishingDuelPanel_41", 0);
|
||||
OnClickConfrim();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
p_text.text = LocalizationMgr.GetText("UI_COMMON_confirm");
|
||||
StopAllCoroutines();
|
||||
currentRodItem.SetSelected(false);
|
||||
RestartShowHomeUIEvent restartShowHomeUIEvent = new RestartShowHomeUIEvent();
|
||||
GContext.Publish(restartShowHomeUIEvent);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user