114 lines
2.4 KiB
C#
114 lines
2.4 KiB
C#
using System;
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
// ReSharper disable UnassignedGetOnlyAutoProperty
|
|
|
|
namespace BITKit.UX
|
|
{
|
|
/// <summary>
|
|
/// 基本UX面板接口,定义了基本的UX面板功能
|
|
/// </summary>
|
|
/// <para>⭐同步打开与关闭</para>
|
|
/// <para>⭐异步打开与关闭</para>
|
|
/// <para>⭐当前可见状态</para>
|
|
/// <para>⭐基本UI导航回调</para>
|
|
public interface IUXPanel:IEntryElement,IUpdate
|
|
{
|
|
/// <summary>
|
|
/// 该面板是否具有动画
|
|
/// </summary>
|
|
bool IsAnimate { get; }
|
|
/// <summary>
|
|
/// 该面板是否有效,用于检查该面板是否已经被销毁
|
|
/// </summary>
|
|
bool IsValid { get; }
|
|
/// <summary>
|
|
/// 该面板的索引(入口,Key)
|
|
/// </summary>
|
|
string Index { get; }
|
|
/// <summary>
|
|
/// 该面板是否启用指针
|
|
/// </summary>
|
|
bool AllowCursor { get; }
|
|
/// <summary>
|
|
/// 该面板是否启用玩家输入
|
|
/// </summary>
|
|
bool AllowInput { get; }
|
|
/// <summary>
|
|
/// 事件回调,当面板被打开时触发
|
|
/// </summary>
|
|
event Action OnEntry;
|
|
/// <summary>
|
|
/// 事件回调,当面板被关闭时触发
|
|
/// </summary>
|
|
event Action OnExit;
|
|
}
|
|
public abstract class UXPanelImplement:IUXPanel
|
|
{
|
|
protected abstract IUXPanel service { get; }
|
|
private IUXPanel _iuxPanelImplementation => service;
|
|
public bool IsAnimate => _iuxPanelImplementation.IsAnimate;
|
|
|
|
public bool IsValid => _iuxPanelImplementation.IsValid;
|
|
|
|
public string Index => _iuxPanelImplementation.Index;
|
|
|
|
public bool AllowCursor => _iuxPanelImplementation.AllowCursor;
|
|
|
|
public bool AllowInput => _iuxPanelImplementation.AllowInput;
|
|
|
|
public bool IsEntered
|
|
{
|
|
get => service.IsEntered;
|
|
set => service.IsEntered = value;
|
|
}
|
|
|
|
public void Entry()
|
|
{
|
|
_iuxPanelImplementation.Entry();
|
|
}
|
|
|
|
public UniTask EntryAsync()
|
|
{
|
|
return service.EntryAsync();
|
|
}
|
|
|
|
public void Entered()
|
|
{
|
|
service.Entered();
|
|
}
|
|
|
|
public void Exit()
|
|
{
|
|
_iuxPanelImplementation.Exit();
|
|
}
|
|
|
|
public UniTask ExitAsync()
|
|
{
|
|
return service.ExitAsync();
|
|
}
|
|
|
|
public void Exited()
|
|
{
|
|
service.Exited();
|
|
}
|
|
|
|
public event Action OnEntry
|
|
{
|
|
add => _iuxPanelImplementation.OnEntry += value;
|
|
remove => _iuxPanelImplementation.OnEntry -= value;
|
|
}
|
|
|
|
public event Action OnExit
|
|
{
|
|
add => _iuxPanelImplementation.OnExit += value;
|
|
remove => _iuxPanelImplementation.OnExit -= value;
|
|
}
|
|
|
|
public void OnUpdate(float deltaTime)
|
|
{
|
|
service.OnUpdate(deltaTime);
|
|
}
|
|
}
|
|
}
|