NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/UI_PatioController.cs

108 lines
2.8 KiB
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UIElements;
using Button = UnityEngine.UI.Button;
using Image = UnityEngine.UI.Image;
using Toggle = UnityEngine.UI.Toggle;
using ScrollView = PhxhSDK.PhxhScrollView;
using Framework;
using System;
using PhxhSDK;
using Gameplay;
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;
SetScrollView();
}
private void CreateScrollView()
{
if (null != mCurrentScrollViewContentObj)
{
CommonUtils.DestoryAllChildGameObject(mCurrentScrollViewContentObj);
}
SetScrollView();
}
private void SetScrollView()
{
_mCurrentScrollView.SetUpdateFunc(RefreshItem);
_mCurrentScrollView.SetItemCountFunc(GetCountFunc);
_mCurrentScrollView.SetButton(SetScrollviewItemButton);
}
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)
{
}
//invoke when reload window
protected override void OnReloadWindow(object data = null)
{
}
//invoke when close window
protected override void OnCloseWindow()
{
}
}