This commit is contained in:
SepComet
2026-02-26 13:21:43 +08:00
parent a118803f1a
commit 4daefa17d5
1259 changed files with 290021 additions and 1 deletions
+13
View File
@@ -0,0 +1,13 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# Rider 忽略的文件
/modules.xml
/projectSettingsUpdater.xml
/.idea.UI.iml
/contentModel.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../../.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/../../../GameFramework" vcs="Git" />
</component>
</project>
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d22b16bf76d2e504f9a8504ceb15b10c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
namespace GeometryTD.UI
{
public interface IUIFormController
{
int? OpenUI(object userData = null);
void CloseUI();
void BindUseCase(IUIUseCase useCase);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 63bbd9f533c214c40b43e910c9e2e096
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,6 @@
namespace GeometryTD.UI
{
public interface IUIUseCase
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 29f3a280b77ccf746a4a219a991717c7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+250
View File
@@ -0,0 +1,250 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using GeometryTD;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityGameFramework.Runtime;
namespace GeometryTD.UI
{
public abstract class UGuiForm : UIFormLogic
{
public const int DepthFactor = 100;
private const float FadeTime = 0.3f;
private static Font _mainFont = null;
private static TMP_FontAsset _mainTMPFont = null;
private Canvas _cachedCanvas = null;
private CanvasGroup _canvasGroup = null;
private List<Canvas> _cachedCanvasContainer = new List<Canvas>();
public int OriginalDepth { get; private set; }
public int Depth => _cachedCanvas.sortingOrder;
public void Close()
{
Close(false);
}
public void Close(bool ignoreFade)
{
StopAllCoroutines();
if (ignoreFade)
{
GameEntry.UI.CloseUIForm(this);
}
else
{
StartCoroutine(CloseCo(FadeTime));
}
}
public void PlayUISound(int uiSoundId)
{
GameEntry.Sound.PlayUISound(uiSoundId);
}
public static void SetMainFont(Font mainFont)
{
if (mainFont == null)
{
Log.Error("Main font is invalid.");
return;
}
_mainFont = mainFont;
}
public static void SetMainTMPFont(TMP_FontAsset mainTMPFont)
{
if (mainTMPFont == null)
{
Log.Error("Main font is invalid.");
return;
}
_mainTMPFont = mainTMPFont;
}
#if UNITY_2017_3_OR_NEWER
protected override void OnInit(object userData)
#else
protected internal override void OnInit(object userData)
#endif
{
base.OnInit(userData);
_cachedCanvas = gameObject.GetOrAddComponent<Canvas>();
_cachedCanvas.overrideSorting = true;
OriginalDepth = _cachedCanvas.sortingOrder;
_canvasGroup = gameObject.GetOrAddComponent<CanvasGroup>();
RectTransform rect = GetComponent<RectTransform>();
rect.anchorMin = Vector2.zero;
rect.anchorMax = Vector2.one;
rect.anchoredPosition = Vector2.zero;
rect.sizeDelta = Vector2.zero;
gameObject.GetOrAddComponent<GraphicRaycaster>();
if (_mainTMPFont == null)
{
Log.Warning("Main TMP font isn't set.");
}
else
{
var tmp_texts = GetComponentsInChildren<TMP_Text>(true);
foreach (var text in tmp_texts)
{
text.font = _mainTMPFont;
if (!string.IsNullOrEmpty(text.text))
{
text.text = GameEntry.Localization.GetString(text.text);
}
}
}
if (_mainFont == null)
{
Log.Warning("Main font isn't set.");
}
else
{
var texts = GetComponentsInChildren<Text>(true);
foreach (var text in texts)
{
text.font = _mainFont;
if (!string.IsNullOrEmpty(text.text))
{
text.text = GameEntry.Localization.GetString(text.text);
}
}
}
}
#if UNITY_2017_3_OR_NEWER
protected override void OnRecycle()
#else
protected internal override void OnRecycle()
#endif
{
base.OnRecycle();
}
#if UNITY_2017_3_OR_NEWER
protected override void OnOpen(object userData)
#else
protected internal override void OnOpen(object userData)
#endif
{
base.OnOpen(userData);
_canvasGroup.alpha = 0f;
StopAllCoroutines();
StartCoroutine(_canvasGroup.FadeToAlpha(1f, FadeTime));
}
#if UNITY_2017_3_OR_NEWER
protected override void OnClose(bool isShutdown, object userData)
#else
protected internal override void OnClose(bool isShutdown, object userData)
#endif
{
base.OnClose(isShutdown, userData);
}
#if UNITY_2017_3_OR_NEWER
protected override void OnPause()
#else
protected internal override void OnPause()
#endif
{
base.OnPause();
}
#if UNITY_2017_3_OR_NEWER
protected override void OnResume()
#else
protected internal override void OnResume()
#endif
{
base.OnResume();
_canvasGroup.alpha = 0f;
StopAllCoroutines();
StartCoroutine(_canvasGroup.FadeToAlpha(1f, FadeTime));
}
#if UNITY_2017_3_OR_NEWER
protected override void OnCover()
#else
protected internal override void OnCover()
#endif
{
base.OnCover();
}
#if UNITY_2017_3_OR_NEWER
protected override void OnReveal()
#else
protected internal override void OnReveal()
#endif
{
base.OnReveal();
}
#if UNITY_2017_3_OR_NEWER
protected override void OnRefocus(object userData)
#else
protected internal override void OnRefocus(object userData)
#endif
{
base.OnRefocus(userData);
}
#if UNITY_2017_3_OR_NEWER
protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
#else
protected internal override void OnUpdate(float elapseSeconds, float realElapseSeconds)
#endif
{
base.OnUpdate(elapseSeconds, realElapseSeconds);
}
#if UNITY_2017_3_OR_NEWER
protected override void OnDepthChanged(int uiGroupDepth, int depthInUIGroup)
#else
protected internal override void OnDepthChanged(int uiGroupDepth, int depthInUIGroup)
#endif
{
int oldDepth = Depth;
base.OnDepthChanged(uiGroupDepth, depthInUIGroup);
int deltaDepth = UGuiGroupHelper.DepthFactor * uiGroupDepth + DepthFactor * depthInUIGroup - oldDepth +
OriginalDepth;
GetComponentsInChildren(true, _cachedCanvasContainer);
for (int i = 0; i < _cachedCanvasContainer.Count; i++)
{
_cachedCanvasContainer[i].sortingOrder += deltaDepth;
}
_cachedCanvasContainer.Clear();
}
private IEnumerator CloseCo(float duration)
{
yield return _canvasGroup.FadeToAlpha(0f, duration);
GameEntry.UI.CloseUIForm(this);
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0b92f84dc56dc764a9c261fe47df5520
timeCreated: 1528026161
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,53 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using UnityEngine;
using UnityEngine.UI;
using UnityGameFramework.Runtime;
namespace GeometryTD.UI
{
/// <summary>
/// uGUI 界面组辅助器。
/// </summary>
public class UGuiGroupHelper : UIGroupHelperBase
{
public const int DepthFactor = 10000;
private int m_Depth = 0;
private Canvas m_CachedCanvas = null;
/// <summary>
/// 设置界面组深度。
/// </summary>
/// <param name="depth">界面组深度。</param>
public override void SetDepth(int depth)
{
m_Depth = depth;
m_CachedCanvas.overrideSorting = true;
m_CachedCanvas.sortingOrder = DepthFactor * depth;
}
private void Awake()
{
m_CachedCanvas = gameObject.GetOrAddComponent<Canvas>();
gameObject.GetOrAddComponent<GraphicRaycaster>();
}
private void Start()
{
m_CachedCanvas.overrideSorting = true;
m_CachedCanvas.sortingOrder = DepthFactor * m_Depth;
RectTransform transform = GetComponent<RectTransform>();
transform.anchorMin = Vector2.zero;
transform.anchorMax = Vector2.one;
transform.anchoredPosition = Vector2.zero;
transform.sizeDelta = Vector2.zero;
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 05a35a4a1f7dd5646a70cb1a73348780
timeCreated: 1528026161
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,6 @@
namespace GeometryTD.UI
{
public class UIContext
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ad938323d1c8a364baace3c6d97b6431
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,182 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using GameFramework.DataTable;
using GameFramework.UI;
using System.Collections;
using GeometryTD.Procedure;
using GeometryTD;
using GeometryTD.CustomUtility;
using GeometryTD.DataTable;
using GeometryTD.Definition;
using UnityEngine;
using UnityEngine.UI;
using UnityGameFramework.Runtime;
namespace GeometryTD.UI
{
public static class UIExtension
{
public static IEnumerator FadeToAlpha(this CanvasGroup canvasGroup, float alpha, float duration)
{
float time = 0f;
float originalAlpha = canvasGroup.alpha;
while (time < duration)
{
time += Time.deltaTime;
canvasGroup.alpha = Mathf.Lerp(originalAlpha, alpha, time / duration);
yield return new WaitForEndOfFrame();
}
canvasGroup.alpha = alpha;
}
public static IEnumerator SmoothValue(this Slider slider, float value, float duration)
{
float time = 0f;
float originalValue = slider.value;
while (time < duration)
{
time += Time.deltaTime;
slider.value = Mathf.Lerp(originalValue, value, time / duration);
yield return new WaitForEndOfFrame();
}
slider.value = value;
}
public static bool HasUIForm(this UIComponent uiComponent, UIFormType uiFormId, string uiGroupName = null)
{
return uiComponent.HasUIForm((int)uiFormId, uiGroupName);
}
public static bool HasUIForm(this UIComponent uiComponent, int uiFormId, string uiGroupName = null)
{
IDataTable<DRUIForm> dtUIForm = GameEntry.DataTable.GetDataTable<DRUIForm>();
DRUIForm drUIForm = dtUIForm.GetDataRow(uiFormId);
if (drUIForm == null)
{
return false;
}
string assetName = AssetUtility.GetUIFormAsset(drUIForm.AssetName);
if (string.IsNullOrEmpty(uiGroupName))
{
return uiComponent.HasUIForm(assetName);
}
IUIGroup uiGroup = uiComponent.GetUIGroup(uiGroupName);
if (uiGroup == null)
{
return false;
}
return uiGroup.HasUIForm(assetName);
}
public static UGuiForm GetUIForm(this UIComponent uiComponent, UIFormType uiFormId, string uiGroupName = null)
{
return uiComponent.GetUIForm((int)uiFormId, uiGroupName);
}
public static UGuiForm GetUIForm(this UIComponent uiComponent, int uiFormId, string uiGroupName = null)
{
IDataTable<DRUIForm> dtUIForm = GameEntry.DataTable.GetDataTable<DRUIForm>();
DRUIForm drUIForm = dtUIForm.GetDataRow(uiFormId);
if (drUIForm == null)
{
return null;
}
string assetName = AssetUtility.GetUIFormAsset(drUIForm.AssetName);
UIForm uiForm = null;
if (string.IsNullOrEmpty(uiGroupName))
{
uiForm = uiComponent.GetUIForm(assetName);
if (uiForm == null)
{
return null;
}
return (UGuiForm)uiForm.Logic;
}
IUIGroup uiGroup = uiComponent.GetUIGroup(uiGroupName);
if (uiGroup == null)
{
return null;
}
uiForm = (UIForm)uiGroup.GetUIForm(assetName);
if (uiForm == null)
{
return null;
}
return (UGuiForm)uiForm.Logic;
}
public static void CloseUIForm(this UIComponent uiComponent, UGuiForm uiForm)
{
uiComponent.CloseUIForm(uiForm.UIForm);
}
public static int? OpenUIForm(this UIComponent uiComponent, UIFormType uiFormId, object userData = null)
{
return uiComponent.OpenUIForm((int)uiFormId, userData);
}
public static int? OpenUIForm(this UIComponent uiComponent, int uiFormId, object userData = null)
{
IDataTable<DRUIForm> dtUIForm = GameEntry.DataTable.GetDataTable<DRUIForm>();
DRUIForm drUIForm = dtUIForm.GetDataRow(uiFormId);
if (drUIForm == null)
{
Log.Warning("Can not load UI form '{0}' from data table.", uiFormId.ToString());
return null;
}
string assetName = AssetUtility.GetUIFormAsset(drUIForm.AssetName);
if (!drUIForm.AllowMultiInstance)
{
if (uiComponent.IsLoadingUIForm(assetName))
{
return null;
}
if (uiComponent.HasUIForm(assetName))
{
return null;
}
}
return uiComponent.OpenUIForm(assetName, drUIForm.UIGroupName, Constant.AssetPriority.UIFormAsset,
drUIForm.PauseCoveredUIForm, userData);
}
public static void OpenDialog(this UIComponent uiComponent, DialogParams dialogParams)
{
if (((ProcedureBase)GameEntry.Procedure.CurrentProcedure).UseNativeDialog)
{
OpenNativeDialog(dialogParams);
}
else
{
uiComponent.OpenUIForm(UIFormType.DialogForm, dialogParams);
}
}
private static void OpenNativeDialog(DialogParams dialogParams)
{
// TODO:这里应该弹出原生对话框,先简化实现为直接按确认按钮
if (dialogParams.OnClickConfirm != null)
{
dialogParams.OnClickConfirm(dialogParams.UserData);
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9cfc2c881ce240349901812c61f4476b
timeCreated: 1528026162
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,10 @@
namespace GeometryTD.UI
{
public abstract class UIFormControllerBase<TContext> : IUIFormController where TContext : UIContext
{
protected abstract int? OpenUIInternal(TContext context);
public abstract int? OpenUI(object userData = null);
public abstract void CloseUI();
public abstract void BindUseCase(IUIUseCase useCase);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f14634cead1af164d8795233697f4100
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,183 @@
using GeometryTD.Definition;
using GameFramework.Event;
using UnityGameFramework.Runtime;
namespace GeometryTD.UI
{
public abstract class UIFormControllerCommonBase<TContext, TForm> : UIFormControllerBase<TContext>
where TContext : UIContext
where TForm : UGuiForm
{
private TContext _context;
private TForm _form;
private int? _formSerialId;
private bool _pendingRefresh;
private bool _isBindEvent;
protected TContext Context => _context;
protected TForm Form => _form;
protected int? FormSerialId => _formSerialId;
protected abstract UIFormType UIFormTypeId { get; }
protected abstract void RefreshUI(TForm form, TContext context);
protected virtual void SubscribeCustomEvents()
{
}
protected virtual void UnsubscribeCustomEvents()
{
}
protected virtual void CloseLoadedFormDirect(TForm form)
{
form.Close();
}
protected void SetContext(TContext context)
{
_context = context;
}
protected void RefreshCurrentUI()
{
if (_context == null)
{
return;
}
if (_form == null)
{
_pendingRefresh = true;
return;
}
RefreshUI(_form, _context);
_pendingRefresh = false;
}
protected override int? OpenUIInternal(TContext context)
{
if (context == null)
{
Log.Warning("{0}.OpenUI() context is null.", GetType().Name);
return null;
}
_context = context;
if (_form != null && _formSerialId.HasValue && GameEntry.UI.HasUIForm(_formSerialId.Value))
{
RefreshUI(_form, _context);
return _formSerialId;
}
CloseUI();
_pendingRefresh = true;
SubscribeEvents();
_formSerialId = GameEntry.UI.OpenUIForm(UIFormTypeId, _context);
return _formSerialId;
}
public override void CloseUI()
{
_pendingRefresh = false;
UnsubscribeEvents();
if (_formSerialId.HasValue)
{
if (GameEntry.UI.HasUIForm(_formSerialId.Value))
{
GameEntry.UI.CloseUIForm(_formSerialId.Value);
}
_form = null;
_formSerialId = null;
return;
}
if (_form != null)
{
CloseLoadedFormDirect(_form);
_form = null;
}
}
private void SubscribeEvents()
{
if (_isBindEvent)
{
return;
}
GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
GameEntry.Event.Subscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
SubscribeCustomEvents();
_isBindEvent = true;
}
private void UnsubscribeEvents()
{
if (!_isBindEvent)
{
return;
}
GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
GameEntry.Event.Unsubscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
UnsubscribeCustomEvents();
_isBindEvent = false;
}
private void OpenUIFormSuccess(object sender, GameEventArgs e)
{
if (!(e is OpenUIFormSuccessEventArgs args))
{
return;
}
if (!_formSerialId.HasValue)
{
return;
}
if (args.UIForm == null || args.UIForm.SerialId != _formSerialId.Value || args.UserData != _context)
{
return;
}
_form = args.UIForm.Logic as TForm;
if (_form == null)
{
Log.Warning("{0} open success but form logic is invalid.", GetType().Name);
return;
}
if (_pendingRefresh)
{
RefreshCurrentUI();
}
}
private void CloseUIFormComplete(object sender, GameEventArgs e)
{
if (!(e is CloseUIFormCompleteEventArgs args))
{
return;
}
if (args.SerialId != _formSerialId)
{
return;
}
_form = null;
_formSerialId = null;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1c5e27ba12c95604a858ba7c25f8b863
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,84 @@
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;
namespace GeometryTD.UI
{
public class CommonButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler,
IPointerUpHandler
{
private const float FadeTime = 0.3f;
private const float OnHoverAlpha = 0.7f;
private const float OnClickAlpha = 0.6f;
[FormerlySerializedAs("m_OnHover")] [SerializeField]
private UnityEvent _onHover = null;
[FormerlySerializedAs("m_OnClick")] [SerializeField]
private UnityEvent _onClick = null;
[SerializeField] private UnityEvent _onHoverEnd = null;
[SerializeField] private bool _allowFade = true;
private CanvasGroup _canvasGroup = null;
private void Awake()
{
_canvasGroup = gameObject.GetOrAddComponent<CanvasGroup>();
}
private void OnDisable()
{
_canvasGroup.alpha = 1f;
}
public void OnPointerEnter(PointerEventData eventData)
{
if (eventData.button != PointerEventData.InputButton.Left)
{
return;
}
StopAllCoroutines();
if (_allowFade)
StartCoroutine(_canvasGroup.FadeToAlpha(OnHoverAlpha, FadeTime));
_onHover.Invoke();
}
public void OnPointerExit(PointerEventData eventData)
{
if (eventData.button != PointerEventData.InputButton.Left)
{
return;
}
StopAllCoroutines();
if (_allowFade)
StartCoroutine(_canvasGroup.FadeToAlpha(1f, FadeTime));
_onHoverEnd?.Invoke();
}
public void OnPointerDown(PointerEventData eventData)
{
if (eventData.button != PointerEventData.InputButton.Left)
{
return;
}
_canvasGroup.alpha = OnClickAlpha;
_onClick.Invoke();
}
public void OnPointerUp(PointerEventData eventData)
{
if (eventData.button != PointerEventData.InputButton.Left)
{
return;
}
_canvasGroup.alpha = OnHoverAlpha;
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a5079836f95c2a44b96fa331487ebb70
timeCreated: 1528026160
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+116
View File
@@ -0,0 +1,116 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using GameFramework;
namespace GeometryTD.UI
{
/// <summary>
/// 对话框显示数据。
/// </summary>
public class DialogParams
{
/// <summary>
/// 模式,即按钮数量。取值 1、2、3。
/// </summary>
public int Mode
{
get;
set;
}
/// <summary>
/// 标题。
/// </summary>
public string Title
{
get;
set;
}
/// <summary>
/// 消息内容。
/// </summary>
public string Message
{
get;
set;
}
/// <summary>
/// 弹出窗口时是否暂停游戏。
/// </summary>
public bool PauseGame
{
get;
set;
}
/// <summary>
/// 确认按钮文本。
/// </summary>
public string ConfirmText
{
get;
set;
}
/// <summary>
/// 确定按钮回调。
/// </summary>
public GameFrameworkAction<object> OnClickConfirm
{
get;
set;
}
/// <summary>
/// 取消按钮文本。
/// </summary>
public string CancelText
{
get;
set;
}
/// <summary>
/// 取消按钮回调。
/// </summary>
public GameFrameworkAction<object> OnClickCancel
{
get;
set;
}
/// <summary>
/// 中立按钮文本。
/// </summary>
public string OtherText
{
get;
set;
}
/// <summary>
/// 其它按钮回调。
/// </summary>
public GameFrameworkAction<object> OnClickOther
{
get;
set;
}
/// <summary>
/// 用户自定义数据。
/// </summary>
public string UserData
{
get;
set;
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ad9ca3c36c52b0a4e8b25c8b451966da
timeCreated: 1528026160
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2d5e5f0def1180c4aab6e075a792c0bc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 60bbfce2106cf39439cef458aa73cde7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f66fbb87b709be9458c13b74880b6c3c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,19 @@
using GameFramework;
namespace GeometryTD.UI
{
public class DialogFormContext : UIContext
{
public int Mode;
public string Title;
public string Message;
public bool PauseGame;
public string ConfirmText;
public GameFrameworkAction<object> OnClickConfirm;
public string CancelText;
public GameFrameworkAction<object> OnClickCancel;
public string OtherText;
public GameFrameworkAction<object> OnClickOther;
public object UserData;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 58dfba8154611024da5258b2139494ca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c57df472a972f8341bf6e436aee2efc5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,78 @@
using GeometryTD.Definition;
using UnityGameFramework.Runtime;
namespace GeometryTD.UI
{
public class DialogFormController : UIFormControllerCommonBase<DialogFormContext, DialogForm>
{
protected override UIFormType UIFormTypeId => UIFormType.DialogForm;
protected override void RefreshUI(DialogForm form, DialogFormContext context)
{
form.RefreshUI(context);
}
protected override void CloseLoadedFormDirect(DialogForm form)
{
GameEntry.UI.CloseUIForm(form);
}
private static DialogFormContext BuildContext(DialogFormRawData rawData)
{
if (rawData == null)
{
return null;
}
return new DialogFormContext
{
Mode = rawData.Mode,
Title = rawData.Title,
Message = rawData.Message,
PauseGame = rawData.PauseGame,
ConfirmText = rawData.ConfirmText,
OnClickConfirm = rawData.OnClickConfirm,
CancelText = rawData.CancelText,
OnClickCancel = rawData.OnClickCancel,
OtherText = rawData.OtherText,
OnClickOther = rawData.OnClickOther,
UserData = rawData.UserData
};
}
public int? OpenUI(DialogFormRawData rawData)
{
DialogFormContext context = BuildContext(rawData);
return OpenUIInternal(context);
}
public override int? OpenUI(object userData = null)
{
if (userData is DialogFormContext context)
{
return OpenUIInternal(context);
}
if (userData is DialogFormRawData rawData)
{
return OpenUI(rawData);
}
if (userData != null)
{
Log.Warning("DialogFormController.OpenUI() userData type is invalid.");
return null;
}
return OpenUIInternal(Context);
}
public override void BindUseCase(IUIUseCase useCase)
{
if (useCase != null)
{
Log.Warning("DialogFormController does not use a use case.");
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3cb6fbdc246509042940f9d6f07e8cc2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 46e1661fcd0436f459fc6a3b5fa1151d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,109 @@
using GameFramework;
namespace GeometryTD.UI
{
/// <summary>
/// 对话框显示数据。
/// </summary>
public class DialogFormRawData
{
/// <summary>
/// 模式,即按钮数量。取值 1、2、3。
/// </summary>
public int Mode
{
get;
set;
}
/// <summary>
/// 标题。
/// </summary>
public string Title
{
get;
set;
}
/// <summary>
/// 消息内容。
/// </summary>
public string Message
{
get;
set;
}
/// <summary>
/// 弹出窗口时是否暂停游戏。
/// </summary>
public bool PauseGame
{
get;
set;
}
/// <summary>
/// 确认按钮文本。
/// </summary>
public string ConfirmText
{
get;
set;
}
/// <summary>
/// 确定按钮回调。
/// </summary>
public GameFrameworkAction<object> OnClickConfirm
{
get;
set;
}
/// <summary>
/// 取消按钮文本。
/// </summary>
public string CancelText
{
get;
set;
}
/// <summary>
/// 取消按钮回调。
/// </summary>
public GameFrameworkAction<object> OnClickCancel
{
get;
set;
}
/// <summary>
/// 中立按钮文本。
/// </summary>
public string OtherText
{
get;
set;
}
/// <summary>
/// 其它按钮回调。
/// </summary>
public GameFrameworkAction<object> OnClickOther
{
get;
set;
}
/// <summary>
/// 用户自定义数据。
/// </summary>
public object UserData
{
get;
set;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d21c15f61779e1f499a331c553b3af27
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f4990e74343a7f140a3897ad9b099ec3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3e0fd5494bef9074285b80c91a851acd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,223 @@
using GameFramework;
using TMPro;
using UnityEngine;
using UnityGameFramework.Runtime;
namespace GeometryTD.UI
{
public class DialogForm : UGuiForm
{
[SerializeField] private TMP_Text _titleText = null;
[SerializeField] private TMP_Text _messageText = null;
[SerializeField] private GameObject[] _modeObjects = null;
[SerializeField] private TMP_Text[] _confirmTexts = null;
[SerializeField] private TMP_Text[] _cancelTexts = null;
[SerializeField] private TMP_Text[] _otherTexts = null;
private int _dialogMode = 1;
private bool _pauseGame = false;
private object _userData = null;
private GameFrameworkAction<object> _onClickConfirmGFAction = null;
private GameFrameworkAction<object> _onClickCancelGFAction = null;
private GameFrameworkAction<object> _onClickOtherGFAction = null;
private DialogFormContext _context = null;
public int DialogMode => _dialogMode;
public bool PauseGame => _pauseGame;
public object UserData => _userData;
public void OnConfirmButtonClick()
{
Close();
if (_onClickConfirmGFAction != null)
{
_onClickConfirmGFAction(_userData);
}
}
public void OnCancelButtonClick()
{
Close();
if (_onClickCancelGFAction != null)
{
_onClickCancelGFAction(_userData);
}
}
public void OnOtherButtonClick()
{
Close();
if (_onClickOtherGFAction != null)
{
_onClickOtherGFAction(_userData);
}
}
#if UNITY_2017_3_OR_NEWER
protected override void OnOpen(object userData)
#else
protected internal override void OnOpen(object userData)
#endif
{
base.OnOpen(userData);
if (userData is DialogFormContext context)
{
RefreshUI(context);
return;
}
if (userData is DialogFormRawData dialogParams)
{
RefreshUI(BuildContext(dialogParams));
return;
}
Log.Warning("DialogForm requires DialogFormContext or DialogParams as userData.");
}
#if UNITY_2017_3_OR_NEWER
protected override void OnClose(bool isShutdown, object userData)
#else
protected internal override void OnClose(bool isShutdown, object userData)
#endif
{
if (_pauseGame)
{
GameEntry.Base.ResumeGame();
}
_dialogMode = 1;
_titleText.text = string.Empty;
_messageText.text = string.Empty;
_pauseGame = false;
_userData = null;
_context = null;
RefreshConfirmText(string.Empty);
_onClickConfirmGFAction = null;
RefreshCancelText(string.Empty);
_onClickCancelGFAction = null;
RefreshOtherText(string.Empty);
_onClickOtherGFAction = null;
base.OnClose(isShutdown, userData);
}
public void RefreshUI(DialogFormContext context)
{
if (context == null)
{
Log.Warning("DialogForm context is invalid.");
return;
}
_context = context;
_dialogMode = context.Mode;
RefreshDialogMode();
_titleText.text = context.Title;
_messageText.text = context.Message;
_pauseGame = context.PauseGame;
RefreshPauseGame();
_userData = context.UserData;
RefreshConfirmText(context.ConfirmText);
_onClickConfirmGFAction = context.OnClickConfirm;
RefreshCancelText(context.CancelText);
_onClickCancelGFAction = context.OnClickCancel;
RefreshOtherText(context.OtherText);
_onClickOtherGFAction = context.OnClickOther;
}
private static DialogFormContext BuildContext(DialogFormRawData rawData)
{
if (rawData == null)
{
return null;
}
return new DialogFormContext
{
Mode = rawData.Mode,
Title = rawData.Title,
Message = rawData.Message,
PauseGame = rawData.PauseGame,
ConfirmText = rawData.ConfirmText,
OnClickConfirm = rawData.OnClickConfirm,
CancelText = rawData.CancelText,
OnClickCancel = rawData.OnClickCancel,
OtherText = rawData.OtherText,
OnClickOther = rawData.OnClickOther,
UserData = rawData.UserData
};
}
private void RefreshDialogMode()
{
for (int i = 1; i <= _modeObjects.Length; i++)
{
_modeObjects[i - 1].SetActive(i == _dialogMode);
}
}
private void RefreshPauseGame()
{
if (_pauseGame)
{
GameEntry.Base.PauseGame();
}
}
private void RefreshConfirmText(string confirmText)
{
if (string.IsNullOrEmpty(confirmText))
{
confirmText = GameEntry.Localization.GetString("Dialog.ConfirmButton");
}
for (int i = 0; i < _confirmTexts.Length; i++)
{
_confirmTexts[i].text = confirmText;
}
}
private void RefreshCancelText(string cancelText)
{
if (string.IsNullOrEmpty(cancelText))
{
cancelText = GameEntry.Localization.GetString("Dialog.CancelButton");
}
for (int i = 0; i < _cancelTexts.Length; i++)
{
_cancelTexts[i].text = cancelText;
}
}
private void RefreshOtherText(string otherText)
{
if (string.IsNullOrEmpty(otherText))
{
otherText = GameEntry.Localization.GetString("Dialog.OtherButton");
}
for (int i = 0; i < _otherTexts.Length; i++)
{
_otherTexts[i].text = otherText;
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: c04f3be6bab0c7748bc236f9023e47f9
timeCreated: 1528026160
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+122
View File
@@ -0,0 +1,122 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using System.Collections;
using GeometryTD.Entity;
using GeometryTD.UI;
using UnityEngine;
using UnityEngine.UI;
using UnityGameFramework.Runtime;
namespace GeometryTD.UI
{
public class HPBarItem : MonoBehaviour
{
private const float AnimationSeconds = 0.3f;
private const float KeepSeconds = 0.4f;
private const float FadeOutSeconds = 0.3f;
[SerializeField]
private Slider m_HPBar = null;
private Canvas m_ParentCanvas = null;
private RectTransform m_CachedTransform = null;
private CanvasGroup m_CachedCanvasGroup = null;
private EntityBase m_Owner = null;
private int m_OwnerId = 0;
public EntityBase Owner
{
get
{
return m_Owner;
}
}
public void Init(EntityBase owner, Canvas parentCanvas, float fromHPRatio, float toHPRatio)
{
if (owner == null)
{
Log.Error("Owner is invalid.");
return;
}
m_ParentCanvas = parentCanvas;
gameObject.SetActive(true);
StopAllCoroutines();
m_CachedCanvasGroup.alpha = 1f;
if (m_Owner != owner || m_OwnerId != owner.Id)
{
m_HPBar.value = fromHPRatio;
m_Owner = owner;
m_OwnerId = owner.Id;
}
Refresh();
StartCoroutine(HPBarCo(toHPRatio, AnimationSeconds, KeepSeconds, FadeOutSeconds));
}
public bool Refresh()
{
if (m_CachedCanvasGroup.alpha <= 0f)
{
return false;
}
if (m_Owner != null && Owner.Available && Owner.Id == m_OwnerId)
{
Vector3 worldPosition = m_Owner.CachedTransform.position + Vector3.forward;
Vector3 screenPosition = GameEntry.Scene.MainCamera.WorldToScreenPoint(worldPosition);
Vector2 position;
if (RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)m_ParentCanvas.transform, screenPosition,
m_ParentCanvas.worldCamera, out position))
{
m_CachedTransform.localPosition = position;
}
}
return true;
}
public void Reset()
{
StopAllCoroutines();
m_CachedCanvasGroup.alpha = 1f;
m_HPBar.value = 1f;
m_Owner = null;
gameObject.SetActive(false);
}
private void Awake()
{
m_CachedTransform = GetComponent<RectTransform>();
if (m_CachedTransform == null)
{
Log.Error("RectTransform is invalid.");
return;
}
m_CachedCanvasGroup = GetComponent<CanvasGroup>();
if (m_CachedCanvasGroup == null)
{
Log.Error("CanvasGroup is invalid.");
return;
}
}
private IEnumerator HPBarCo(float value, float animationDuration, float keepDuration, float fadeOutDuration)
{
yield return m_HPBar.SmoothValue(value, animationDuration);
yield return new WaitForSeconds(keepDuration);
yield return m_CachedCanvasGroup.FadeToAlpha(0f, fadeOutDuration);
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9bcc0608685184647b097f4838a8e9f6
timeCreated: 1528026155
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e4dd0c79a354c2b4ab640b77f57919da
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6e06239c7dddb9448bf89661801f3bac
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d0e4237086d5a92409f7f6d4dd499098
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 32bf4a12bd0ac2847b19bbb76b7c3dd5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
// using Definition.Enum;
//
// namespace UI
// {
// public class DisplayItemContext : UIContext
// {
// public string IconAssetName;
// public ItemRarity Rarity;
// public bool IsWeapon;
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: df1bccc6ff70fbc4089c7809e35c1f61
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
// using Definition.Enum;
// using UnityEngine;
//
// namespace UI
// {
// public class DisplayItemInfoFormContext : UIContext
// {
// public int Index;
// public string IconAssetName;
// public string Title;
// public string TypeText;
// public ItemRarity Rarity;
// public string Description;
// public int Price;
// public bool IsWeapon;
// public Vector3 TargetPos;
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cdcef9502b7fa944ca95cb839fdc60bc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
// using System.Collections;
// using System.Collections.Generic;
// using UnityEngine;
//
// namespace UI
// {
// public class DisplayListAreaContext : UIContext
// {
// public string Title;
// public int CurrentCount;
// public int MaxCount = -1;
// public DisplayItemContext[] ItemContexts;
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a10dfda6cc0f45247bfcdbfb578110bc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,15 @@
// using Definition.Enum;
// using UnityEngine;
//
// namespace UI
// {
// public class GoodsItemContext : UIContext
// {
// public string Title;
// public ItemRarity Rarity;
// public string Type;
// public Sprite Icon;
// public string Description;
// public int Price;
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c9d0b321b02be5f41a27cc0a8bf84e34
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,10 @@
// using System.Collections;
// using System.Collections.Generic;
// using UnityEngine;
//
// namespace UI
// {
// public class HudFormContext : UIContext
// {
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3f8d476720436b84483bd1c29da4d558
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,10 @@
// using System.Collections.Generic;
//
// namespace UI
// {
// public class LevelUpFormContext : UIContext
// {
// public List<LevelUpRewardItemContext> Props;
// public int RefreshPrice;
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1874c6c7ef990c04ba726a2581cd23ce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
// using Definition.Enum;
// using UnityEngine;
//
// namespace UI
// {
// public class LevelUpRewardItemContext : UIContext
// {
// public string Title;
// public Sprite Icon;
// public ItemRarity ItemRarity;
// public string Description;
// public string IconAssetName;
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 424ceeba7cae4fa4faaeef9035f31e31
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,15 @@
// using System.Collections.Generic;
//
// namespace UI
// {
// public class ShopFormContext : UIContext
// {
// public int CurrentLevel;
// public int RefreshPrice;
// public int PlayerCoin;
// public List<GoodsItemContext> GoodsItems;
// public DisplayListAreaContext PropListContext;
// public DisplayListAreaContext WeaponListContext;
// public float WeaponRecycleRate = 0.3f;
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b0ef5183d2f87a54793b86d848e6524a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7d69a94fcc50f4c4ca1dc45e4338560e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,116 @@
// using CustomEvent;
// using Definition.Enum;
// using GameFramework.Event;
// using UnityGameFramework.Runtime;
//
// namespace UI
// {
// public class DisplayItemInfoFormController : UIFormControllerCommonBase<
// DisplayItemInfoFormContext, DisplayItemInfoForm>
// {
// protected override UIFormType UIFormTypeId => UIFormType.DisplayItemInfoForm;
//
// private bool _locked = false;
//
// protected override void SubscribeCustomEvents()
// {
// GameEntry.Event.Subscribe(DisplayItemInfoLockEventArgs.EventId, DisplayItemInfoLock);
// GameEntry.Event.Subscribe(DisplayItemInfoHideEventArgs.EventId, DisplayItemInfoHide);
// }
//
// protected override void UnsubscribeCustomEvents()
// {
// GameEntry.Event.Unsubscribe(DisplayItemInfoLockEventArgs.EventId, DisplayItemInfoLock);
// GameEntry.Event.Unsubscribe(DisplayItemInfoHideEventArgs.EventId, DisplayItemInfoHide);
// }
//
// protected override void RefreshUI(DisplayItemInfoForm form, DisplayItemInfoFormContext context)
// {
// form.RefreshUI(context);
// }
//
// protected override void CloseLoadedFormDirect(DisplayItemInfoForm form)
// {
// GameEntry.UI.CloseUIForm(form);
// }
//
// private static DisplayItemInfoFormContext BuildContext(DisplayItemInfoFormRawData rawData)
// {
// if (rawData == null)
// {
// return null;
// }
//
// return new DisplayItemInfoFormContext
// {
// Index = rawData.Index,
// IconAssetName = rawData.IconAssetName,
// Title = rawData.Title,
// Rarity = rawData.Rarity,
// TypeText = rawData.TypeText,
// Description = rawData.Description,
// Price = rawData.Price,
// IsWeapon = rawData.IsWeapon,
// TargetPos = rawData.TargetPos
// };
// }
//
// public int? OpenUI(DisplayItemInfoFormRawData rawData)
// {
// _locked = false;
// DisplayItemInfoFormContext context = BuildContext(rawData);
// return OpenUIInternal(context);
// }
//
// public override int? OpenUI(object userData = null)
// {
// _locked = false;
// if (userData is DisplayItemInfoFormContext context)
// {
// return OpenUIInternal(context);
// }
//
// if (userData is DisplayItemInfoFormRawData rawData)
// {
// return OpenUI(rawData);
// }
//
// if (userData != null)
// {
// Log.Warning("DisplayItemInfoFormController.OpenUI() userData type is invalid.");
// return null;
// }
//
// return OpenUIInternal(Context);
// }
//
// public override void BindUseCase(IUIUseCase useCase)
// {
// if (!(useCase is DisplayItemInfoFormUseCase))
// {
// Log.Error("DisplayItemInfoForm.BindUseCase() useCase is invalid.");
// }
// }
//
// #region Event Handlers
//
// private void DisplayItemInfoLock(object sender, GameEventArgs e)
// {
// if (!(e is DisplayItemInfoLockEventArgs)) return;
//
// _locked = true;
// }
//
// private void DisplayItemInfoHide(object sender, GameEventArgs e)
// {
// if (!(e is DisplayItemInfoHideEventArgs args)) return;
//
// if (!args.Force && _locked && sender is not DisplayItemInfoForm) return;
//
// GameEntry.UIRouter.CloseUI(UIFormType.DisplayItemInfoForm);
// _locked = false;
// }
//
// #endregion
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8a9b5acbc476ae44a8259a5aea1c0cf2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,46 @@
// using Definition.Enum;
// using UnityGameFramework.Runtime;
//
// namespace UI
// {
// public class HudFormController : UIFormControllerCommonBase<HudFormContext, HudForm>
// {
// protected override UIFormType UIFormTypeId => UIFormType.HudForm;
//
// protected override void RefreshUI(HudForm form, HudFormContext context)
// {
// form.RefreshUI(context);
// }
//
// private static HudFormContext BuildHudFormContext()
// {
// return new HudFormContext();
// }
//
// public override int? OpenUI(object userData = null)
// {
// if (userData is HudFormContext context)
// {
// return OpenUIInternal(context);
// }
//
// if (userData != null)
// {
// Log.Warning("HudFormController.OpenUI() userData type is invalid.");
// return null;
// }
//
// return OpenUIInternal(BuildHudFormContext());
// }
//
// public int? OpenUI(HudFormContext context)
// {
// return OpenUIInternal(context);
// }
//
// public override void BindUseCase(IUIUseCase useCase)
// {
// Log.Info("HudFormController doesn't need UseCase");
// }
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b7360b01093fa984d86105e2dd024dd5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,169 @@
// using System.Collections.Generic;
// using CustomEvent;
// using Definition.Enum;
// using CustomUtility;
// using GameFramework.Event;
// using UnityGameFramework.Runtime;
//
// namespace UI
// {
// public class LevelUpFormController : UIFormControllerCommonBase<LevelUpFormContext, LevelUpForm>
// {
// private LevelUpFormUseCase _useCase;
//
// protected override UIFormType UIFormTypeId => UIFormType.LevelUpForm;
//
// protected override void RefreshUI(LevelUpForm form, LevelUpFormContext context)
// {
// form.RefreshUI(context);
// }
//
// protected override void SubscribeCustomEvents()
// {
// GameEntry.Event.Subscribe(RefreshEventArgs.EventId, OnRefresh);
// GameEntry.Event.Subscribe(LevelUpPropSelectedEventArgs.EventId, OnLevelUpPropSelected);
// }
//
// protected override void UnsubscribeCustomEvents()
// {
// GameEntry.Event.Unsubscribe(RefreshEventArgs.EventId, OnRefresh);
// GameEntry.Event.Unsubscribe(LevelUpPropSelectedEventArgs.EventId, OnLevelUpPropSelected);
// }
//
// private static LevelUpFormContext BuildContext(LevelUpFormRawData rawData)
// {
// if (rawData == null || rawData.Rewards == null)
// {
// return null;
// }
//
// List<LevelUpRewardItemContext> props = new List<LevelUpRewardItemContext>(rawData.Rewards.Count);
// foreach (var reward in rawData.Rewards)
// {
// if (reward == null)
// {
// continue;
// }
//
// props.Add(new LevelUpRewardItemContext
// {
// Title = reward.Title,
// Icon = null,
// ItemRarity = reward.Rarity,
// Description = ItemDescUtility.CreatePropDescription(reward.Modifiers),
// IconAssetName = reward.IconAssetName
// });
// }
//
// return new LevelUpFormContext
// {
// RefreshPrice = rawData.RefreshPrice,
// Props = props
// };
// }
//
// public override int? OpenUI(object userData = null)
// {
// if (userData is LevelUpFormContext context)
// {
// return OpenUIInternal(context);
// }
//
// if (userData is LevelUpFormRawData rawDataFromUserData)
// {
// return OpenUI(rawDataFromUserData);
// }
//
// if (userData != null)
// {
// Log.Warning("LevelUpFormController.OpenUI() userData type is invalid.");
// return null;
// }
//
// if (_useCase == null)
// {
// Log.Error("LevelUpFormController.OpenUI() useCase is null.");
// return null;
// }
//
// LevelUpFormRawData rawData = _useCase.CreateInitialModel();
// return OpenUI(rawData);
// }
//
// public int? OpenUI(LevelUpFormRawData rawData)
// {
// LevelUpFormContext context = BuildContext(rawData);
// return OpenUIInternal(context);
// }
//
// public override void BindUseCase(IUIUseCase useCase)
// {
// if (!(useCase is LevelUpFormUseCase levelUpFormUseCase))
// {
// Log.Error("LevelUpForm.BindUseCase() useCase is invalid.");
// return;
// }
//
// _useCase = levelUpFormUseCase;
// }
//
// private void SelectReward(int selectedIndex)
// {
// if (_useCase == null)
// {
// Log.Error("LevelUpFormController.OpenUI() useCase is null.");
// return;
// }
//
// LevelUpFormRawData rawData = _useCase.SelectReward(selectedIndex);
// if (rawData == null)
// {
// return;
// }
//
// OpenUI(rawData);
// }
//
// private void RefreshRewardList(int refreshCost)
// {
// if (_useCase == null)
// {
// Log.Error("LevelUpFormController.OpenUI() useCase is null.");
// return;
// }
//
// LevelUpFormRawData rawData = _useCase.TryRefresh(refreshCost);
// if (rawData == null)
// {
// return;
// }
//
// OpenUI(rawData);
// }
//
// private void OnRefresh(object sender, GameEventArgs e)
// {
// if (!(sender is LevelUpForm))
// {
// return;
// }
//
// if (!(e is RefreshEventArgs args))
// {
// return;
// }
//
// RefreshRewardList(args.Cost);
// }
//
// private void OnLevelUpPropSelected(object sender, GameEventArgs e)
// {
// if (!(e is LevelUpPropSelectedEventArgs args))
// {
// return;
// }
//
// SelectReward(args.SelectedId);
// }
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 89d85bbc4f7cf8c438c7ee693eaf67cf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,411 @@
// using System.Collections.Generic;
// using CustomEvent;
// using Definition.DataStruct;
// using Definition.Enum;
// using Entity;
// using CustomUtility;
// using Entity.Weapon;
// using GameFramework.Event;
// using UnityEngine;
// using UnityGameFramework.Runtime;
//
// namespace UI
// {
// public class ShopFormController : UIFormControllerCommonBase<ShopFormContext, ShopForm>
// {
// private ShopFormUseCase _useCase;
// private ShopFormRawData _rawData;
//
// protected override UIFormType UIFormTypeId => UIFormType.ShopForm;
//
// protected override void RefreshUI(ShopForm form, ShopFormContext context)
// {
// form.RefreshUI(context);
// }
//
// protected override void SubscribeCustomEvents()
// {
// GameEntry.Event.Subscribe(RefreshEventArgs.EventId, Refresh);
// GameEntry.Event.Subscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
// GameEntry.Event.Subscribe(ShopWeaponRecycleEventArgs.EventId, WeaponRecycle);
// GameEntry.Event.Subscribe(ShopContinueEventArgs.EventId, ShopContinue);
// GameEntry.Event.Subscribe(DisplayItemShowEventArgs.EventId, DisplayItemShow);
// }
//
// protected override void UnsubscribeCustomEvents()
// {
// GameEntry.Event.Unsubscribe(RefreshEventArgs.EventId, Refresh);
// GameEntry.Event.Unsubscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
// GameEntry.Event.Unsubscribe(ShopWeaponRecycleEventArgs.EventId, WeaponRecycle);
// GameEntry.Event.Unsubscribe(ShopContinueEventArgs.EventId, ShopContinue);
// GameEntry.Event.Unsubscribe(DisplayItemShowEventArgs.EventId, DisplayItemShow);
// }
//
// #region BuildContext
//
// private ShopFormContext BuildContext(ShopFormRawData rawData)
// {
// if (rawData == null)
// {
// return null;
// }
//
// _rawData = rawData;
//
// return new ShopFormContext
// {
// CurrentLevel = rawData.CurrentLevel,
// RefreshPrice = rawData.RefreshPrice,
// PlayerCoin = rawData.PlayerCoin,
// GoodsItems = rawData.GoodsItems,
// PropListContext =
// BuildDisplayListAreaContext(DisplayListAreaType.Prop, rawData.PropItems, rawData.PropMaxCount),
// WeaponListContext = BuildDisplayListAreaContext(DisplayListAreaType.Weapon, rawData.WeaponItems,
// rawData.WeaponMaxCount)
// };
// }
//
// private static DisplayListAreaContext BuildDisplayListAreaContext(DisplayListAreaType listType,
// IReadOnlyList<object> items,
// int maxCount)
// {
// string title = GetDisplayListTitle(listType);
// if (items == null)
// {
// return new DisplayListAreaContext
// {
// Title = title,
// CurrentCount = 0,
// MaxCount = maxCount,
// ItemContexts = System.Array.Empty<DisplayItemContext>()
// };
// }
//
// DisplayItemContext[] itemContexts = new DisplayItemContext[items.Count];
// switch (listType)
// {
// case DisplayListAreaType.Weapon:
// if (items is IReadOnlyList<WeaponBase> weapons)
// {
// for (int i = 0; i < weapons.Count; i++)
// {
// WeaponBase weapon = weapons[i];
// if (weapon == null) break;
// itemContexts[i] = BuildWeaponItem(weapon);
// }
// }
//
// break;
//
// case DisplayListAreaType.Prop:
// if (items is IReadOnlyList<PropItem> propItems)
// {
// for (int i = 0; i < propItems.Count; i++)
// {
// PropItem propItem = propItems[i];
// if (propItem == null) break;
// itemContexts[i] = BuildPropItem(propItem);
// }
// }
//
// break;
// }
//
// int currentCount = itemContexts.Length;
// return new DisplayListAreaContext
// {
// Title = title,
// CurrentCount = currentCount,
// MaxCount = maxCount,
// ItemContexts = itemContexts
// };
// }
//
// private static string GetDisplayListTitle(DisplayListAreaType listType)
// {
// return listType switch
// {
// DisplayListAreaType.Weapon => "武器",
// DisplayListAreaType.Prop => "道具",
// _ => string.Empty
// };
// }
//
// private static DisplayItemContext BuildPropItem(PropItem propItem)
// {
// string iconAssetName = null;
// ItemRarity rarity = ItemRarity.None;
//
// if (propItem != null)
// {
// iconAssetName = propItem.IconAssetName;
// rarity = propItem.Rarity;
// }
//
// return new DisplayItemContext
// {
// IconAssetName = iconAssetName,
// Rarity = rarity,
// IsWeapon = false
// };
// }
//
// private static DisplayItemContext BuildWeaponItem(WeaponBase weaponBase)
// {
// string iconAssetName = null;
// ItemRarity rarity = ItemRarity.None;
//
// if (weaponBase != null && weaponBase.WeaponData != null)
// {
// iconAssetName = weaponBase.WeaponData.IconAssetName;
// rarity = weaponBase.WeaponData.Rarity;
// }
//
// return new DisplayItemContext
// {
// IconAssetName = iconAssetName,
// Rarity = rarity,
// IsWeapon = true
// };
// }
//
// private static void AppendDisplayItemContext(DisplayListAreaContext listContext, DisplayItemContext newItem)
// {
// if (listContext == null || newItem == null)
// {
// return;
// }
//
// int oldCount = listContext.ItemContexts != null ? listContext.ItemContexts.Length : 0;
// DisplayItemContext[] newContexts = new DisplayItemContext[oldCount + 1];
// if (oldCount > 0)
// {
// System.Array.Copy(listContext.ItemContexts, newContexts, oldCount);
// }
//
// newContexts[oldCount] = newItem;
// listContext.ItemContexts = newContexts;
// listContext.CurrentCount = oldCount + 1;
// }
//
// #endregion
//
// #region UI Methods
//
// public int? OpenUI(ShopFormRawData rawData)
// {
// ShopFormContext context = BuildContext(rawData);
// return OpenUIInternal(context);
// }
//
// public override int? OpenUI(object userData = null)
// {
// if (userData is ShopFormContext context)
// {
// return OpenUIInternal(context);
// }
//
// if (userData is ShopFormRawData rawDataFromUserData)
// {
// return OpenUI(rawDataFromUserData);
// }
//
// if (userData != null)
// {
// Log.Warning("ShopFormController.OpenUI() userData type is invalid.");
// return null;
// }
//
// if (_useCase == null)
// {
// Log.Error("ShopForm.OpenUI():: useCase is null.");
// return null;
// }
//
// ShopFormRawData rawData = _useCase.CreateInitialModel();
// return OpenUI(rawData);
// }
//
// public override void BindUseCase(IUIUseCase useCase)
// {
// if (!(useCase is ShopFormUseCase shopFormUseCase))
// {
// Log.Error("LevelUpForm.BindUseCase() useCase is invalid.");
// return;
// }
//
// _useCase = shopFormUseCase;
// }
//
// #endregion
//
// #region Service
//
// private void RefreshGoodsItems(ShopRefreshResult result)
// {
// if (Context == null || result == null)
// {
// return;
// }
//
// Context.GoodsItems = result.GoodsItems;
// Context.RefreshPrice = result.RefreshPrice;
//
// if (Form == null)
// {
// return;
// }
//
// Form.RefreshGoodsItems(result.GoodsItems);
// Form.RefreshRefreshPrice(result.RefreshPrice);
// }
//
// private void ApplyGoodsPurchased(ShopPurchaseResult result)
// {
// if (Context == null || result == null)
// {
// return;
// }
//
// if (Context.GoodsItems != null && result.GoodsIndex >= 0 && result.GoodsIndex < Context.GoodsItems.Count)
// {
// Context.GoodsItems[result.GoodsIndex] = null;
// }
//
// if (result.DisplayItem != null)
// {
// if (result.DisplayItem.IsWeapon)
// {
// AppendDisplayItemContext(Context.WeaponListContext, result.DisplayItem);
// }
// else
// {
// AppendDisplayItemContext(Context.PropListContext, result.DisplayItem);
// }
// }
//
// Form?.ApplyGoodsPurchased(result.GoodsIndex, result.DisplayItem);
// }
//
// #endregion
//
// #region Event Handlers
//
// private void Refresh(object sender, GameEventArgs e)
// {
// if (!(sender is ShopForm))
// {
// return;
// }
//
// if (!(e is RefreshEventArgs args))
// {
// return;
// }
//
// ShopRefreshResult result = _useCase.TryRefresh(args.Cost);
// if (result == null)
// {
// return;
// }
//
// RefreshGoodsItems(result);
// }
//
// private void ShopPurchase(object sender, GameEventArgs e)
// {
// if (!(sender is ShopForm))
// {
// return;
// }
//
// if (!(e is ShopPurchaseEventArgs args))
// {
// return;
// }
//
// ShopPurchaseResult result = _useCase.TryPurchase(args.GoodsIndex);
// if (result == null)
// {
// return;
// }
//
// ApplyGoodsPurchased(result);
// }
//
// private void ShopContinue(object sender, GameEventArgs e)
// {
// if (!(sender is ShopForm))
// {
// return;
// }
//
// if (!(e is ShopContinueEventArgs))
// {
// return;
// }
//
// _useCase?.Continue();
// }
//
// private void DisplayItemShow(object sender, GameEventArgs e)
// {
// if (!(e is DisplayItemShowEventArgs args) || _rawData == null) return;
//
// DisplayItemInfoFormRawData rawData = new();
// rawData.TargetPos = args.TargetPos;
// rawData.Index = args.Index;
// if (args.IsWeapon)
// {
// var weaponData = _rawData.WeaponItems[args.Index].WeaponData;
// rawData.IconAssetName = weaponData.IconAssetName;
// rawData.Title = weaponData.Title;
// rawData.Rarity = weaponData.Rarity;
// rawData.TypeText = "武器";
// rawData.Description = ItemDescUtility.CreateWeaponDescription(weaponData);
// rawData.Price = Mathf.FloorToInt(weaponData.Price * Context.WeaponRecycleRate);
// rawData.IsWeapon = true;
// }
// else
// {
// var propItem = _rawData.PropItems[args.Index];
// rawData.IconAssetName = propItem.IconAssetName;
// rawData.Title = propItem.Title;
// rawData.Rarity = propItem.Rarity;
// rawData.TypeText = "道具";
// rawData.Description = ItemDescUtility.CreatePropDescription(propItem);
// rawData.Price = 0;
// rawData.IsWeapon = false;
// }
//
// GameEntry.UIRouter.OpenUI(UIFormType.DisplayItemInfoForm, rawData);
// }
//
// private void WeaponRecycle(object sender, GameEventArgs e)
// {
// if (!(e is ShopWeaponRecycleEventArgs args)) return;
//
// if (_useCase == null || Context == null)
// {
// return;
// }
//
// bool success = _useCase.TryRecycleWeapon(args.Index, args.Price);
// if (!success)
// {
// return;
// }
//
// if (Context.WeaponListContext != null)
// {
// int currentCount = Mathf.Max(0, Context.WeaponListContext.CurrentCount - 1);
// Context.WeaponListContext.CurrentCount = currentCount;
// }
//
// Form?.RemoveWeaponDisplayItem(args.Index);
// GameEntry.Event.Fire(this, DisplayItemInfoHideEventArgs.Create(true));
// }
//
// #endregion
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: be57ace1e7b07be429632ea49bcab6c5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ac5b4f32ba8b93e4f93b94bc402245bd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,20 @@
// using System.Collections;
// using System.Collections.Generic;
// using Definition.Enum;
// using UnityEngine;
//
// namespace UI
// {
// public class DisplayItemInfoFormRawData
// {
// public int Index;
// public string IconAssetName;
// public string Title;
// public string TypeText;
// public ItemRarity Rarity;
// public string Description;
// public int Price;
// public bool IsWeapon;
// public Vector3 TargetPos;
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 012ded06be40bcf48b3e79ce89df4e2b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
// using System.Collections.Generic;
// using DataTable;
//
// namespace UI
// {
// public class LevelUpFormRawData
// {
// public List<DRLevelUpReward> Rewards;
// public int RefreshPrice;
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a3ece8e2fb75f424cb4885d4344434d2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
// using System.Collections.Generic;
// using Definition.DataStruct;
// using Entity.Weapon;
//
// namespace UI
// {
// public class ShopFormRawData
// {
// public int CurrentLevel;
// public int RefreshPrice;
// public int PlayerCoin;
// public List<GoodsItemContext> GoodsItems;
// public IReadOnlyList<PropItem> PropItems;
// public int PropMaxCount = -1;
// public IReadOnlyList<WeaponBase> WeaponItems;
// public int WeaponMaxCount = -1;
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 533bff5f9d3bc7847af44dcd1cdffba3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 134aefa2f7839e641b5824d665cbb8ef
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,75 @@
// using Definition.DataStruct;
// using Entity;
// using CustomUtility;
// using Entity.Weapon;
// using Procedure;
//
// namespace UI
// {
// public class DisplayItemInfoFormUseCase : IUIUseCase
// {
// private readonly ProcedureGame _procedureGame;
//
// private Player Player => _procedureGame != null ? _procedureGame.Player : null;
//
// public DisplayItemInfoFormUseCase(ProcedureGame procedureGame)
// {
// _procedureGame = procedureGame;
// }
//
// public DisplayItemInfoFormRawData CreateModel(int index, bool isWeapon)
// {
// if (index < 0 || Player == null)
// {
// return null;
// }
//
// if (isWeapon)
// {
// var weapons = Player.Weapons;
// if (weapons == null || index >= weapons.Count)
// {
// return null;
// }
//
// WeaponBase weapon = weapons[index];
// if (weapon == null || weapon.WeaponData == null)
// {
// return null;
// }
//
// return new DisplayItemInfoFormRawData
// {
// IconAssetName = weapon.WeaponData.IconAssetName,
// Title = weapon.WeaponData.Title,
// TypeText = "Weapon",
// Description = ItemDescUtility.CreateWeaponDescription(weapon),
// Price = 0,
// IsWeapon = true
// };
// }
//
// var props = Player.Props;
// if (props == null || index >= props.Count)
// {
// return null;
// }
//
// PropItem prop = props[index];
// if (prop == null)
// {
// return null;
// }
//
// return new DisplayItemInfoFormRawData
// {
// IconAssetName = prop.IconAssetName,
// Title = prop.Title,
// TypeText = "Prop",
// Description = ItemDescUtility.CreatePropDescription(prop),
// Price = 0,
// IsWeapon = false
// };
// }
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 48c1f32fe95e20c43b8015ac1438d54e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,195 @@
// using System.Collections.Generic;
// using System.Linq;
// using DataTable;
// using Definition.DataStruct;
// using Definition.Enum;
// using Entity;
// using Procedure;
// using UnityEngine;
// using UnityGameFramework.Runtime;
// using CustomUtility;
// using GameFramework.DataTable;
//
// namespace UI
// {
// internal class LevelUpFormUseCase : IUIUseCase
// {
// private const int BaseRefreshPrice = 2;
// private readonly GameStateLevelUp _gameStateLevelUp;
// private readonly DRLevelUpReward[] _allRewards;
// private readonly IDataTable<DRLevelRarity> _levelRarityTable;
// private readonly Dictionary<ItemRarity, List<DRLevelUpReward>> _rewardsByRarity = new();
// private readonly List<DRLevelUpReward> _validRewards = new();
//
// private int _refreshCount;
// private LevelUpFormRawData _currentModel;
//
// private readonly Player _player;
//
// public LevelUpFormUseCase(Player player, GameStateLevelUp gameStateLevelUp)
// {
// _player = player;
// _gameStateLevelUp = gameStateLevelUp;
// _allRewards = GameEntry.DataTable.GetDataTable<DRLevelUpReward>().ToArray();
// _levelRarityTable = GameEntry.DataTable.GetDataTable<DRLevelRarity>();
//
// BuildRewardRarityPools();
// }
//
// public LevelUpFormRawData CreateInitialModel(int count = 4)
// {
// _refreshCount = 0;
//
// if (_gameStateLevelUp == null || _player.PendingLevelPoints <= 0)
// {
// _currentModel = null;
// return null;
// }
//
// _currentModel = BuildModel(BaseRefreshPrice, count);
// return _currentModel;
// }
//
// public LevelUpFormRawData TryRefresh(int refreshCost, int count = 4)
// {
// if (_currentModel == null)
// {
// return null;
// }
//
// if (_player == null || _player.Coin < refreshCost)
// {
// return null;
// }
//
// _player.Coin -= refreshCost;
//
// _refreshCount++;
// _currentModel = BuildModel((_refreshCount + 1) * BaseRefreshPrice, count);
// return _currentModel;
// }
//
// public LevelUpFormRawData SelectReward(int selectedIndex, int count = 4)
// {
// if (_currentModel?.Rewards == null)
// {
// return null;
// }
//
// if (selectedIndex < 0 || selectedIndex >= _currentModel.Rewards.Count)
// {
// Log.Warning("LevelUpFormUseCase::SelectReward: Invalid index");
// return null;
// }
//
// ApplyReward(_currentModel.Rewards[selectedIndex]);
//
// if (--_player.PendingLevelPoints > 0)
// {
// _refreshCount = 0;
// _currentModel = BuildModel(BaseRefreshPrice, count);
// return _currentModel;
// }
//
// _gameStateLevelUp.IsCompleted = true;
// _currentModel = null;
// return null;
// }
//
// private LevelUpFormRawData BuildModel(int refreshPrice, int count)
// {
// if (_allRewards == null || _allRewards.Length == 0)
// {
// Log.Error("LevelUpFormUseCase::BuildModel(): _allRewards is empty");
// return null;
// }
//
// int finalCount = count > 0 ? System.Math.Min(count, _allRewards.Length) : _allRewards.Length;
// List<DRLevelUpReward> selections = new List<DRLevelUpReward>(finalCount);
//
// int currentLevel = _player != null ? _player.CurrentLevel : 1;
// for (int i = 0; i < finalCount; i++)
// {
// ItemRarity rarity = RarityUtility.SelectRarityForLevel(_levelRarityTable, currentLevel);
// DRLevelUpReward reward = PickRewardByRarity(rarity);
// if (reward == null)
// {
// Log.Warning("LevelUpFormUseCase::BuildModel(): No available reward for selection.");
// break;
// }
//
// selections.Add(reward);
// }
//
// return new LevelUpFormRawData
// {
// Rewards = selections,
// RefreshPrice = refreshPrice
// };
// }
//
// private void ApplyReward(DRLevelUpReward reward)
// {
// if (reward == null)
// {
// return;
// }
//
// if (_player == null)
// {
// Log.Warning("LevelUpFormUseCase::ApplyReward: Player is null");
// return;
// }
//
// if (reward.Modifiers == null || reward.Modifiers.Length == 0)
// {
// Log.Warning("LevelUpFormUseCase::ApplyReward: Reward modifiers are empty");
// return;
// }
//
// _player.AddProp(new PropItem(reward.Modifiers, reward.Rarity, reward.Title, reward.IconAssetName));
// }
//
// private void BuildRewardRarityPools()
// {
// _rewardsByRarity.Clear();
// _validRewards.Clear();
//
// if (_allRewards == null) return;
//
// foreach (DRLevelUpReward reward in _allRewards)
// {
// if (reward == null)
// {
// continue;
// }
//
// ItemRarity rarity = reward.Rarity;
// _validRewards.Add(reward);
//
// if (!_rewardsByRarity.TryGetValue(rarity, out List<DRLevelUpReward> list))
// {
// list = new List<DRLevelUpReward>();
// _rewardsByRarity.Add(rarity, list);
// }
//
// list.Add(reward);
// }
// }
//
// private DRLevelUpReward PickRewardByRarity(ItemRarity rarity)
// {
// if (_rewardsByRarity.TryGetValue(rarity, out List<DRLevelUpReward> list) && list.Count > 0)
// {
// return list[Random.Range(0, list.Count)];
// }
//
// if (_validRewards.Count > 0)
// {
// return _validRewards[Random.Range(0, _validRewards.Count)];
// }
//
// return null;
// }
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 19d2fa806b03510498d072c5b8710bcb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,444 @@
// using System.Collections.Generic;
// using System.Linq;
// using DataTable;
// using Definition.DataStruct;
// using Definition.Enum;
// using Entity;
// using Entity.EntityData;
// using CustomUtility;
// using GameFramework.DataTable;
// using Procedure;
// using UnityEngine;
// using UnityGameFramework.Runtime;
// using Random = UnityEngine.Random;
//
// namespace UI
// {
// internal sealed class ShopRefreshResult
// {
// public List<GoodsItemContext> GoodsItems;
// public int RefreshPrice;
// }
//
// internal sealed class ShopPurchaseResult
// {
// public int GoodsIndex;
// public DisplayItemContext DisplayItem;
// }
//
// internal class ShopFormUseCase : IUIUseCase
// {
// private readonly ProcedureGame _procedureGame;
// private readonly GameStateShop _gameStateShop;
//
// private readonly DRGoods[] _allGoods;
// private readonly IDataTable<DRProp> _propDataTable;
// private readonly IDataTable<DRWeapon> _weaponDataTable;
// private readonly IDataTable<DRLevelRarity> _levelRarityTable;
//
// private readonly List<DRGoods> _validGoods = new();
// private readonly Dictionary<ItemRarity, List<DRGoods>> _goodsByRarity = new();
//
// private readonly List<ShopGoodsSelection> _selections = new();
// private int _refreshTime;
//
// private Player Player => _procedureGame.Player;
//
// private sealed class ShopGoodsSelection
// {
// public GoodsType GoodsType;
// public int GoodsTypeId;
// public int Price;
// }
//
// public ShopFormUseCase(ProcedureGame procedureGame, GameStateShop gameStateShop)
// {
// _procedureGame = procedureGame;
// _gameStateShop = gameStateShop;
// _allGoods = GameEntry.DataTable.GetDataTable<DRGoods>().ToArray();
// _propDataTable = GameEntry.DataTable.GetDataTable<DRProp>();
// _weaponDataTable = GameEntry.DataTable.GetDataTable<DRWeapon>();
// _levelRarityTable = GameEntry.DataTable.GetDataTable<DRLevelRarity>();
//
// BuildGoodsRarityPools();
// }
//
// public ShopFormRawData CreateInitialModel()
// {
// _refreshTime = 0;
//
// Player player = Player;
// if (_procedureGame == null || player == null)
// {
// return null;
// }
//
// int currentLevel = _procedureGame.CurrentLevel;
// return new ShopFormRawData
// {
// CurrentLevel = currentLevel,
// RefreshPrice = currentLevel,
// PlayerCoin = player.Coin,
// GoodsItems = BuildRandomGoodsItems(4),
// PropItems = player.Props,
// PropMaxCount = -1,
// WeaponItems = player.Weapons,
// WeaponMaxCount = player.WeaponCapacity
// };
// }
//
// public ShopRefreshResult TryRefresh(int cost)
// {
// Player player = Player;
// if (player == null || _procedureGame == null || player.Coin < cost)
// {
// return null;
// }
//
// player.Coin -= cost;
//
// int refreshPrice = (_refreshTime + 1) * _procedureGame.CurrentLevel;
// _refreshTime++;
//
// return new ShopRefreshResult
// {
// GoodsItems = BuildRandomGoodsItems(4),
// RefreshPrice = refreshPrice
// };
// }
//
// public ShopPurchaseResult TryPurchase(int goodsIndex)
// {
// if (goodsIndex < 0 || goodsIndex >= _selections.Count)
// {
// Log.Warning("ShopFormUseCase::TryPurchase: Invalid index");
// return null;
// }
//
// ShopGoodsSelection selection = _selections[goodsIndex];
// if (selection == null)
// {
// Log.Warning("ShopFormUseCase::TryPurchase: Item already purchased.");
// return null;
// }
//
// Player player = Player;
// if (player == null || player.Coin < selection.Price)
// {
// return null;
// }
//
// DisplayItemContext displayItem = ApplyGoodsPurchase(selection);
// if (displayItem == null)
// {
// return null;
// }
//
// player.Coin -= selection.Price;
// _selections[goodsIndex] = null;
//
// return new ShopPurchaseResult
// {
// GoodsIndex = goodsIndex,
// DisplayItem = displayItem
// };
// }
//
// public void Continue()
// {
// _gameStateShop.ShopFinish = true;
// }
//
// private List<GoodsItemContext> BuildRandomGoodsItems(int count)
// {
// if (_allGoods == null || _allGoods.Length == 0)
// {
// Log.Error("ShopFormUseCase::BuildRandomGoodsItems(): _allGoods is empty");
// return null;
// }
//
// int finalCount = Mathf.Min(count, _allGoods.Length);
// List<GoodsItemContext> goodsItems = new List<GoodsItemContext>(finalCount);
// _selections.Clear();
//
// int currentLevel = _procedureGame != null ? _procedureGame.CurrentLevel : 1;
//
// for (int i = 0; i < finalCount; i++)
// {
// ItemRarity rarity = RarityUtility.SelectRarityForLevel(_levelRarityTable, currentLevel);
// DRGoods drGoods = PickGoodsByRarity(rarity);
// if (drGoods == null)
// {
// Log.Warning("ShopFormUseCase::BuildRandomGoodsItems: No available goods for selection.");
// break;
// }
//
// GoodsItemContext goodsItem = new GoodsItemContext();
// int price;
//
// if (drGoods.GoodsType == GoodsType.Prop)
// {
// DRProp drProp = _propDataTable.GetDataRow(drGoods.GoodsTypeId);
// if (drProp == null)
// {
// Log.Warning($"ShopFormUseCase::BuildRandomGoodsItems: Missing DRProp, id = {drGoods.GoodsTypeId}");
// continue;
// }
//
// price = CalculateRandomizedPrice(drProp.Price, drProp.PriceRandomPercent);
// goodsItem.Title = drProp.Title;
// goodsItem.Type = "Prop";
// goodsItem.Rarity = drProp.Rarity;
// GameEntry.SpriteCache.GetSprite(drProp.IconAssetName, sprite => goodsItem.Icon = sprite);
// goodsItem.Description = ItemDescUtility.CreatePropDescription(drProp.Modifiers);
// }
// else if (drGoods.GoodsType == GoodsType.Weapon)
// {
// DRWeapon drWeapon = _weaponDataTable.GetDataRow(drGoods.GoodsTypeId);
// if (drWeapon == null)
// {
// Log.Warning($"ShopFormUseCase::BuildRandomGoodsItems: Missing DRWeapon, id = {drGoods.GoodsTypeId}");
// continue;
// }
//
// price = CalculateRandomizedPrice(drWeapon.Price, drWeapon.PriceRandomPercent);
// goodsItem.Title = drWeapon.Title;
// goodsItem.Type = "Weapon";
// goodsItem.Rarity = drWeapon.Rarity;
// GameEntry.SpriteCache.GetSprite(drWeapon.IconAssetName, sprite => goodsItem.Icon = sprite);
// goodsItem.Description = ItemDescUtility.CreateWeaponDescription(drWeapon);
// }
// else
// {
// Log.Warning($"ShopFormUseCase::BuildRandomGoodsItems: Unsupported goods type = {drGoods.GoodsType}");
// continue;
// }
//
// goodsItem.Price = price;
//
// _selections.Add(new ShopGoodsSelection
// {
// GoodsType = drGoods.GoodsType,
// GoodsTypeId = drGoods.GoodsTypeId,
// Price = price
// });
//
// goodsItems.Add(goodsItem);
// }
//
// return goodsItems;
// }
//
// private void BuildGoodsRarityPools()
// {
// _goodsByRarity.Clear();
// _validGoods.Clear();
//
// if (_allGoods == null) return;
//
// foreach (DRGoods goods in _allGoods)
// {
// if (goods == null) continue;
//
// if (!TryGetGoodsRarity(goods, out ItemRarity rarity))
// {
// continue;
// }
//
// _validGoods.Add(goods);
//
// if (!_goodsByRarity.TryGetValue(rarity, out List<DRGoods> list))
// {
// list = new List<DRGoods>();
// _goodsByRarity.Add(rarity, list);
// }
//
// list.Add(goods);
// }
// }
//
// private DRGoods PickGoodsByRarity(ItemRarity rarity)
// {
// if (_goodsByRarity.TryGetValue(rarity, out List<DRGoods> list) && list.Count > 0)
// {
// return list[Random.Range(0, list.Count)];
// }
//
// if (_validGoods.Count > 0)
// {
// return _validGoods[Random.Range(0, _validGoods.Count)];
// }
//
// return null;
// }
//
// private bool TryGetGoodsRarity(DRGoods goods, out ItemRarity rarity)
// {
// rarity = ItemRarity.None;
// if (goods == null)
// {
// return false;
// }
//
// if (goods.GoodsType == GoodsType.Prop)
// {
// DRProp drProp = _propDataTable != null ? _propDataTable.GetDataRow(goods.GoodsTypeId) : null;
// if (drProp == null)
// {
// Log.Warning($"ShopFormUseCase::TryGetGoodsRarity: Missing DRProp, id = {goods.GoodsTypeId}");
// return false;
// }
//
// rarity = drProp.Rarity;
// return true;
// }
//
// if (goods.GoodsType == GoodsType.Weapon)
// {
// DRWeapon drWeapon = _weaponDataTable != null ? _weaponDataTable.GetDataRow(goods.GoodsTypeId) : null;
// if (drWeapon == null)
// {
// Log.Warning($"ShopFormUseCase::TryGetGoodsRarity: Missing DRWeapon, id = {goods.GoodsTypeId}");
// return false;
// }
//
// rarity = drWeapon.Rarity;
// return true;
// }
//
// Log.Warning($"ShopFormUseCase::TryGetGoodsRarity: Unsupported goods type = {goods.GoodsType}");
// return false;
// }
//
// private static int CalculateRandomizedPrice(int basePrice, float priceRandomPercent)
// {
// float normalizedPercent = priceRandomPercent > 1f ? priceRandomPercent / 100f : priceRandomPercent;
// normalizedPercent = Mathf.Max(0f, normalizedPercent);
// float offsetPercent = Random.Range(-normalizedPercent, normalizedPercent);
// int finalPrice = Mathf.RoundToInt(basePrice * (1f + offsetPercent));
// return Mathf.Max(1, finalPrice);
// }
//
// private DisplayItemContext ApplyGoodsPurchase(ShopGoodsSelection goods)
// {
// if (goods == null || Player == null)
// {
// return null;
// }
//
// if (goods.GoodsType == GoodsType.Prop)
// {
// DRProp drProp = _propDataTable != null ? _propDataTable.GetDataRow(goods.GoodsTypeId) : null;
// if (drProp == null || drProp.Modifiers == null || drProp.Modifiers.Length == 0)
// {
// Log.Warning("ShopFormUseCase::ApplyGoodsPurchase: Prop modifiers are empty");
// return null;
// }
//
// Player.AddProp(new PropItem(drProp.Modifiers, drProp.Rarity, drProp.Title, drProp.IconAssetName));
// return new DisplayItemContext
// {
// IconAssetName = drProp.IconAssetName,
// Rarity = drProp.Rarity,
// IsWeapon = false
// };
// }
//
// if (goods.GoodsType == GoodsType.Weapon)
// {
// if (Player.Weapons != null && Player.Weapons.Count >= Player.WeaponCapacity)
// {
// Log.Warning("ShopFormUseCase::ApplyGoodsPurchase: Weapon capacity is full.");
// return null;
// }
//
// DRWeapon drWeapon = _weaponDataTable != null ? _weaponDataTable.GetDataRow(goods.GoodsTypeId) : null;
// if (drWeapon == null)
// {
// Log.Warning($"ShopFormUseCase::ApplyGoodsPurchase: Missing DRWeapon, id = {goods.GoodsTypeId}");
// return null;
// }
//
// var weaponData = CreateWeaponData(goods.GoodsTypeId);
// if (weaponData == null)
// {
// Log.Warning(
// $"ShopFormUseCase::ApplyGoodsPurchase: Unsupported weapon type id = {goods.GoodsTypeId}");
// return null;
// }
//
// GameEntry.Entity.ShowWeapon(weaponData);
//
// return new DisplayItemContext
// {
// IconAssetName = drWeapon.IconAssetName,
// Rarity = drWeapon.Rarity,
// IsWeapon = true
// };
// }
//
// return null;
// }
//
// private WeaponData CreateWeaponData(int weaponTypeId)
// {
// int entityId = GameEntry.Entity.GenerateSerialId();
// int ownerId = Player.Id;
// CampType ownerCamp = CampType.Player;
//
// WeaponType weaponType = (WeaponType)weaponTypeId;
// switch (weaponType)
// {
// case WeaponType.WeaponKnife:
// return new WeaponKnifeData(entityId, ownerId, ownerCamp);
// case WeaponType.WeaponHandgun:
// return new WeaponHandgunData(entityId, ownerId, ownerCamp);
// case WeaponType.WeaponSlash:
// return new WeaponSlashData(entityId, ownerId, ownerCamp);
// case WeaponType.WeaponLightning:
// return new WeaponLightningData(entityId, ownerId, ownerCamp);
// default:
// return null;
// }
// }
//
// public bool TryRecycleWeapon(int argsIndex, int argsPrice)
// {
// Player player = Player;
// if (player == null)
// {
// return false;
// }
//
// var weapons = player.Weapons;
// if (weapons == null || weapons.Count <= 1)
// {
// Log.Warning("ShopFormUseCase::TryRecycleWeapon: Can not recycle the last weapon.");
// return false;
// }
//
// if (argsIndex < 0 || argsIndex >= weapons.Count)
// {
// Log.Warning($"ShopFormUseCase::TryRecycleWeapon: Invalid weapon index = {argsIndex}");
// return false;
// }
//
// var weapon = weapons[argsIndex];
// if (weapon == null)
// {
// Log.Warning("ShopFormUseCase::TryRecycleWeapon: Weapon is null.");
// return false;
// }
//
// int recyclePrice = Mathf.Max(0, argsPrice);
// if (!player.RemoveWeapon(weapon))
// {
// Log.Warning("ShopFormUseCase::TryRecycleWeapon: Remove weapon failed.");
// return false;
// }
//
// player.Coin += recyclePrice;
// return true;
// }
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e973748d1bd846349d42e219a80f07c2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7af0b9398035e254cb6de37a6c301552
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,71 @@
// using CustomEvent;
// using UnityEngine;
// using UnityEngine.UI;
//
// namespace UI
// {
// public class DisplayItem : MonoBehaviour
// {
// [SerializeField] private IconArea _iconArea;
//
// [SerializeField] private RectTransform _itemRect;
//
// private DisplayItemContext _context;
//
// private int _index = -1;
//
// public void SetIndex(int index)
// {
// _index = index;
// }
//
// public void OnInit(DisplayItemContext context, int index)
// {
// if (context == null) return;
//
// _context = context;
// _index = index;
//
// if (_iconArea != null)
// {
// string iconName = _context.IconAssetName;
// GameEntry.SpriteCache.GetSprite(iconName, sprite => { _iconArea.OnInit(sprite, context.Rarity); });
// }
// }
//
// public void OnReset()
// {
// _context = null;
// _index = -1;
//
// if (_iconArea != null)
// {
// _iconArea.OnReset();
// }
// }
//
// public void OnItemInfoShow()
// {
// if (_index < 0) return;
// if (_itemRect == null) return;
//
// Rect rect = _itemRect.rect;
// Vector3 targetPos = _itemRect.TransformPoint(new Vector3(
// (rect.xMin + rect.xMax) / 2,
// rect.yMax,
// 0f)
// );
// GameEntry.Event.Fire(this, DisplayItemShowEventArgs.Create(_index, _context.IsWeapon, targetPos));
// }
//
// public void OnItemInfoLock()
// {
// GameEntry.Event.Fire(this, DisplayItemInfoLockEventArgs.Create());
// }
//
// public void OnItemInfoHide()
// {
// GameEntry.Event.Fire(this, DisplayItemInfoHideEventArgs.Create());
// }
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7fe0ad0e96348114786974bb02d62914
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,205 @@
// using CustomEvent;
// using TMPro;
// using UnityEngine;
// using UnityGameFramework.Runtime;
//
// namespace UI
// {
// public class DisplayItemInfoForm : UGuiForm
// {
// [SerializeField] private RectTransform _content;
//
// [SerializeField] private IconArea _iconArea;
//
// [SerializeField] private TMP_Text _itemTitle;
//
// [SerializeField] private TMP_Text _itemTypeText;
//
// [SerializeField] private TMP_Text _itemDescription;
//
// [SerializeField] private CommonButton _recycleButton;
//
// [SerializeField] private TMP_Text _itemPrice;
//
// [SerializeField] private bool _autoResizeHeight = true;
//
// [SerializeField] private float _fixedTopHeight = 150f;
//
// [SerializeField] private float _fixedBottomHeight = 150f;
//
// [SerializeField] private float _fixedWidth = 300f;
//
// [SerializeField] private float _screenEdgePadding = 0f;
//
// private DisplayItemInfoFormContext _context;
// private Vector3 _targetPos;
//
// public void RefreshUI(DisplayItemInfoFormContext context)
// {
// if (context == null)
// {
// Log.Warning("DisplayItemInfoForm context is invalid.");
// return;
// }
//
// _context = context;
//
// _targetPos = ConvertWorldToAnchored(_context.TargetPos);
// Log.Info($"{_context.TargetPos}->{_targetPos}");
//
// if (_content != null)
// {
// _content.anchoredPosition3D = _targetPos;
// }
//
// if (_itemTitle != null) _itemTitle.text = _context.Title ?? string.Empty;
// if (_itemTypeText != null) _itemTypeText.text = _context.TypeText ?? string.Empty;
// if (_itemDescription != null) _itemDescription.text = _context.Description ?? string.Empty;
// if (_itemPrice != null) _itemPrice.text = $"{_context.Price} <sprite name=\"coin\" index=0>";
//
// if (_recycleButton != null)
// {
// _recycleButton.gameObject.SetActive(_context.IsWeapon);
// }
//
// if (_iconArea != null)
// {
// if (!string.IsNullOrEmpty(_context.IconAssetName))
// {
// string iconAssetName = _context.IconAssetName;
// GameEntry.SpriteCache.GetSprite(iconAssetName, sprite =>
// {
// if (_context != null && _context.IconAssetName == iconAssetName)
// {
// _iconArea.OnInit(sprite, context.Rarity);
// ResizeToFitContent();
// ApplyClampedTargetPos();
// }
// });
// }
// }
//
// ResizeToFitContent();
// ApplyClampedTargetPos();
// }
//
// protected override void OnOpen(object userData)
// {
// base.OnOpen(userData);
//
// if (!(userData is DisplayItemInfoFormContext context))
// {
// Log.Error("DisplayItemInfoFormContext is invalid.");
// return;
// }
//
// RefreshUI(context);
// }
//
// protected override void OnClose(bool isShutdown, object userData)
// {
// _context = null;
// base.OnClose(isShutdown, userData);
// }
//
// private void ResizeToFitContent()
// {
// if (!_autoResizeHeight || _content == null)
// {
// return;
// }
//
// if (_itemDescription == null)
// {
// return;
// }
//
// _itemDescription.ForceMeshUpdate();
// var descriptionSize = _itemDescription.rectTransform.sizeDelta;
// descriptionSize.y = _itemDescription.preferredHeight;
// _itemDescription.rectTransform.sizeDelta = descriptionSize;
// float descriptionHeight = Mathf.Max(0f, _itemDescription.preferredHeight);
// float targetHeight = _fixedTopHeight + descriptionHeight + _fixedBottomHeight;
//
// Vector2 size = new Vector2(_fixedWidth, targetHeight);
// _content.sizeDelta = size;
// }
//
// private void ApplyClampedTargetPos()
// {
// if (_content == null)
// {
// return;
// }
//
// RectTransform parent = _content.parent as RectTransform;
// if (parent == null)
// {
// return;
// }
//
// Vector2 size = _content.sizeDelta;
// if (size.x <= 0f || size.y <= 0f)
// {
// size = _content.rect.size;
// }
//
// Vector2 pivot = _content.pivot;
// float halfWidth = parent.rect.width * 0.5f;
// float halfHeight = parent.rect.height * 0.5f;
//
// float minX = -halfWidth + size.x * pivot.x + _screenEdgePadding;
// float maxX = halfWidth - size.x * (1f - pivot.x) - _screenEdgePadding;
// float minY = -halfHeight + size.y * pivot.y + _screenEdgePadding;
// float maxY = halfHeight - size.y * (1f - pivot.y) - _screenEdgePadding;
//
// float clampedX = minX <= maxX ? Mathf.Clamp(_targetPos.x, minX, maxX) : 0f;
// float clampedY = minY <= maxY ? Mathf.Clamp(_targetPos.y, minY, maxY) : 0f;
//
// _content.anchoredPosition3D = new Vector3(clampedX, clampedY, _targetPos.z);
// }
//
// private Vector3 ConvertWorldToAnchored(Vector3 worldPos)
// {
// if (_content == null)
// {
// return worldPos;
// }
//
// RectTransform parent = _content.parent as RectTransform;
// if (parent == null)
// {
// return worldPos;
// }
//
// Canvas canvas = _content.GetComponentInParent<Canvas>();
// Canvas rootCanvas = canvas != null ? canvas.rootCanvas : null;
// Camera uiCamera = null;
// if (rootCanvas != null && rootCanvas.renderMode != RenderMode.ScreenSpaceOverlay)
// {
// uiCamera = rootCanvas.worldCamera != null ? rootCanvas.worldCamera : Camera.main;
// }
//
// Vector2 screenPoint = RectTransformUtility.WorldToScreenPoint(uiCamera, worldPos);
// if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(parent, screenPoint, uiCamera,
// out Vector2 localPoint))
// {
// return worldPos;
// }
//
// float z = _content.anchoredPosition3D.z;
// return new Vector3(localPoint.x, localPoint.y, z);
// }
//
// public void OnRecycleButtonClick()
// {
// if (_context == null || !_context.IsWeapon) return;
// GameEntry.Event.Fire(this, ShopWeaponRecycleEventArgs.Create(_context.Index, _context.Price));
// }
//
// public void OnCancelButtonClick()
// {
// GameEntry.Event.Fire(this, DisplayItemInfoHideEventArgs.Create());
// }
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 32469245f20597240a3c51d2cd1fb0c5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,27 @@
// using GameFramework;
// using GameFramework.ObjectPool;
// using UnityEngine;
//
// namespace UI
// {
// public class DisplayItemObject : ObjectBase
// {
// public static DisplayItemObject Create(object target)
// {
// DisplayItemObject displayItemObject = ReferencePool.Acquire<DisplayItemObject>();
// displayItemObject.Initialize(target);
// return displayItemObject;
// }
//
// protected override void Release(bool isShutdown)
// {
// DisplayItem item = (DisplayItem)Target;
// if (item == null)
// {
// return;
// }
//
// Object.Destroy(item.gameObject);
// }
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f21ab051c635de04998b80804d9bafe5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,285 @@
// using System;
// using System.Collections.Generic;
// using GameFramework.ObjectPool;
// using TMPro;
// using UnityEngine;
// using UnityEngine.UI;
// using UnityGameFramework.Runtime;
//
// namespace UI
// {
// public enum DisplayListAreaType : byte
// {
// None = 0,
// Prop = 1,
// Weapon = 2
// }
//
// public class DisplayListArea : MonoBehaviour
// {
// [SerializeField] private TMP_Text _titleText;
//
// [SerializeField] private TMP_Text _countText;
//
// [SerializeField] private DisplayItem _displayItemTemplate;
//
// [SerializeField] private Transform _displayItemRoot;
//
// [SerializeField] private Vector2 _startPosition = Vector2.zero;
//
// [SerializeField] private float _itemSize = 150f;
//
// [SerializeField] private float _itemSpacing = 10f;
//
// [SerializeField] private int _fixedColumnCount = 0;
//
// [SerializeField] private int _instancePoolCapacity = 32;
//
// private DisplayListAreaContext _context;
//
// private IObjectPool<DisplayItemObject> _displayItemObjectPool;
// private const string DisplayItemPoolName = "DisplayItem";
//
// private readonly List<DisplayItem> _activeItems = new List<DisplayItem>();
//
// public void OnInit(DisplayListAreaContext context)
// {
// if (context == null)
// {
// Log.Warning("DisplayListArea context is invalid.");
// return;
// }
//
// EnsurePool();
// _context = context;
//
// if (_titleText != null) _titleText.text = context.Title;
// UpdateCountText(context.CurrentCount, context.MaxCount);
//
// int itemCount = context.ItemContexts?.Length ?? 0;
// int targetCount = Mathf.Min(context.CurrentCount, itemCount);
// EnsureItemCount(targetCount);
// for (int i = 0; i < targetCount; i++)
// {
// _activeItems[i].OnInit(context.ItemContexts[i], i);
// }
//
// LayoutItems();
// }
//
// public void OnReset()
// {
// _context = null;
//
// for (int i = _activeItems.Count - 1; i >= 0; i--)
// {
// HideItem(_activeItems[i]);
// }
// }
//
// public void OnDestroy()
// {
// _displayItemObjectPool?.ReleaseAllUnused();
// }
//
// public DisplayItem AddItem(DisplayItemContext itemContext)
// {
// EnsurePool();
// if (_displayItemObjectPool == null)
// {
// return null;
// }
//
// DisplayItem item = CreateItem();
// if (item == null)
// {
// return null;
// }
//
// int index = _activeItems.Count;
// _activeItems.Add(item);
// item.OnInit(itemContext, index);
// item.SetIndex(index);
//
// int columnCount = _fixedColumnCount > 0 ? _fixedColumnCount : CalculateColumnCount(GetRootWidth());
// LayoutItem(item, index, columnCount);
//
// int currentCount = _activeItems.Count;
// int maxCount = _context != null ? _context.MaxCount : -1;
// if (_context != null)
// {
// _context.CurrentCount = currentCount;
// }
//
// UpdateCountText(currentCount, maxCount);
//
// return item;
// }
//
// public bool RemoveItemAt(int index)
// {
// if (index < 0 || index >= _activeItems.Count)
// {
// return false;
// }
//
// HideItem(_activeItems[index]);
// LayoutItems();
//
// int currentCount = _activeItems.Count;
// int maxCount = _context != null ? _context.MaxCount : -1;
// if (_context != null)
// {
// _context.CurrentCount = currentCount;
// }
//
// UpdateCountText(currentCount, maxCount);
//
// return true;
// }
//
// private void EnsurePool()
// {
// if (_displayItemObjectPool != null) return;
//
// if (_displayItemRoot == null)
// {
// _displayItemRoot = transform;
// }
//
// GridLayoutGroup gridLayout = _displayItemRoot.GetComponent<GridLayoutGroup>();
// if (gridLayout != null)
// {
// gridLayout.enabled = false;
// }
//
// if (GameEntry.ObjectPool.HasObjectPool<DisplayItemObject>(DisplayItemPoolName))
// {
// _displayItemObjectPool = GameEntry.ObjectPool.GetObjectPool<DisplayItemObject>(DisplayItemPoolName);
// return;
// }
//
// if (_displayItemTemplate == null)
// {
// Debug.LogError("DisplayListArea requires a DisplayItem template.");
// return;
// }
//
// _displayItemObjectPool =
// GameEntry.ObjectPool.CreateSingleSpawnObjectPool<DisplayItemObject>(DisplayItemPoolName,
// _instancePoolCapacity);
// }
//
// private void EnsureItemCount(int count)
// {
// if (_displayItemObjectPool == null) return;
//
// for (int i = _activeItems.Count; i < count; i++)
// {
// DisplayItem item = CreateItem();
// if (item == null)
// {
// break;
// }
//
// _activeItems.Add(item);
// }
//
// for (int i = _activeItems.Count - 1; i >= count; i--)
// {
// HideItem(_activeItems[i]);
// }
// }
//
// private DisplayItem CreateItem()
// {
// DisplayItem item = null;
// DisplayItemObject itemObject = _displayItemObjectPool.Spawn();
// if (itemObject != null)
// {
// item = (DisplayItem)itemObject.Target;
// }
// else
// {
// if (_displayItemTemplate == null)
// {
// Debug.LogError("DisplayListArea requires a DisplayItem template.");
// return null;
// }
//
// item = Instantiate(_displayItemTemplate);
// _displayItemObjectPool.Register(DisplayItemObject.Create(item), true);
// }
//
// if (_displayItemRoot != null)
// {
// Transform itemTransform = item.transform;
// itemTransform.SetParent(_displayItemRoot, false);
// }
//
// item.gameObject.SetActive(true);
// return item;
// }
//
// private void HideItem(DisplayItem item)
// {
// if (item == null) return;
// item.OnReset();
// _activeItems.Remove(item);
// item.gameObject.SetActive(false);
// _displayItemObjectPool?.Unspawn(item);
// }
//
// private void LayoutItems()
// {
// if (_displayItemRoot == null) return;
//
// int columnCount = _fixedColumnCount > 0 ? _fixedColumnCount : CalculateColumnCount(GetRootWidth());
//
// for (int i = 0; i < _activeItems.Count; i++)
// {
// DisplayItem item = _activeItems[i];
// item.SetIndex(i);
// LayoutItem(item, i, columnCount);
// }
// }
//
// private void LayoutItem(DisplayItem item, int index, int columnCount)
// {
// if (item == null) return;
// RectTransform itemRect = item.GetComponent<RectTransform>();
// if (itemRect == null) return;
//
// float step = _itemSize + _itemSpacing;
// int row = index / columnCount;
// int col = index % columnCount;
//
// itemRect.anchorMin = new Vector2(0f, 1f);
// itemRect.anchorMax = new Vector2(0f, 1f);
// itemRect.pivot = new Vector2(0f, 1f);
// itemRect.sizeDelta = new Vector2(_itemSize, _itemSize);
// itemRect.anchoredPosition = _startPosition + new Vector2(col * step, -row * step);
// }
//
// private float GetRootWidth()
// {
// RectTransform rootRect = _displayItemRoot as RectTransform;
// return rootRect != null ? rootRect.rect.width : 0f;
// }
//
// private int CalculateColumnCount(float rootWidth)
// {
// if (rootWidth <= 0f) return 1;
//
// float step = _itemSize + _itemSpacing;
// int columns = Mathf.FloorToInt((rootWidth + _itemSpacing) / step);
// return Mathf.Max(1, columns);
// }
//
// private void UpdateCountText(int currentCount, int maxCount)
// {
// if (_countText == null) return;
// _countText.text = maxCount == -1 ? $"({currentCount})" : $"({currentCount}/{maxCount})";
// }
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 58c6ff306e4be41458bdf4dd82ad92e1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,142 @@
// using CustomComponent;
// using CustomEvent;
// using GameFramework.Event;
// using TMPro;
// using UnityEngine;
// using UnityEngine.UI;
//
// namespace UI
// {
// public class HudForm : UGuiForm
// {
// [SerializeField] private float _sliderFadeDuration = 0.5f;
//
// [SerializeField] private Slider _hpSlider;
//
// [SerializeField] private TMP_Text _hpText;
//
// private float _currentHpPercent = 0;
// private Coroutine _hpSliderFadeCoroutine;
//
// [SerializeField] private Slider _expSlider;
//
// private float _currentExpPercent = 0;
// private Coroutine _expSliderFadeCoroutine;
//
// [SerializeField] private TMP_Text _expText;
//
// private int _playerCurrentLevel = 1;
//
// [SerializeField] private TMP_Text _coinText;
// private int _currentCoin = 0;
//
// [SerializeField] private TMP_Text _levelTimeLeftText;
// private int _currentTimeLeft = 0;
//
// [SerializeField] private TMP_Text _enemyCountText;
// private EnemyManagerComponent _enemy;
//
// public void RefreshUI(HudFormContext hudFormContext)
// {
// }
//
// #region FSM
//
// protected override void OnInit(object userData)
// {
// base.OnInit(userData);
//
// GameEntry.Event.Subscribe(PlayerHealthChangeEventArgs.EventId, PlayerHpChange);
// GameEntry.Event.Subscribe(PlayerExpChangeEventArgs.EventId, PlayerExpChange);
// GameEntry.Event.Subscribe(PlayerCoinChangeEventArgs.EventId, PlayerCoinChange);
// GameEntry.Event.Subscribe(PlayerLevelUpEventArgs.EventId, PlayerLevelUp);
// GameEntry.Event.Subscribe(LevelProcessEventArgs.EventId, LevelProcess);
//
// _enemy = GameEntry.EnemyManager;
// }
//
// protected override void OnClose(bool isShutdown, object userData)
// {
// GameEntry.Event.Unsubscribe(PlayerLevelUpEventArgs.EventId, PlayerLevelUp);
// GameEntry.Event.Unsubscribe(PlayerHealthChangeEventArgs.EventId, PlayerHpChange);
// GameEntry.Event.Unsubscribe(PlayerExpChangeEventArgs.EventId, PlayerExpChange);
// GameEntry.Event.Unsubscribe(PlayerCoinChangeEventArgs.EventId, PlayerCoinChange);
// GameEntry.Event.Unsubscribe(PlayerLevelUpEventArgs.EventId, PlayerLevelUp);
//
// base.OnClose(isShutdown, userData);
// }
//
// protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
// {
// base.OnUpdate(elapseSeconds, realElapseSeconds);
// if (_enemy == null)
// {
// _enemy = GameEntry.EnemyManager;
// }
//
// if (_enemy != null)
// {
// _enemyCountText.text = $"Enemy: {_enemy.CurrentEnemyCount}";
// }
// }
//
// #endregion
//
// #region Event Handlers
//
// private void PlayerHpChange(object sender, GameEventArgs e)
// {
// if (!(e is PlayerHealthChangeEventArgs args)) return;
//
// _hpText.text = $"{args.CurrentHealth}/{args.MaxHealth}";
//
// float percent = (float)args.CurrentHealth / args.MaxHealth;
// if (Mathf.Approximately(_currentHpPercent, percent)) return;
//
// _currentHpPercent = percent;
//
// if (_hpSliderFadeCoroutine != null) StopCoroutine(_hpSliderFadeCoroutine);
// _hpSliderFadeCoroutine = StartCoroutine(_hpSlider.SmoothValue(percent, _sliderFadeDuration));
// }
//
// private void PlayerExpChange(object sender, GameEventArgs e)
// {
// if (!(e is PlayerExpChangeEventArgs args)) return;
// float percent = (float)args.CurrentExp / args.MaxExp;
// if (Mathf.Approximately(_currentExpPercent, percent)) return;
//
// _currentExpPercent = percent;
//
// if (_expSliderFadeCoroutine != null) StopCoroutine(_expSliderFadeCoroutine);
// _expSliderFadeCoroutine = StartCoroutine(_expSlider.SmoothValue(percent, _sliderFadeDuration));
// }
//
// private void PlayerLevelUp(object sender, GameEventArgs e)
// {
// if (!(e is PlayerLevelUpEventArgs)) return;
//
// _playerCurrentLevel++;
// _expText.text = $"LV.{_playerCurrentLevel}";
// }
//
// private void PlayerCoinChange(object sender, GameEventArgs e)
// {
// if (!(e is PlayerCoinChangeEventArgs args)) return;
// if (_currentCoin == args.CoinCount) return;
//
// _coinText.text = $"<sprite name=\"coin\" index=0> {args.CoinCount}";
// _currentCoin = args.CoinCount;
// }
//
// private void LevelProcess(object sender, GameEventArgs e)
// {
// if (!(e is LevelProcessEventArgs args)) return;
// if (_currentTimeLeft == args.LevelTimeLeft) return;
//
// _currentTimeLeft = args.LevelTimeLeft;
// _levelTimeLeftText.text = _currentTimeLeft.ToString();
// }
//
// #endregion
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bd4c4d6e8d4b0f54c830e2cfef46848e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,70 @@
// using CustomEvent;
// using TMPro;
// using UnityEngine;
// using UnityGameFramework.Runtime;
//
// namespace UI
// {
// public class LevelUpForm : UGuiForm
// {
// [SerializeField] private LevelUpRewardItem[] _propItems;
//
// [SerializeField] private TMP_Text _refreshButtonText;
//
// private LevelUpFormContext _context;
//
// public void RefreshUI(LevelUpFormContext context)
// {
// _context = context;
//
// foreach (var propItem in _propItems)
// {
// propItem.gameObject.SetActive(false);
// }
//
// if (_context.Props == null) return;
// int count = Mathf.Min(_propItems.Length, _context.Props.Count);
// for (int i = 0; i < count; i++)
// {
// _propItems[i].gameObject.SetActive(true);
// _propItems[i].Init(_context.Props[i]);
// }
//
// //刷新 -20 <sprite name="coin" index=0>
// _refreshButtonText.text = $"刷新 -{context.RefreshPrice} <sprite name=\"coin\" index=0>";
// }
//
// #region FSM
//
// protected override void OnOpen(object userData)
// {
// base.OnOpen(userData);
//
// if (userData is LevelUpFormContext context)
// {
// RefreshUI(context);
// return;
// }
//
// Log.Warning("LevelUpForm requires LevelUpFormContext as userData.");
// }
//
// protected override void OnClose(bool isShutdown, object userData)
// {
// _context = null;
// base.OnClose(isShutdown, userData);
// }
//
// #endregion
//
// public void OnSelectButtonClick(int index)
// {
// GameEntry.Event.Fire(this, LevelUpPropSelectedEventArgs.Create(index));
// }
//
// public void OnRefreshButtonClick()
// {
// GameEntry.Event.Fire(this, RefreshEventArgs.Create(_context.RefreshPrice));
// }
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 73f52c8a6d8b8ec42ad8cd3c00e0254d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,47 @@
// using TMPro;
// using UnityEngine;
// using UnityEngine.UI;
// using UnityGameFramework.Runtime;
//
// namespace UI
// {
// public class LevelUpRewardItem : MonoBehaviour
// {
// [SerializeField] private IconArea _iconArea;
//
// [SerializeField] private TMP_Text _titleText;
//
// [SerializeField] private TMP_Text _typeText;
//
// [SerializeField] private TMP_Text _descriptionText;
//
// private LevelUpRewardItemContext _context;
//
//
// public void Init(LevelUpRewardItemContext context)
// {
// if (context == null)
// {
// Log.Error("LevelUpPropContext context is invalid.");
// return;
// }
//
// _context = context;
//
// if (_titleText != null) _titleText.text = context.Title;
// if (_descriptionText != null) _descriptionText.text = context.Description;
// if (_iconArea != null) _iconArea.OnInit(context.Icon, context.ItemRarity);
//
// LoadIcon(_context.IconAssetName);
// }
//
// private void LoadIcon(string iconAssetName)
// {
// if (_iconArea == null) return;
//
// if (string.IsNullOrEmpty(iconAssetName)) return;
//
// GameEntry.SpriteCache.GetSprite(iconAssetName, sprite => _iconArea.SetIcon(sprite));
// }
// }
// }
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 237d64392d274c14f9f5c81b54122a93
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,192 @@
// using System.Collections.Generic;
// using CustomEvent;
// using GameFramework.Event;
// using TMPro;
// using UnityEngine;
// using UnityGameFramework.Runtime;
//
// namespace UI
// {
// public class ShopForm : UGuiForm
// {
// #region Property
//
// [SerializeField] private TMP_Text _titleText;
//
// [SerializeField] private TMP_Text _continueButtonText;
//
// [SerializeField] private TMP_Text _refreshPriceText;
//
// [SerializeField] private TMP_Text _playerCoinText;
// private int _currentCoin;
//
// [SerializeField] private ShopGoodsItem[] _goodsItems;
//
// [SerializeField] private DisplayListArea _propListArea;
//
// [SerializeField] private DisplayListArea _weaponListArea;
//
// private ShopFormContext _context;
//
// #endregion
//
//
// public void RefreshUI(ShopFormContext context)
// {
// _context = context;
//
// _titleText.text = $"商店 (Lv.{context.CurrentLevel})";
// _continueButtonText.text = $"继续 (Lv.{context.CurrentLevel + 1})";
// RefreshRefreshPrice(context.RefreshPrice);
// _playerCoinText.text = $"<sprite name=\"coin\" index=0> {context.PlayerCoin}";
//
// RefreshGoodsItems(context.GoodsItems);
//
// if (_propListArea != null && context.PropListContext != null)
// {
// _propListArea.OnInit(context.PropListContext);
// }
//
// if (_weaponListArea != null && context.WeaponListContext != null)
// {
// _weaponListArea.OnInit(context.WeaponListContext);
// }
// }
//
// internal void RefreshGoodsItems(List<GoodsItemContext> goodsItems)
// {
// foreach (var item in _goodsItems)
// {
// item.gameObject.SetActive(false);
// }
//
// if (goodsItems == null)
// {
// return;
// }
//
// int count = Mathf.Min(_goodsItems.Length, goodsItems.Count);
// for (int i = 0; i < count; i++)
// {
// _goodsItems[i].Init(goodsItems[i]);
// _goodsItems[i].gameObject.SetActive(true);
// }
// }
//
// internal void RefreshRefreshPrice(int refreshPrice)
// {
// _refreshPriceText.text = $"刷新 -{refreshPrice} <sprite name=\"coin\" index=0>";
// }
//
// internal void ApplyGoodsPurchased(int goodsIndex, DisplayItemContext displayItem)
// {
// SetGoodsItemVisible(goodsIndex, false);
//
// if (displayItem == null)
// {
// return;
// }
//
// if (displayItem.IsWeapon)
// {
// AddWeaponDisplayItem(displayItem);
// }
// else
// {
// AddPropDisplayItem(displayItem);
// }
// }
//
// private void SetGoodsItemVisible(int index, bool visible)
// {
// if (_goodsItems == null || index < 0 || index >= _goodsItems.Length)
// {
// Log.Warning("ShopForm.SetGoodsItemVisible: Invalid index.");
// return;
// }
//
// _goodsItems[index].gameObject.SetActive(visible);
// }
//
// private void AddPropDisplayItem(DisplayItemContext context)
// {
// if (_propListArea == null || context == null) return;
// _propListArea.AddItem(context);
// }
//
// private void AddWeaponDisplayItem(DisplayItemContext context)
// {
// if (_weaponListArea == null || context == null) return;
// _weaponListArea.AddItem(context);
// }
//
// internal void RemoveWeaponDisplayItem(int index)
// {
// if (_weaponListArea == null) return;
// _weaponListArea.RemoveItemAt(index);
// }
//
// #region ButtonClick
//
// public void OnContinueButtonClick()
// {
// GameEntry.Event.Fire(this, ShopContinueEventArgs.Create());
// }
//
// public void OnPurchaseButtonClick(int index)
// {
// GameEntry.Event.Fire(this, ShopPurchaseEventArgs.Create(index));
// }
//
// public void OnRefreshButtonClick()
// {
// GameEntry.Event.Fire(this, RefreshEventArgs.Create(_context.RefreshPrice));
// }
//
// #endregion
//
// #region FSM
//
// protected override void OnOpen(object userData)
// {
// base.OnOpen(userData);
//
// GameEntry.Event.Subscribe(PlayerCoinChangeEventArgs.EventId, OnPlayerCoinChange);
//
// if (userData is ShopFormContext context)
// {
// RefreshUI(context);
// return;
// }
//
// Log.Warning("ShopForm requires ShopFormContext as userData.");
// }
//
// protected override void OnClose(bool isShutdown, object userData)
// {
// _context = null;
//
// GameEntry.Event.Unsubscribe(PlayerCoinChangeEventArgs.EventId, OnPlayerCoinChange);
//
// _propListArea?.OnReset();
// _weaponListArea?.OnReset();
//
// base.OnClose(isShutdown, userData);
// }
//
// #endregion
//
// #region Event Handlers
//
// private void OnPlayerCoinChange(object sender, GameEventArgs e)
// {
// if (!(e is PlayerCoinChangeEventArgs args)) return;
// if (args.CoinCount == _currentCoin) return;
//
// _currentCoin = args.CoinCount;
// _playerCoinText.text = $"<sprite name=\"coin\" index=0> {_currentCoin}";
// }
//
// #endregion
// }
// }

Some files were not shown because too many files have changed in this diff Show More