177 lines
4.5 KiB
C#
177 lines
4.5 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
|
|||
|
public class BagPanel : BasePanel
|
|||
|
{
|
|||
|
//<2F><>ť<EFBFBD><C5A5>ʼ<EFBFBD><CABC>ɫ<EFBFBD>ǰ<EFBFBD>ɫ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɻ<EFBFBD>ɫ
|
|||
|
private string imgColor = "6A6A6A";
|
|||
|
//<2F><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ɫ <20><><EFBFBD><EFBFBD>
|
|||
|
private string txtColor1 = "225555";
|
|||
|
//<2F><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ dz<><C7B3>
|
|||
|
private string txtColor2 = "CDDACF";
|
|||
|
|
|||
|
public Button btnAll;
|
|||
|
public Button btnMater;
|
|||
|
public Button btnPill;
|
|||
|
public Button btnGong;
|
|||
|
|
|||
|
public Text txtAll;
|
|||
|
public Text txtMater;
|
|||
|
public Text txtPill;
|
|||
|
public Text txtGong;
|
|||
|
public Text txtStone;
|
|||
|
public Text txtYu;
|
|||
|
public Text txtInfo;
|
|||
|
|
|||
|
public ScrollRect sv;
|
|||
|
|
|||
|
//<2F><>ƷԤ<C6B7><D4A4><EFBFBD><EFBFBD>
|
|||
|
public GameObject btnMaterial;
|
|||
|
|
|||
|
//ѡ<><D1A1><EFBFBD>İ<EFBFBD>ť
|
|||
|
private Button btnChoose;
|
|||
|
//ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
private Text txtChoose;
|
|||
|
|
|||
|
private UserGoodsInfo goods;
|
|||
|
//װ<><D7B0><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD>ڸ<EFBFBD><DAB8><EFBFBD>ҳ<EFBFBD><D2B3>
|
|||
|
private List<GameObject> goodsList = new List<GameObject>();
|
|||
|
|
|||
|
public override void Init()
|
|||
|
{
|
|||
|
btnChoose = btnAll;
|
|||
|
txtChoose = txtAll;
|
|||
|
goods=GameDataMgr.Instance.userGoods;
|
|||
|
UpdatePanel();
|
|||
|
|
|||
|
//ȫ<><C8AB><EFBFBD><EFBFBD>ť
|
|||
|
btnAll.onClick.AddListener(() =>
|
|||
|
{
|
|||
|
//<2F><><EFBFBD>ǵ<EFBFBD>ǰ<EFBFBD><C7B0>ť<EFBFBD>Ÿ<EFBFBD><C5B8><EFBFBD>
|
|||
|
if (btnChoose != btnAll)
|
|||
|
{
|
|||
|
//<2F><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>
|
|||
|
UpdateAllGoods();
|
|||
|
}
|
|||
|
});
|
|||
|
//<2F><><EFBFBD>ϰ<EFBFBD>ť
|
|||
|
btnMater.onClick.AddListener(() =>
|
|||
|
{
|
|||
|
//<2F><><EFBFBD>ǵ<EFBFBD>ǰ<EFBFBD><C7B0>ť<EFBFBD>Ÿ<EFBFBD><C5B8><EFBFBD>
|
|||
|
if (btnChoose != btnMater)
|
|||
|
{
|
|||
|
//<2F><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>
|
|||
|
//<2F><><EFBFBD>ð<EFBFBD>ť<EFBFBD><C5A5>ɫ
|
|||
|
SetColor(btnMater, txtMater);
|
|||
|
UpdateGoods(2);
|
|||
|
}
|
|||
|
});
|
|||
|
//<2F><>ҩ<EFBFBD><D2A9>ť
|
|||
|
btnPill.onClick.AddListener(() =>
|
|||
|
{
|
|||
|
//<2F><><EFBFBD>ǵ<EFBFBD>ǰ<EFBFBD><C7B0>ť<EFBFBD>Ÿ<EFBFBD><C5B8><EFBFBD>
|
|||
|
if (btnChoose != btnPill)
|
|||
|
{
|
|||
|
//<2F><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>
|
|||
|
//<2F><><EFBFBD>ð<EFBFBD>ť<EFBFBD><C5A5>ɫ
|
|||
|
SetColor(btnPill, txtPill);
|
|||
|
UpdateGoods(1);
|
|||
|
}
|
|||
|
});
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
|
|||
|
btnGong.onClick.AddListener(() =>
|
|||
|
{
|
|||
|
//<2F><><EFBFBD>ǵ<EFBFBD>ǰ<EFBFBD><C7B0>ť<EFBFBD>Ÿ<EFBFBD><C5B8><EFBFBD>
|
|||
|
if (btnChoose != btnGong)
|
|||
|
{
|
|||
|
//<2F><><EFBFBD>½<EFBFBD><C2BD><EFBFBD>
|
|||
|
//<2F><><EFBFBD>ð<EFBFBD>ť<EFBFBD><C5A5>ɫ
|
|||
|
SetColor(btnGong, txtGong);
|
|||
|
UpdateGoods(3);
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD>ı䰴ť<E4B0B4><C5A5><EFBFBD><EFBFBD>ɫ
|
|||
|
/// </summary>
|
|||
|
/// <param name="btn"></param>
|
|||
|
/// <param name="txt"></param>
|
|||
|
public void SetColor(Button btn, Text txt)
|
|||
|
{
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫǰ<C9AB>Ȱ<EFBFBD><C8B0><EFBFBD>һ<EFBFBD>εİ<CEB5>ť<EFBFBD><C5A5>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>
|
|||
|
if (btnChoose != null && txtChoose != null)
|
|||
|
{
|
|||
|
btnChoose.image.color = Color.white;
|
|||
|
txtChoose.color = GameMgr.Instance.HexToColor(txtColor1);
|
|||
|
}
|
|||
|
//Ȼ<><C8BB><EFBFBD><EFBFBD><EFBFBD>ô˴ε<CBB4><CEB5><EFBFBD><EFBFBD>İ<EFBFBD>ť<EFBFBD><C5A5>ɫ
|
|||
|
btn.image.color = GameMgr.Instance.HexToColor(imgColor);
|
|||
|
txt.color = GameMgr.Instance.HexToColor(txtColor2);
|
|||
|
//<2F><><EFBFBD><EFBFBD>Ϊ<EFBFBD>µİ<C2B5>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|||
|
btnChoose = btn;
|
|||
|
txtChoose = txt;
|
|||
|
}
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
public void UpdatePanel()
|
|||
|
{
|
|||
|
UpdateAllGoods();
|
|||
|
SetColor(btnAll, txtAll);
|
|||
|
txtStone.text = "<22><>ʯ<EFBFBD><CAAF>"+GameMgr.Instance.SetNumber(GameDataMgr.Instance.player.stone);
|
|||
|
txtYu.text = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"+GameMgr.Instance.SetNumber(GameDataMgr.Instance.player.yu);
|
|||
|
}
|
|||
|
|
|||
|
//ȫ<><C8AB><EFBFBD><EFBFBD>Ʒ
|
|||
|
private void UpdateAllGoods()
|
|||
|
{
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD>б<EFBFBD>
|
|||
|
for (int i = 0; i < goodsList.Count; i++)
|
|||
|
{
|
|||
|
Destroy(goodsList[i]);
|
|||
|
}
|
|||
|
goodsList.Clear();
|
|||
|
|
|||
|
for (int i = 0; i < goods.goods.Count; i++)
|
|||
|
{
|
|||
|
GameObject go = Instantiate(btnMaterial);
|
|||
|
go.GetComponent<BtnMaterial>().UpdatePanel(goods.goods[i]);
|
|||
|
go.transform.SetParent(sv.content, false);
|
|||
|
goodsList.Add(go);
|
|||
|
}
|
|||
|
|
|||
|
txtInfo.text = "";
|
|||
|
}
|
|||
|
|
|||
|
private void UpdateGoods(int goodsType)
|
|||
|
{
|
|||
|
//1<><31>ҩ<EFBFBD><D2A9>2<EFBFBD><32><EFBFBD><EFBFBD>
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD>б<EFBFBD>
|
|||
|
for (int i = 0; i < goodsList.Count; i++)
|
|||
|
{
|
|||
|
Destroy(goodsList[i]);
|
|||
|
}
|
|||
|
goodsList.Clear();
|
|||
|
|
|||
|
for (int i = 0; i < goods.goods.Count; i++)
|
|||
|
{
|
|||
|
if (goods.goods[i].goodsType == goodsType)
|
|||
|
{
|
|||
|
GameObject go = Instantiate(btnMaterial);
|
|||
|
go.GetComponent<BtnMaterial>().UpdatePanel(goods.goods[i]);
|
|||
|
go.transform.SetParent(sv.content, false);
|
|||
|
goodsList.Add(go);
|
|||
|
}
|
|||
|
}
|
|||
|
txtInfo.text = "";
|
|||
|
}
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
public void UpdateTxtInfo(GoodsData info)
|
|||
|
{
|
|||
|
txtInfo.text = "<22><>Ʒ<EFBFBD><C6B7><EFBFBD>ƣ<EFBFBD>"+info.name+"\n<><6E>Ʒ<EFBFBD><C6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"+info.info;
|
|||
|
}
|
|||
|
}
|