87 lines
2.2 KiB
C#
87 lines
2.2 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using UnityEngine.UI;
|
|
using System.Collections.Generic;
|
|
|
|
public class AucationSelfRecordPanel : MonoBehaviour {
|
|
|
|
public static AucationSelfRecordPanel Instance;
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
Instance = null;
|
|
}
|
|
|
|
|
|
public GameObject itemPrefab;
|
|
public Transform itemPrefabParent;
|
|
public GameObject noInfoIcon;
|
|
|
|
private void OnEnable()
|
|
{
|
|
AskForInfo();
|
|
}
|
|
|
|
public void AskForInfo()
|
|
{
|
|
CG_REQ_SNATCH_BET_ITEMS req = (CG_REQ_SNATCH_BET_ITEMS)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_SNATCH_BET_ITEMS);
|
|
req.SetType(3);
|
|
req.SendPacket();
|
|
}
|
|
|
|
private List<GameObject> itemPrefabList = new List<GameObject>();
|
|
public void CreatePrefab(GC_RET_SNATCH_HISTORY_RET_ITEMS packet)
|
|
{
|
|
ClearAllPrefabAndList();
|
|
if(packet.historyItemInfoCount <= 0)
|
|
{
|
|
if(!noInfoIcon.activeInHierarchy)
|
|
{
|
|
noInfoIcon.SetActive(true);
|
|
return;
|
|
}
|
|
}else
|
|
{
|
|
if (noInfoIcon.activeInHierarchy)
|
|
{
|
|
noInfoIcon.SetActive(false);
|
|
}
|
|
}
|
|
|
|
for (int index = 0; index < packet.historyItemInfoCount; index++)
|
|
{
|
|
GameObject item = GameObject.Instantiate(itemPrefab);
|
|
|
|
item.transform.SetParent(itemPrefabParent);
|
|
item.transform.localPosition = Vector3.zero;
|
|
item.transform.localRotation = Quaternion.Euler(Vector3.zero);
|
|
item.transform.localScale = Vector3.one;
|
|
|
|
item.GetComponent<AucationSelfRecordItem>().InitItem(packet.GetHistoryItemInfo(index).Tm,
|
|
packet.GetHistoryItemInfo(index).ItemIndexId,
|
|
packet.GetHistoryItemInfo(index).Betnum,
|
|
index);
|
|
|
|
itemPrefabList.Add(item);
|
|
}
|
|
}
|
|
|
|
public void ClearAllPrefabAndList()
|
|
{
|
|
for (int index = 0; index < itemPrefabList.Count; index++)
|
|
{
|
|
GameObject.Destroy(itemPrefabList[index]);
|
|
}
|
|
itemPrefabList.Clear();
|
|
}
|
|
|
|
public void OnCloseBtnClick()
|
|
{
|
|
UIManager.CloseUI(UIInfo.AucationSelfRecordPanel);
|
|
}
|
|
|
|
}
|