2024-06-03 17:06:54 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using Gameplay;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
|
|
public class UIVehicleHeadNode: UINode
|
|
|
|
|
|
{
|
|
|
|
|
|
public Image imgBg;
|
|
|
|
|
|
public Image imgHead;
|
|
|
|
|
|
public Image imgPro;
|
|
|
|
|
|
public Button button;
|
|
|
|
|
|
|
|
|
|
|
|
private UIVehicleHeadInfo _data;
|
|
|
|
|
|
private VehicleCultivateData _vehicleInfo;
|
|
|
|
|
|
|
|
|
|
|
|
#region FrameWork
|
|
|
|
|
|
|
|
|
|
|
|
private void _GetComponents()
|
|
|
|
|
|
{
|
|
|
|
|
|
imgBg = _GetComponent<Image>("ImageBg");
|
|
|
|
|
|
imgHead = _GetComponent<Image>("ImageHeadPic");
|
|
|
|
|
|
imgPro = _GetComponent<Image>("ImageProfession");
|
|
|
|
|
|
button = _GetComponent<Button>("Button");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _Refresh(bool isAsync = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (isAsync)
|
|
|
|
|
|
{
|
|
|
|
|
|
_RefreshAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _RefreshAsync()
|
|
|
|
|
|
{
|
|
|
|
|
|
_RefreshHeadAsync();
|
|
|
|
|
|
_RefreshProAsync();
|
2024-06-04 19:21:34 +08:00
|
|
|
|
_AddButton();
|
2024-06-03 17:06:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async void _RefreshHeadAsync()
|
|
|
|
|
|
{
|
|
|
|
|
|
var sprite = await LoadAssetAsync<Sprite>(VehicleDataHelper.GetVehiclePicPath((int)_data.Uid));
|
|
|
|
|
|
imgHead.sprite = sprite;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private async void _RefreshProAsync()
|
|
|
|
|
|
{
|
2024-06-04 19:21:34 +08:00
|
|
|
|
//_AddButton();
|
2024-06-03 17:06:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _AddButton()
|
|
|
|
|
|
{
|
|
|
|
|
|
ClearBind(button);
|
|
|
|
|
|
var clickFunc = _data.ClickFunc;
|
|
|
|
|
|
if (clickFunc != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (clickFunc is Action act)
|
|
|
|
|
|
{
|
|
|
|
|
|
BindButton(button, act);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void _AddButton<T>(T param)
|
|
|
|
|
|
{
|
|
|
|
|
|
ClearBind(button);
|
|
|
|
|
|
var clickFunc = _data.ClickFunc;
|
|
|
|
|
|
if (clickFunc != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (clickFunc is Action<T> actT)
|
|
|
|
|
|
{
|
|
|
|
|
|
BindButton(button, actT, param);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Unity EventFunction
|
|
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
|
{
|
|
|
|
|
|
OnRelease();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region API
|
|
|
|
|
|
|
|
|
|
|
|
public void SetData(UIVehicleHeadInfo data)
|
|
|
|
|
|
{
|
|
|
|
|
|
_data = data;
|
|
|
|
|
|
if (!VehicleCultivateDataManager.Instance.DataDic.ContainsKey(_data.Uid))
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUtil.LogError("加载头像时出现错误,未拥有该载具,载具ID:" + _data.Uid);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
_vehicleInfo = VehicleCultivateDataManager.Instance.DataDic[_data.Uid];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetClickFuncParam<T>(T param)
|
|
|
|
|
|
{
|
|
|
|
|
|
_AddButton(param);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Refresh()
|
|
|
|
|
|
{
|
|
|
|
|
|
_Refresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class UIVehicleHeadInfo
|
|
|
|
|
|
{
|
|
|
|
|
|
private uint _uid;
|
|
|
|
|
|
|
|
|
|
|
|
public uint Uid => _uid;
|
|
|
|
|
|
public bool IsShowBg = false;
|
|
|
|
|
|
public bool IsShowPro;
|
|
|
|
|
|
public Delegate ClickFunc;
|
|
|
|
|
|
|
|
|
|
|
|
public UIVehicleHeadInfo(uint uid)
|
|
|
|
|
|
{
|
|
|
|
|
|
_uid = uid;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|