116 lines
3.3 KiB
C#
116 lines
3.3 KiB
C#
using Gameplay;
|
|
using PhxhSDK;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class UI_PatioController : UIWindow
|
|
{
|
|
//UI GameObj
|
|
///Auto Gen Start///
|
|
|
|
///Auto Gen End///
|
|
|
|
// Use this for initialization
|
|
List<NormalShopItemData> mShopDataList;
|
|
PhxhScrollView _mCurrentScrollView = null;
|
|
private GameObject mCurrentScrollViewContentObj = null;
|
|
Dictionary<GameObject, NormalShopItemData> mShopItemGoDataDic;
|
|
|
|
|
|
public override void OnAwake()
|
|
{
|
|
//bind UI GameObj
|
|
UI_PatioBinder.GetComponents(this);
|
|
mShopDataList = new List<NormalShopItemData>();
|
|
_mCurrentScrollView = GetComponent<PhxhScrollView>("Scroll View");
|
|
mCurrentScrollViewContentObj = FindObj("Scroll View/Viewport/Content");
|
|
|
|
}
|
|
|
|
//invoke when open window
|
|
protected override void OnOpenWindow(object data)
|
|
{
|
|
NormalShopDataForGacha nowShopData = data as NormalShopDataForGacha;
|
|
mShopDataList = nowShopData.normalShopItemDatas;
|
|
CreateScrollView();
|
|
|
|
}
|
|
private void CreateScrollView()
|
|
{
|
|
if (null != mCurrentScrollViewContentObj)
|
|
{
|
|
CommonUtils.DestoryAllChildGameObject(mCurrentScrollViewContentObj);
|
|
}
|
|
SetScrollView();
|
|
RefreshScrollview();
|
|
}
|
|
|
|
private void SetScrollView()
|
|
{
|
|
_mCurrentScrollView.SetUpdateFunc(RefreshItem);
|
|
_mCurrentScrollView.SetItemCountFunc(GetCountFunc);
|
|
_mCurrentScrollView.SetButton(SetScrollviewItemButton);
|
|
}
|
|
private void RefreshScrollview()
|
|
{
|
|
_mCurrentScrollView.UpdateData(false);
|
|
}
|
|
private int GetCountFunc()
|
|
{
|
|
return mShopDataList.Count;
|
|
}
|
|
private void SetScrollviewItemButton(GameObject obj)
|
|
{
|
|
GameObject singleObj = CommonUtils.GetGameObject(obj, "ClickBtn");
|
|
|
|
ClearBind(singleObj);
|
|
BindButton<GameObject>(singleObj, OnShopItemClick, singleObj);
|
|
}
|
|
|
|
private void OnShopItemClick(GameObject obj)
|
|
{
|
|
NormalShopItemData info = mShopItemGoDataDic[obj];
|
|
|
|
//await UIManager.Instance.OpenWindow(UINameConst.UI_Purchase, shopItemContainPic);
|
|
|
|
}
|
|
|
|
private void RefreshItem(int index, RectTransform item)
|
|
{
|
|
item.gameObject.SetActive(true);
|
|
NormalShopItemData normalShopData = mShopDataList[index];
|
|
RefreshSingleItem(item.gameObject,normalShopData);
|
|
mShopItemGoDataDic[item.gameObject]= normalShopData;
|
|
}
|
|
|
|
private void RefreshSingleItem(GameObject gameObject, NormalShopItemData normalShopData)
|
|
{
|
|
var uiHeadInfo = new UIHeadInfo((uint)CommonUtils.GetItemCharacterCfgId(normalShopData.id), false)
|
|
{
|
|
// ClickCb = (Action<int>)OnClickItem,
|
|
IsShowBg = false
|
|
};
|
|
UIHeadItemNode headItemNode = CommonUtils.GetComponent<UIHeadItemNode>(gameObject, "Head/UIHeadItemNode");
|
|
headItemNode.GetComponents();
|
|
headItemNode.SetData(uiHeadInfo);
|
|
//headItemNode.SetClickCbParam(index);
|
|
headItemNode.Refresh(false);
|
|
|
|
CommonUtils.GetComponent<TMP_Text>(gameObject, "Price").text = normalShopData.price.ToString();
|
|
}
|
|
|
|
//invoke when reload window
|
|
protected override void OnReloadWindow(object data = null)
|
|
{
|
|
|
|
}
|
|
|
|
//invoke when close window
|
|
protected override void OnCloseWindow()
|
|
{
|
|
|
|
}
|
|
}
|