整理 ShopUseCase 的相关脚本
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b80dd4adb0a8e148abc7c52a2e23b42
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 710248cee26a898459031e4336703628
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,103 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class CommonButton : Button
|
||||
{
|
||||
[SerializeField] private Image _background = null;
|
||||
|
||||
private Color _originalBackgroundColor;
|
||||
|
||||
[SerializeField] private UnityEvent _onPointerEnterAction = new();
|
||||
|
||||
[SerializeField] private UnityEvent _onPointerExitAction = new();
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
_originalBackgroundColor = _background.color;
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
_background.color = _originalBackgroundColor;
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
_background.color = new Color(0.3f, 0.3f, 0.3f, 0.3f);
|
||||
}
|
||||
|
||||
public override void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
if (eventData.button != PointerEventData.InputButton.Left)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EnterHoverState();
|
||||
}
|
||||
|
||||
public override void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
if (eventData.button != PointerEventData.InputButton.Left)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ExitHoverState();
|
||||
}
|
||||
|
||||
public override void OnSelect(BaseEventData eventData)
|
||||
{
|
||||
_background.color = new Color(1f, 0.9f, 0.3f);
|
||||
EnterHoverState();
|
||||
}
|
||||
|
||||
public override void OnDeselect(BaseEventData eventData)
|
||||
{
|
||||
_background.color = _originalBackgroundColor;
|
||||
ExitHoverState();
|
||||
}
|
||||
|
||||
private void EnterHoverState()
|
||||
{
|
||||
if (EventSystem.current.currentSelectedGameObject != gameObject)
|
||||
{
|
||||
EventSystem.current.SetSelectedGameObject(this.gameObject);
|
||||
}
|
||||
|
||||
_onPointerEnterAction.Invoke();
|
||||
}
|
||||
|
||||
private void ExitHoverState()
|
||||
{
|
||||
_onPointerExitAction.Invoke();
|
||||
}
|
||||
|
||||
public void RegisterPointerEnterAction(UnityAction action)
|
||||
{
|
||||
_onPointerEnterAction.AddListener(action);
|
||||
}
|
||||
|
||||
public void RegisterPointerExitAction(UnityAction action)
|
||||
{
|
||||
_onPointerExitAction.AddListener(action);
|
||||
}
|
||||
|
||||
public void UnregisterPointerEnterAction(UnityAction action)
|
||||
{
|
||||
_onPointerEnterAction.RemoveListener(action);
|
||||
}
|
||||
|
||||
public void UnregisterPointerExitAction(UnityAction action)
|
||||
{
|
||||
_onPointerExitAction.RemoveListener(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5079836f95c2a44b96fa331487ebb70
|
||||
timeCreated: 1528026160
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c41ec32ecc913a3479f29daf48e3da04
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3d54de71bcad264da3c1ca92ff54e4f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 337bc362617c8994fb0248fa5d5fd4a8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f228612923ff51343a4dab06ce4c1f92
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e4010de30b33144fa20400058edfeba
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b12df2039d69e14aa018b259f3789cf
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35c8961f073eae8479506bdec8b745f8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class ShopGoodsSelection
|
||||
{
|
||||
public GoodsType GoodsType;
|
||||
public int PropId;
|
||||
public WeaponType WeaponType;
|
||||
public int Price;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df119fea99cc4e3e9fd080a7be4ec3ab
|
||||
timeCreated: 1789377913
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public sealed class ShopPurchaseResult
|
||||
{
|
||||
public int GoodsIndex;
|
||||
public DisplayItemRawData DisplayItem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a48aa67c1024d86b79cf1f5550084a0
|
||||
timeCreated: 1789377892
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public sealed class ShopRefreshResult
|
||||
{
|
||||
public List<GoodsItemRawData> GoodsItems;
|
||||
public int RefreshPrice;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0870748189e94cfa8eec2645bec5fd39
|
||||
timeCreated: 1789377879
|
||||
-21
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
@@ -11,18 +10,6 @@ using Random = UnityEngine.Random;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public sealed class ShopRefreshResult
|
||||
{
|
||||
public List<GoodsItemRawData> GoodsItems;
|
||||
public int RefreshPrice;
|
||||
}
|
||||
|
||||
public sealed class ShopPurchaseResult
|
||||
{
|
||||
public int GoodsIndex;
|
||||
public DisplayItemRawData DisplayItem;
|
||||
}
|
||||
|
||||
public class ShopUseCase : IUIUseCase
|
||||
{
|
||||
private readonly Player _player;
|
||||
@@ -37,14 +24,6 @@ namespace SepCore.UI
|
||||
private readonly List<ShopGoodsSelection> _selections = new();
|
||||
private int _refreshTime;
|
||||
|
||||
private sealed class ShopGoodsSelection
|
||||
{
|
||||
public GoodsType GoodsType;
|
||||
public int PropId;
|
||||
public WeaponType WeaponType;
|
||||
public int Price;
|
||||
}
|
||||
|
||||
public ShopUseCase(Player player, int currentLevel, Action onShopFinish)
|
||||
{
|
||||
_player = player;
|
||||
Reference in New Issue
Block a user