You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

136 lines
4.3 KiB

using IVDataFormat;
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
public class GoodsInfo : MonoBehaviour
{
#region Const
public static GoodsInfo curMgr;
#endregion
#region Ui
[SerializeField]
private Canvas canvasUi;
private Transform trfScroll;
private Transform content;
private Image[] goodsIcon;
private TextMeshProUGUI title;
private TextMeshProUGUI[] txtName;
private TextMeshProUGUI[] txtDesc;
private TextMeshProUGUI[] txtContent;
[SerializeField]
private TextMeshProUGUI mainText;
#endregion
#region Values
private bool bReLocalize = true;
private int[] goodsId;
private int iloading = -1;
private int len;
#endregion
private void Awake()
{
curMgr = this;
setGoodsId();
trfScroll = canvasUi.transform.Find("Scroll");
title = canvasUi.transform.Find("title").GetComponent<TextMeshProUGUI>();
len = goodsId.Length;
goodsIcon = new Image[len];
txtName = new TextMeshProUGUI[len];
txtDesc = new TextMeshProUGUI[len];
txtContent = new TextMeshProUGUI[len];
content = trfScroll.transform.GetChild(0).transform.GetChild(0);
for (int i = 0; i < len; i++)
{
goodsIcon[i] = content.GetChild(i).GetChild(2).GetComponent<Image>();
txtName[i] = content.GetChild(i).GetChild(3).GetComponent<TextMeshProUGUI>();
txtDesc[i] = content.GetChild(i).GetChild(4).GetComponent<TextMeshProUGUI>();
txtContent[i] = content.GetChild(i).GetChild(5).GetComponent<TextMeshProUGUI>();
}
}
public static void SLocalize(bool bmain) => curMgr?.Localize(bmain);
void Localize(bool bmain)
{
if (bmain)
{
mainText.text = LocalizationText.GetText("goods_info");
}
else
{
if (bReLocalize)
{
mainText.text = LocalizationText.GetText("goods_info");
title.text = LocalizationText.GetText("goods_info");
for (int i = 0; i < len; i++)
{
int inum = goodsId[i];
goodsIcon[i].sprite = AddressableMgr.GetGoodsIcon(inum);
txtName[i].text = LocalizationText.GetText(FormatString.CombineAll("currency", inum));
txtDesc[i].text = LocalizationText.GetText(FormatString.CombineAll("currency", inum, "_desc"));
txtContent[i].text = LocalizationText.GetText(FormatString.CombineAll("currency", inum, "_content"));
}
bReLocalize = false;
iloading = 0;
}
}
}
public static void SReLocalize()
{
curMgr.bReLocalize = true;
curMgr.Localize(true);
}
public static bool SCloseMenu()
{
return curMgr.CloseMenu();
}
private bool CloseMenu()
{
if (canvasUi.enabled)
{
CloseGoodsInfo();
return true;
}
return false;
}
public void OpenGoodsInfo()
{
if (iloading > 0)
return;
iloading++;
if(bReLocalize)
Localize(false);
canvasUi.enabled = true;
SoundMgr.PlaySfx(SoundName.BtnPress);
}
public void CloseGoodsInfo()
{
canvasUi.enabled = false;
SoundMgr.PlaySfx(SoundName.BtnPress);
iloading--;
}
private void setGoodsId()
{
goodsId = new int[23] { (int)cGoods.CDia, (int)cGoods.CGold, (int)cGoods.CLvPoint,
(int)cGoods.CEnhanceStoneGear, (int)cGoods.CAwakenStoneGear,(int)cGoods.CEnhanceStoneSkill,(int)cGoods.CAwakenStoneSkill, (int)cGoods.CChangeStone, (int)cGoods.CPudding,(int)cGoods.CCondMight,
(int)cGoods.TDgTicketGold + dConst.RateMax, (int)cGoods.TDgTicketEnhance + dConst.RateMax,(int)cGoods.TDgTicketPet + dConst.RateMax,
(int)cGoods.TDgTicketAwaken + dConst.RateMax, (int)cGoods.TDgTicketRelic + dConst.RateMax,
(int)cGoods.TEventTrade + dConst.RateMax,(int)cGoods.TEventRoulette + dConst.RateMax, (int)cGoods.TEventRaise + dConst.RateMax,
(int)cGoods.CGachaTokenWeapon, (int)cGoods.CGachaTokenArmor, (int)cGoods.CGachaTokenAcce, (int)cGoods.CGachaTokenTreasure, (int)cGoods.CMileage};
}
}