diff --git a/.vscode/settings.json b/.vscode/settings.json
index 1056b20..cfbb280 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -56,5 +56,6 @@
"temp/": true,
"Temp/": true
},
- "dotnet.defaultSolution": "VampireLike.sln"
+ "dotnet.defaultSolution": "VampireLike.sln",
+ "dotnet.preferCSharpExtension": true
}
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/Definition/Enum/UIFormType.cs b/Assets/GameMain/Scripts/Definition/Enum/UIFormType.cs
index 297a245..a3dc469 100644
--- a/Assets/GameMain/Scripts/Definition/Enum/UIFormType.cs
+++ b/Assets/GameMain/Scripts/Definition/Enum/UIFormType.cs
@@ -53,5 +53,10 @@ namespace Definition.Enum
/// 游戏HUD。
///
HudForm = 203,
+
+ ///
+ /// 升级选择。
+ ///
+ LevelUpForm = 204,
}
}
diff --git a/Assets/GameMain/Scripts/Entity/EntityLogic/Player.cs b/Assets/GameMain/Scripts/Entity/EntityLogic/Player.cs
index 451b78d..d7fd7bb 100644
--- a/Assets/GameMain/Scripts/Entity/EntityLogic/Player.cs
+++ b/Assets/GameMain/Scripts/Entity/EntityLogic/Player.cs
@@ -70,6 +70,8 @@ namespace Entity
}
}
+ public int CurrentLevel => _currentLevel;
+
public bool Enable
{
get => _enable;
diff --git a/Assets/GameMain/Scripts/Event/LevelUpPropSelectedEventArgs.cs b/Assets/GameMain/Scripts/Event/LevelUpPropSelectedEventArgs.cs
new file mode 100644
index 0000000..a43be13
--- /dev/null
+++ b/Assets/GameMain/Scripts/Event/LevelUpPropSelectedEventArgs.cs
@@ -0,0 +1,31 @@
+using GameFramework;
+using GameFramework.Event;
+
+namespace CustomEvent
+{
+ public class LevelUpPropSelectedEventArgs : GameEventArgs
+ {
+ public static readonly int EventId = typeof(LevelUpPropSelectedEventArgs).GetHashCode();
+
+ public override int Id => EventId;
+
+ public int SelectedId { get; private set; }
+
+ public LevelUpPropSelectedEventArgs()
+ {
+ SelectedId = -1;
+ }
+
+ public static LevelUpPropSelectedEventArgs Create(int propId)
+ {
+ var args = ReferencePool.Acquire();
+ args.SelectedId = propId;
+ return args;
+ }
+
+ public override void Clear()
+ {
+ SelectedId = -1;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/Event/LevelUpPropSelectedEventArgs.cs.meta b/Assets/GameMain/Scripts/Event/LevelUpPropSelectedEventArgs.cs.meta
new file mode 100644
index 0000000..b4c74dc
--- /dev/null
+++ b/Assets/GameMain/Scripts/Event/LevelUpPropSelectedEventArgs.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 3183e53376fbf95438a0a938510ce7f1
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/GameMain/Scripts/Event/Player.meta b/Assets/GameMain/Scripts/Event/Player.meta
new file mode 100644
index 0000000..abeabe5
--- /dev/null
+++ b/Assets/GameMain/Scripts/Event/Player.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 2540b6786a5c4f3aadd4f57c79b714b9
+timeCreated: 1770985387
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/Event/PlayerCoinChangeEventArgs.cs b/Assets/GameMain/Scripts/Event/Player/PlayerCoinChangeEventArgs.cs
similarity index 100%
rename from Assets/GameMain/Scripts/Event/PlayerCoinChangeEventArgs.cs
rename to Assets/GameMain/Scripts/Event/Player/PlayerCoinChangeEventArgs.cs
diff --git a/Assets/GameMain/Scripts/Event/PlayerCoinChangeEventArgs.cs.meta b/Assets/GameMain/Scripts/Event/Player/PlayerCoinChangeEventArgs.cs.meta
similarity index 100%
rename from Assets/GameMain/Scripts/Event/PlayerCoinChangeEventArgs.cs.meta
rename to Assets/GameMain/Scripts/Event/Player/PlayerCoinChangeEventArgs.cs.meta
diff --git a/Assets/GameMain/Scripts/Event/PlayerExpChangeEventArgs.cs b/Assets/GameMain/Scripts/Event/Player/PlayerExpChangeEventArgs.cs
similarity index 100%
rename from Assets/GameMain/Scripts/Event/PlayerExpChangeEventArgs.cs
rename to Assets/GameMain/Scripts/Event/Player/PlayerExpChangeEventArgs.cs
diff --git a/Assets/GameMain/Scripts/Event/PlayerExpChangeEventArgs.cs.meta b/Assets/GameMain/Scripts/Event/Player/PlayerExpChangeEventArgs.cs.meta
similarity index 100%
rename from Assets/GameMain/Scripts/Event/PlayerExpChangeEventArgs.cs.meta
rename to Assets/GameMain/Scripts/Event/Player/PlayerExpChangeEventArgs.cs.meta
diff --git a/Assets/GameMain/Scripts/Event/PlayerHealthChangeEventArgs.cs b/Assets/GameMain/Scripts/Event/Player/PlayerHealthChangeEventArgs.cs
similarity index 100%
rename from Assets/GameMain/Scripts/Event/PlayerHealthChangeEventArgs.cs
rename to Assets/GameMain/Scripts/Event/Player/PlayerHealthChangeEventArgs.cs
diff --git a/Assets/GameMain/Scripts/Event/PlayerHealthChangeEventArgs.cs.meta b/Assets/GameMain/Scripts/Event/Player/PlayerHealthChangeEventArgs.cs.meta
similarity index 100%
rename from Assets/GameMain/Scripts/Event/PlayerHealthChangeEventArgs.cs.meta
rename to Assets/GameMain/Scripts/Event/Player/PlayerHealthChangeEventArgs.cs.meta
diff --git a/Assets/GameMain/Scripts/Event/Player/PlayerLevelUpEventArgs.cs b/Assets/GameMain/Scripts/Event/Player/PlayerLevelUpEventArgs.cs
new file mode 100644
index 0000000..4323875
--- /dev/null
+++ b/Assets/GameMain/Scripts/Event/Player/PlayerLevelUpEventArgs.cs
@@ -0,0 +1,27 @@
+using GameFramework;
+using GameFramework.Event;
+
+namespace CustomEvent
+{
+ public class PlayerLevelUpEventArgs : GameEventArgs
+ {
+ public static readonly int EventId = typeof(PlayerLevelUpEventArgs).GetHashCode();
+
+ public override int Id => EventId;
+
+ public PlayerLevelUpEventArgs()
+ {
+ }
+
+ public static PlayerLevelUpEventArgs Create()
+ {
+ var args = ReferencePool.Acquire();
+
+ return args;
+ }
+
+ public override void Clear()
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/Event/Player/PlayerLevelUpEventArgs.cs.meta b/Assets/GameMain/Scripts/Event/Player/PlayerLevelUpEventArgs.cs.meta
new file mode 100644
index 0000000..ba8ed3c
--- /dev/null
+++ b/Assets/GameMain/Scripts/Event/Player/PlayerLevelUpEventArgs.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 59e602f086ce428396eab715b1277a23
+timeCreated: 1770989625
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/Event/Shop.meta b/Assets/GameMain/Scripts/Event/Shop.meta
new file mode 100644
index 0000000..4a0de7f
--- /dev/null
+++ b/Assets/GameMain/Scripts/Event/Shop.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 0ce83a125a974b49ad8a9251a8d73359
+timeCreated: 1770985411
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/Event/Shop/ShopContinueEventArgs.cs b/Assets/GameMain/Scripts/Event/Shop/ShopContinueEventArgs.cs
new file mode 100644
index 0000000..4f5a592
--- /dev/null
+++ b/Assets/GameMain/Scripts/Event/Shop/ShopContinueEventArgs.cs
@@ -0,0 +1,27 @@
+using GameFramework;
+using GameFramework.Event;
+
+namespace CustomEvent
+{
+ public class ShopContinueEventArgs : GameEventArgs
+ {
+ public static readonly int EventId = typeof(ShopContinueEventArgs).GetHashCode();
+
+ public override int Id => EventId;
+
+ public ShopContinueEventArgs()
+ {
+ }
+
+ public static ShopContinueEventArgs Create()
+ {
+ var args = ReferencePool.Acquire();
+
+ return args;
+ }
+
+ public override void Clear()
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/Event/Shop/ShopContinueEventArgs.cs.meta b/Assets/GameMain/Scripts/Event/Shop/ShopContinueEventArgs.cs.meta
new file mode 100644
index 0000000..4cc0ef4
--- /dev/null
+++ b/Assets/GameMain/Scripts/Event/Shop/ShopContinueEventArgs.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: b09ad1baac8a41338c0e42baf398beb8
+timeCreated: 1770986449
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/Event/Shop/ShopPurchaseEventArgs.cs b/Assets/GameMain/Scripts/Event/Shop/ShopPurchaseEventArgs.cs
new file mode 100644
index 0000000..07a254f
--- /dev/null
+++ b/Assets/GameMain/Scripts/Event/Shop/ShopPurchaseEventArgs.cs
@@ -0,0 +1,34 @@
+using GameFramework;
+using GameFramework.Event;
+
+namespace CustomEvent
+{
+ public class ShopPurchaseEventArgs : GameEventArgs
+ {
+ public static readonly int EventId = typeof(ShopPurchaseEventArgs).GetHashCode();
+
+ public override int Id => EventId;
+
+ public int GoodsIndex { get; private set; }
+
+ public ShopPurchaseEventArgs()
+ {
+ GoodsIndex = -1;
+ }
+
+ public static ShopPurchaseEventArgs Create(int index)
+ {
+ var args = ReferencePool.Acquire();
+
+ args.GoodsIndex = index;
+
+ return args;
+ }
+
+ public override void Clear()
+ {
+ GoodsIndex = -1;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/Event/Shop/ShopPurchaseEventArgs.cs.meta b/Assets/GameMain/Scripts/Event/Shop/ShopPurchaseEventArgs.cs.meta
new file mode 100644
index 0000000..e5a8a54
--- /dev/null
+++ b/Assets/GameMain/Scripts/Event/Shop/ShopPurchaseEventArgs.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 11c82e4a45804087b1aaf337e38a8836
+timeCreated: 1770986490
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/Event/Shop/ShopRefreshEventArgs.cs b/Assets/GameMain/Scripts/Event/Shop/ShopRefreshEventArgs.cs
new file mode 100644
index 0000000..2c0751e
--- /dev/null
+++ b/Assets/GameMain/Scripts/Event/Shop/ShopRefreshEventArgs.cs
@@ -0,0 +1,34 @@
+using GameFramework;
+using GameFramework.Event;
+
+namespace CustomEvent
+{
+ public class ShopRefreshEventArgs : GameEventArgs
+ {
+ public static readonly int EventId = typeof(ShopRefreshEventArgs).GetHashCode();
+
+ public override int Id => EventId;
+
+ public int Cost { get; private set; }
+
+ public ShopRefreshEventArgs()
+ {
+ Cost = 0;
+ }
+
+ public static ShopRefreshEventArgs Create(int cost)
+ {
+ var args = ReferencePool.Acquire();
+
+ args.Cost = cost;
+
+ return args;
+ }
+
+ public override void Clear()
+ {
+ Cost = 0;
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/Event/Shop/ShopRefreshEventArgs.cs.meta b/Assets/GameMain/Scripts/Event/Shop/ShopRefreshEventArgs.cs.meta
new file mode 100644
index 0000000..31847bb
--- /dev/null
+++ b/Assets/GameMain/Scripts/Event/Shop/ShopRefreshEventArgs.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 7f463ec631b54d9e9feda00be716ae68
+timeCreated: 1770985436
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/Procedure/Game/GameStateShop.cs b/Assets/GameMain/Scripts/Procedure/Game/GameStateShop.cs
index ec734d4..0d09dc8 100644
--- a/Assets/GameMain/Scripts/Procedure/Game/GameStateShop.cs
+++ b/Assets/GameMain/Scripts/Procedure/Game/GameStateShop.cs
@@ -1,167 +1,209 @@
+using System;
using System.Collections.Generic;
using System.Linq;
+using CustomEvent;
using DataTable;
using Definition.Enum;
using Entity;
using GameFramework.DataTable;
-using GameFramework.Event;
using GameFramework.Fsm;
using GameFramework.Procedure;
using UI;
+using UnityEngine;
using UnityGameFramework.Runtime;
using Random = UnityEngine.Random;
namespace Procedure
{
- public struct ShopFormContext
- {
- public GameStateShop GameStateShop;
- public int CurrentLevel;
- public int RefreshPrice;
- public int PlayerCoin;
- public List GoodsItems;
- }
-
public class GameStateShop : GameStateBase
{
+ #region Property
+
public override GameStateType GameStateType => GameStateType.Shop;
- private ProcedureGame _procedureGame = null;
- private bool _shopOver = false;
- private ShopForm _shopForm = null;
+ private ProcedureGame _procedureGame;
- private DRGoods[] _drGoods = null;
- private IDataTable _propDataTable = null;
- private IDataTable _weaponDataTable = null;
+ private DRGoods[] _drGoods;
- private Player _player = null;
+ private DRProp[] _drProps;
+ private IDataTable _propDataTable;
+ private IDataTable _weaponDataTable;
+
+ private ShopFormController _shopFormController;
private ShopFormContext _shopFormContext;
- public void ShopOver()
- {
- if (_shopOver) return;
- _shopOver = true;
- }
+ private LevelUpFormController _levelUpFormController;
+ private LevelUpFormContext _levelUpFormContext;
- public void PurchaseGoods(int index)
- {
- if (_player.Coin < _shopFormContext.GoodsItems[index].Price) return;
- _player.Coin -= _shopFormContext.GoodsItems[index].Price;
- //TODO:OnGoodsPurchased
- }
+ private int _shopRefreshTime = 0;
- public void RefreshGoods()
+ private Player _player => _procedureGame.Player;
+
+ private bool _shopOver = false;
+
+ #endregion
+
+ #region Methods
+
+ #region LevelUp
+
+ private LevelUpFormContext BuildLevelUpFormContext(int count = 4)
{
- if (_player.Coin < _shopFormContext.RefreshPrice) return;
- _player.Coin -= _shopFormContext.RefreshPrice;
- _shopFormContext = new ShopFormContext()
+ List props = new List();
+ int total = _drProps.Length;
+ if (total <= 0)
{
- GameStateShop = this,
- CurrentLevel = _procedureGame.CurrentLevel,
- RefreshPrice = _shopFormContext.RefreshPrice + _procedureGame.CurrentLevel,
+ Log.Error("GameStateShop::BuildLevelUpFormContext(): _drProps == null");
+ return null;
+ }
+
+ count = Mathf.Min(count, total);
+
+ for (int i = 0; i < count; i++)
+ {
+ int index = Random.Range(0, total);
+ DRProp drProp = _drProps[index];
+ props.Add(new LevelUpPropContext
+ {
+ PropId = drProp.Id,
+ Title = drProp.Title,
+ Type = "Prop",
+ Icon = null,
+ Description = GoodsItemContext.CreatePropDescription(drProp.Modifiers),
+ IconAssetName = drProp.IconAssetName
+ });
+ }
+
+ return new LevelUpFormContext
+ {
+ Level = _player.CurrentLevel,
+ Props = props
+ };
+ }
+
+ #endregion
+
+ #region Shop
+
+ private void RefreshGoodsItems()
+ {
+ _shopFormContext = BuildShopFormContext();
+ _shopFormContext.RefreshPrice = (_shopRefreshTime + 1) * _procedureGame.CurrentLevel;
+ _shopRefreshTime++;
+ _shopFormController.OpenUI(_shopFormContext);
+ }
+
+ private ShopFormContext BuildShopFormContext()
+ {
+ int currentLevel = _procedureGame.CurrentLevel;
+ var context = new ShopFormContext
+ {
+ CurrentLevel = currentLevel,
+ RefreshPrice = currentLevel,
PlayerCoin = _player.Coin,
GoodsItems = InitRandomGoodsItems()
};
- _shopForm.UpdateForm(_shopFormContext);
+ return context;
}
- private List InitRandomGoodsItems()
+ private List InitRandomGoodsItems(int count = -1)
{
- // 1. 随机生成商店商品数量
- int count = Random.Range(4, 6);
+ if (_drGoods == null || _drGoods.Length == 0)
+ {
+ Log.Error("GameStateShop::InitRandomGoodsItems(): _drGoods == null");
+ return null;
+ }
- // 2. 获取数据表中配置的商品总数
+ count = Mathf.Max(count, Random.Range(4, 6));
int totalCount = _drGoods.Length;
+ List items = new List(count);
+ if (totalCount <= 0) return items;
+ count = Mathf.Min(count, totalCount);
- // 3. 创建要返回的商品列表
- List items = new List(count);
-
- // 4. 填充商品列表
for (int i = 0; i < count; i++)
{
- // 4.1 获取要添加的商品Id
int index = Random.Range(0, totalCount);
-
- // 4.2 从数据表中获取商品数据
- var drGoods = _drGoods[index];
-
- // 4.3 构建商品数据类
- var goodsItem = new GoodsItemViewData();
-
- // 4.4 填充商品数据(价格、名字、类型、图标、描述)
- goodsItem.Price = Random.Range(drGoods.MinPrice, drGoods.MaxPrice);
+ DRGoods drGoods = _drGoods[index];
+ GoodsItemContext goodsItem = new GoodsItemContext
+ {
+ Price = Random.Range(drGoods.MinPrice, drGoods.MaxPrice)
+ };
if (drGoods.GoodsType == GoodsType.Prop)
{
DRProp drProp = _propDataTable.GetDataRow(drGoods.GoodsTypeId);
-
goodsItem.Title = drProp.Title;
- goodsItem.Type = "道具";
+ goodsItem.Type = "Prop";
GameEntry.SpriteCache.GetSprite(drProp.IconAssetName, sprite => goodsItem.Icon = sprite);
- goodsItem.Description = GoodsItemViewData.CreatePropDescription(drProp.Modifiers);
+ goodsItem.Description = GoodsItemContext.CreatePropDescription(drProp.Modifiers);
}
- else if (drGoods.GoodsType is GoodsType.Weapon)
+ else if (drGoods.GoodsType == GoodsType.Weapon)
{
DRWeapon drWeapon = _weaponDataTable.GetDataRow(drGoods.GoodsTypeId);
-
goodsItem.Title = drWeapon.Title;
- goodsItem.Type = "武器";
+ goodsItem.Type = "Weapon";
GameEntry.SpriteCache.GetSprite(drWeapon.IconAssetName, sprite => goodsItem.Icon = sprite);
- goodsItem.Description = GoodsItemViewData.CreateWeaponDescription(drWeapon);
- }
- else
- {
- Log.Warning("Goods type not supported.");
+ goodsItem.Description = GoodsItemContext.CreateWeaponDescription(drWeapon);
}
- // 4.5 添加到商品列表
items.Add(goodsItem);
}
return items;
}
+ #endregion
+
+ #endregion
+
#region FSM
public override void OnInit(ProcedureGame master)
{
Log.Debug("GameStateShop::OnInit");
_procedureGame = master;
- _shopOver = false;
+
+ _levelUpFormController = new LevelUpFormController();
+ _shopFormController = new ShopFormController();
+
_drGoods = GameEntry.DataTable.GetDataTable().ToArray();
_propDataTable = GameEntry.DataTable.GetDataTable();
+ _drProps = _propDataTable.ToArray();
_weaponDataTable = GameEntry.DataTable.GetDataTable();
+
+ _shopOver = false;
}
public override void OnEnter(IFsm procedureOwner)
{
Log.Debug("GameStateShop::OnEnter");
- GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
+ GameEntry.Event.Subscribe(ShopRefreshEventArgs.EventId, ShopRefresh);
+ GameEntry.Event.Subscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
+ GameEntry.Event.Subscribe(ShopContinueEventArgs.EventId, ShopContinue);
+ GameEntry.Event.Subscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
- _shopOver = false;
- _player = _procedureGame.Player;
-
- _shopFormContext = new ShopFormContext()
+ if (_procedureGame.PlayerPendingLevel != 0)
{
- GameStateShop = this,
- CurrentLevel = _procedureGame.CurrentLevel,
- RefreshPrice = _procedureGame.CurrentLevel,
- PlayerCoin = _player.Coin,
- GoodsItems = InitRandomGoodsItems()
- };
- GameEntry.UI.OpenUIForm(UIFormType.ShopForm, _shopFormContext);
+ _levelUpFormContext = BuildLevelUpFormContext();
+ _levelUpFormController.OpenUI(_levelUpFormContext);
+ }
+ else
+ {
+ _shopFormContext = BuildShopFormContext();
+ _shopFormController.OpenUI(_shopFormContext);
+ }
+
+ _shopOver = false;
}
public override void OnUpdate(IFsm procedureOwner, float elapseSeconds,
float realElapseSeconds)
{
- Log.Debug("GameStateShop::OnUpdate");
-
if (_shopOver)
{
- _shopForm.Close();
+ _shopFormController?.CloseUI();
_procedureGame.ShopToBattle();
}
}
@@ -170,14 +212,29 @@ namespace Procedure
{
Log.Debug("GameStateShop::OnLeave");
- _shopForm = null;
+ _shopFormContext = null;
+ _shopFormController.CloseUI();
+ _shopFormController = null;
- GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
+ _levelUpFormContext = null;
+ _levelUpFormController.CloseUI();
+ _levelUpFormController = null;
+
+ GameEntry.Event.Unsubscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
+ GameEntry.Event.Unsubscribe(ShopRefreshEventArgs.EventId, ShopRefresh);
+ GameEntry.Event.Unsubscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
+ GameEntry.Event.Unsubscribe(ShopContinueEventArgs.EventId, ShopContinue);
}
public override void OnDestroy(IFsm procedureOwner)
{
_procedureGame = null;
+ _shopFormController = null;
+ _shopFormContext = null;
+
+ _levelUpFormController = null;
+ _levelUpFormContext = null;
+
_drGoods = null;
_propDataTable = null;
_weaponDataTable = null;
@@ -189,16 +246,62 @@ namespace Procedure
#region Event Handlers
- private void OpenUIFormSuccess(object sender, GameEventArgs e)
+ private void ShopRefresh(object sender, EventArgs e)
{
- if (!(e is OpenUIFormSuccessEventArgs args)) return;
- if (!(args.UserData is ShopFormContext data)) return;
- if (data.GameStateShop == this)
- {
- _shopForm = args.UIForm.Logic as ShopForm;
- }
+ if (!(e is ShopRefreshEventArgs args)) return;
+
+ if (_player.Coin < args.Cost) return;
+ _player.Coin -= args.Cost;
+ RefreshGoodsItems();
}
+
+ private void ShopPurchase(object sender, EventArgs e)
+ {
+ if (!(e is ShopPurchaseEventArgs args)) return;
+
+ int index = args.GoodsIndex;
+
+ if (index < 0 && index >= _shopFormContext.GoodsItems.Count)
+ {
+ Log.Warning("GameStateShop::ShopPurchase: Invalid index");
+ return;
+ }
+
+ if (_player.Coin < _shopFormContext.GoodsItems[index].Price) return;
+ _player.Coin -= _shopFormContext.GoodsItems[index].Price;
+ _shopFormContext.GoodsItems.RemoveAt(index);
+ _shopFormController.OpenUI(_shopFormContext);
+ // TODO: OnGoodsPurchased
+ }
+
+ private void ShopContinue(object sender, EventArgs e)
+ {
+ if (!(e is ShopContinueEventArgs)) return;
+
+ _shopOver = true;
+ }
+
+ private void CloseUIFormComplete(object sender, EventArgs e)
+ {
+ if (!(e is CloseUIFormCompleteEventArgs args)) return;
+
+ if (args.UIFormAssetName == nameof(UIFormType.LevelUpForm))
+ {
+
+ if (--_procedureGame.PlayerPendingLevel != 0)
+ {
+ _levelUpFormContext = BuildLevelUpFormContext();
+ _levelUpFormController.OpenUI(_levelUpFormContext);
+ }
+ else
+ {
+ _levelUpFormContext = BuildLevelUpFormContext();
+ _levelUpFormController.OpenUI(_levelUpFormContext);
+ }
+ }
+ }
+
#endregion
}
}
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/Procedure/Game/ProcedureGame.cs b/Assets/GameMain/Scripts/Procedure/Game/ProcedureGame.cs
index dbdbe2b..d9deafa 100644
--- a/Assets/GameMain/Scripts/Procedure/Game/ProcedureGame.cs
+++ b/Assets/GameMain/Scripts/Procedure/Game/ProcedureGame.cs
@@ -36,6 +36,11 @@ namespace Procedure
private Dictionary _gameStates;
public Player Player;
+ ///
+ /// 玩家升级可分配点数
+ ///
+ public int PlayerPendingLevel = 0;
+
private void InitGameState()
{
_gameStates = new Dictionary
@@ -76,8 +81,9 @@ namespace Procedure
_procedureOwner = procedureOwner;
- GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OnOpenUIFormSuccess);
- GameEntry.Event.Subscribe(ShowEntitySuccessEventArgs.EventId, OnShowEntitySuccess);
+ GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
+ GameEntry.Event.Subscribe(ShowEntitySuccessEventArgs.EventId, ShowEntitySuccess);
+ GameEntry.Event.Subscribe(PlayerLevelUpEventArgs.EventId, PlayerLevelUp);
CurrentLevel = 1;
_currentPlayerData = new PlayerData(-1, 1001);
@@ -120,8 +126,9 @@ namespace Procedure
Player = null;
_procedureOwner = null;
- GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OnOpenUIFormSuccess);
- GameEntry.Event.Unsubscribe(ShowEntitySuccessEventArgs.EventId, OnShowEntitySuccess);
+ GameEntry.Event.Unsubscribe(PlayerLevelUpEventArgs.EventId, PlayerLevelUp);
+ GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
+ GameEntry.Event.Unsubscribe(ShowEntitySuccessEventArgs.EventId, ShowEntitySuccess);
base.OnLeave(procedureOwner, isShutdown);
}
@@ -130,7 +137,7 @@ namespace Procedure
#region Event Handler
- private void OnOpenUIFormSuccess(object sender, GameEventArgs e)
+ private void OpenUIFormSuccess(object sender, GameEventArgs e)
{
if (!(e is OpenUIFormSuccessEventArgs args)) return;
@@ -140,7 +147,7 @@ namespace Procedure
}
}
- private void OnShowEntitySuccess(object sender, GameEventArgs e)
+ private void ShowEntitySuccess(object sender, GameEventArgs e)
{
if (!(e is ShowEntitySuccessEventArgs args)) return;
@@ -150,6 +157,13 @@ namespace Procedure
}
}
+ private void PlayerLevelUp(object sender, GameEventArgs e)
+ {
+ if (!(e is PlayerLevelUpEventArgs)) return;
+
+ //PlayerPendingLevel++;
+ }
+
#endregion
}
}
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/UI/GameScene/Context.meta b/Assets/GameMain/Scripts/UI/GameScene/Context.meta
new file mode 100644
index 0000000..e21e354
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/Context.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 32bf4a12bd0ac2847b19bbb76b7c3dd5
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/GameMain/Scripts/UI/GameScene/GoodsItemViewData.cs b/Assets/GameMain/Scripts/UI/GameScene/Context/GoodsItemContext.cs
similarity index 96%
rename from Assets/GameMain/Scripts/UI/GameScene/GoodsItemViewData.cs
rename to Assets/GameMain/Scripts/UI/GameScene/Context/GoodsItemContext.cs
index 4ce793d..b8fb2ac 100644
--- a/Assets/GameMain/Scripts/UI/GameScene/GoodsItemViewData.cs
+++ b/Assets/GameMain/Scripts/UI/GameScene/Context/GoodsItemContext.cs
@@ -5,7 +5,7 @@ using UnityEngine;
namespace UI
{
- public class GoodsItemViewData
+ public class GoodsItemContext
{
public string Title;
public string Type;
diff --git a/Assets/GameMain/Scripts/UI/GameScene/GoodsItemViewData.cs.meta b/Assets/GameMain/Scripts/UI/GameScene/Context/GoodsItemContext.cs.meta
similarity index 100%
rename from Assets/GameMain/Scripts/UI/GameScene/GoodsItemViewData.cs.meta
rename to Assets/GameMain/Scripts/UI/GameScene/Context/GoodsItemContext.cs.meta
diff --git a/Assets/GameMain/Scripts/UI/GameScene/Context/LevelUpFormContext.cs b/Assets/GameMain/Scripts/UI/GameScene/Context/LevelUpFormContext.cs
new file mode 100644
index 0000000..030d90c
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/Context/LevelUpFormContext.cs
@@ -0,0 +1,10 @@
+using System.Collections.Generic;
+
+namespace UI
+{
+ public class LevelUpFormContext
+ {
+ public int Level;
+ public List Props;
+ }
+}
diff --git a/Assets/GameMain/Scripts/UI/GameScene/Context/LevelUpFormContext.cs.meta b/Assets/GameMain/Scripts/UI/GameScene/Context/LevelUpFormContext.cs.meta
new file mode 100644
index 0000000..b9adfad
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/Context/LevelUpFormContext.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1874c6c7ef990c04ba726a2581cd23ce
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/GameMain/Scripts/UI/GameScene/Context/LevelUpPropContext.cs b/Assets/GameMain/Scripts/UI/GameScene/Context/LevelUpPropContext.cs
new file mode 100644
index 0000000..39fabfc
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/Context/LevelUpPropContext.cs
@@ -0,0 +1,14 @@
+using UnityEngine;
+
+namespace UI
+{
+ public class LevelUpPropContext
+ {
+ public int PropId;
+ public string Title;
+ public string Type;
+ public Sprite Icon;
+ public string Description;
+ public string IconAssetName;
+ }
+}
diff --git a/Assets/GameMain/Scripts/UI/GameScene/Context/LevelUpPropContext.cs.meta b/Assets/GameMain/Scripts/UI/GameScene/Context/LevelUpPropContext.cs.meta
new file mode 100644
index 0000000..1eac1c3
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/Context/LevelUpPropContext.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 424ceeba7cae4fa4faaeef9035f31e31
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/GameMain/Scripts/UI/GameScene/Context/ShopFormContext.cs b/Assets/GameMain/Scripts/UI/GameScene/Context/ShopFormContext.cs
new file mode 100644
index 0000000..87a6ab8
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/Context/ShopFormContext.cs
@@ -0,0 +1,12 @@
+using System.Collections.Generic;
+
+namespace UI
+{
+ public class ShopFormContext
+ {
+ public int CurrentLevel;
+ public int RefreshPrice;
+ public int PlayerCoin;
+ public List GoodsItems;
+ }
+}
diff --git a/Assets/GameMain/Scripts/UI/GameScene/Context/ShopFormContext.cs.meta b/Assets/GameMain/Scripts/UI/GameScene/Context/ShopFormContext.cs.meta
new file mode 100644
index 0000000..7db2563
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/Context/ShopFormContext.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: b0ef5183d2f87a54793b86d848e6524a
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/GameMain/Scripts/UI/GameScene/Controller.meta b/Assets/GameMain/Scripts/UI/GameScene/Controller.meta
new file mode 100644
index 0000000..db5f445
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/Controller.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 7d69a94fcc50f4c4ca1dc45e4338560e
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/GameMain/Scripts/UI/GameScene/Controller/IFormController.cs b/Assets/GameMain/Scripts/UI/GameScene/Controller/IFormController.cs
new file mode 100644
index 0000000..792c64c
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/Controller/IFormController.cs
@@ -0,0 +1,8 @@
+namespace UI
+{
+ public interface IFormController
+ {
+ int? OpenUI(TContext context);
+ void CloseUI();
+ }
+}
diff --git a/Assets/GameMain/Scripts/UI/GameScene/Controller/IFormController.cs.meta b/Assets/GameMain/Scripts/UI/GameScene/Controller/IFormController.cs.meta
new file mode 100644
index 0000000..2d7531c
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/Controller/IFormController.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 692b282b1ecbf5a44839d5bf4a03a937
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/GameMain/Scripts/UI/GameScene/Controller/LevelUpFormController.cs b/Assets/GameMain/Scripts/UI/GameScene/Controller/LevelUpFormController.cs
new file mode 100644
index 0000000..03ce768
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/Controller/LevelUpFormController.cs
@@ -0,0 +1,154 @@
+using System.Collections.Generic;
+using CustomEvent;
+using DataTable;
+using Definition.Enum;
+using GameFramework.DataTable;
+using GameFramework.Event;
+using UnityEngine;
+using UnityGameFramework.Runtime;
+
+namespace UI
+{
+ public class LevelUpFormController : IFormController
+ {
+ private int _currentLevel = 1;
+ private int _buildCount = 4;
+
+ private bool _pendingRefresh;
+
+ private int? _levelUpFormSerialId;
+ private LevelUpForm _levelUpForm;
+ private LevelUpFormContext _context;
+
+ public LevelUpFormController()
+ {
+ GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
+ GameEntry.Event.Subscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
+ }
+
+ ~LevelUpFormController()
+ {
+ GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
+ GameEntry.Event.Unsubscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
+ }
+
+ public void ConfigureBuild(int level, int count = 4)
+ {
+ _currentLevel = Mathf.Max(1, level);
+ _buildCount = Mathf.Max(0, count);
+ }
+
+ public int? OpenUI(LevelUpFormContext context)
+ {
+ if (context == null)
+ {
+ Log.Warning("LevelUpFormController.OpenUI() context is null.");
+ return null;
+ }
+
+ _context = context;
+
+ if (_levelUpForm != null)
+ {
+ _levelUpForm.RefreshUI(_context);
+ return _levelUpFormSerialId;
+ }
+
+ CloseUI();
+ _pendingRefresh = true;
+ _levelUpFormSerialId = GameEntry.UI.OpenUIForm(UIFormType.LevelUpForm, context);
+ return _levelUpFormSerialId;
+ }
+
+ public void CloseUI()
+ {
+ _pendingRefresh = false;
+
+ if (_levelUpFormSerialId.HasValue)
+ {
+ GameEntry.UI.CloseUIForm(_levelUpFormSerialId.Value);
+ return;
+ }
+
+ if (_levelUpForm != null)
+ {
+ _levelUpForm.Close();
+ }
+ }
+
+ public void Reset()
+ {
+ _context = null;
+ _levelUpForm = null;
+ _levelUpFormSerialId = null;
+ _pendingRefresh = false;
+ }
+
+ public void OnSelectProp(int propId)
+ {
+
+ }
+
+ private void TryRefreshUI()
+ {
+ if (_context == null)
+ {
+ return;
+ }
+
+ if (_levelUpForm == null)
+ {
+ _pendingRefresh = true;
+ return;
+ }
+
+ _levelUpForm.RefreshUI(_context);
+ _pendingRefresh = false;
+ }
+
+ #region Event Handlers
+
+ private void OpenUIFormSuccess(object sender, GameEventArgs e)
+ {
+ if (!(e is OpenUIFormSuccessEventArgs args)) return;
+
+ if (!_levelUpFormSerialId.HasValue) return;
+
+ if (args.UIForm == null || args.UIForm.SerialId != _levelUpFormSerialId.Value || args.UserData != _context)
+ {
+ return;
+ }
+
+ _levelUpForm = args.UIForm.Logic as LevelUpForm;
+
+ if (_levelUpForm == null)
+ {
+ Log.Warning("LevelUpFormController open success but form logic is invalid.");
+ return;
+ }
+
+ if (_pendingRefresh)
+ {
+ TryRefreshUI();
+ }
+ }
+
+ private void CloseUIFormComplete(object sender, GameEventArgs e)
+ {
+ if (!(e is CloseUIFormCompleteEventArgs args))
+ {
+ return;
+ }
+
+ if (args.SerialId != _levelUpFormSerialId)
+ {
+ return;
+ }
+
+ _levelUpForm = null;
+ _levelUpFormSerialId = null;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/UI/GameScene/Controller/LevelUpFormController.cs.meta b/Assets/GameMain/Scripts/UI/GameScene/Controller/LevelUpFormController.cs.meta
new file mode 100644
index 0000000..4def6f0
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/Controller/LevelUpFormController.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 89d85bbc4f7cf8c438c7ee693eaf67cf
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/GameMain/Scripts/UI/GameScene/Controller/ShopFormController.cs b/Assets/GameMain/Scripts/UI/GameScene/Controller/ShopFormController.cs
new file mode 100644
index 0000000..5a680f4
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/Controller/ShopFormController.cs
@@ -0,0 +1,133 @@
+using Definition.Enum;
+using GameFramework.Event;
+using UnityGameFramework.Runtime;
+
+namespace UI
+{
+ public class ShopFormController : IFormController
+ {
+ #region Property
+
+ private bool _pendingRefresh;
+
+ private int? _shopFormSerialId;
+
+ private ShopForm _shopForm;
+
+ private ShopFormContext _context;
+
+ #endregion
+
+ public ShopFormController()
+ {
+ GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
+ GameEntry.Event.Subscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
+ }
+
+ ~ShopFormController()
+ {
+ GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormSuccess);
+ GameEntry.Event.Unsubscribe(CloseUIFormCompleteEventArgs.EventId, CloseUIFormComplete);
+ }
+
+ public int? OpenUI(ShopFormContext context)
+ {
+ if (context == null)
+ {
+ Log.Warning("ShopFormController.OpenUI() context is null.");
+ return null;
+ }
+
+ _context = context;
+
+ if (_shopForm != null)
+ {
+ _shopForm.RefreshUI(_context);
+ return _shopFormSerialId;
+ }
+
+ CloseUI();
+ _pendingRefresh = true;
+ _shopFormSerialId = GameEntry.UI.OpenUIForm(UIFormType.ShopForm, context);
+ return _shopFormSerialId;
+ }
+
+ public void CloseUI()
+ {
+ _pendingRefresh = false;
+
+ if (_shopFormSerialId.HasValue)
+ {
+ GameEntry.UI.CloseUIForm(_shopFormSerialId.Value);
+ return;
+ }
+
+ if (_shopForm != null)
+ {
+ _shopForm.Close();
+ }
+ }
+
+ private void TryRefreshUI()
+ {
+ if (_context == null)
+ {
+ return;
+ }
+
+ if (_shopForm == null)
+ {
+ _pendingRefresh = true;
+ return;
+ }
+
+ _shopForm.RefreshUI(_context);
+ _pendingRefresh = false;
+ }
+
+ #region Event Handlers
+
+ private void OpenUIFormSuccess(object sender, GameEventArgs e)
+ {
+ if (!(e is OpenUIFormSuccessEventArgs args)) return;
+
+ if (!_shopFormSerialId.HasValue) return;
+
+ if (args.UIForm == null || args.UIForm.SerialId != _shopFormSerialId.Value || args.UserData != _context)
+ {
+ return;
+ }
+
+ _shopForm = args.UIForm.Logic as ShopForm;
+
+ if (_shopForm == null)
+ {
+ Log.Warning("ShopFormController open success but form logic is invalid.");
+ return;
+ }
+
+ if (_pendingRefresh)
+ {
+ TryRefreshUI();
+ }
+ }
+
+ private void CloseUIFormComplete(object sender, GameEventArgs e)
+ {
+ if (!(e is CloseUIFormCompleteEventArgs args))
+ {
+ return;
+ }
+
+ if (args.SerialId != _shopFormSerialId)
+ {
+ return;
+ }
+
+ _shopForm = null;
+ _shopFormSerialId = null;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/UI/GameScene/Controller/ShopFormController.cs.meta b/Assets/GameMain/Scripts/UI/GameScene/Controller/ShopFormController.cs.meta
new file mode 100644
index 0000000..81dea04
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/Controller/ShopFormController.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: be57ace1e7b07be429632ea49bcab6c5
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/GameMain/Scripts/UI/GameScene/View.meta b/Assets/GameMain/Scripts/UI/GameScene/View.meta
new file mode 100644
index 0000000..61b7c7f
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/View.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 7af0b9398035e254cb6de37a6c301552
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/GameMain/Scripts/UI/GameScene/GoodsItem.cs b/Assets/GameMain/Scripts/UI/GameScene/View/GoodsItem.cs
similarity index 79%
rename from Assets/GameMain/Scripts/UI/GameScene/GoodsItem.cs
rename to Assets/GameMain/Scripts/UI/GameScene/View/GoodsItem.cs
index 4292e35..b4b65a7 100644
--- a/Assets/GameMain/Scripts/UI/GameScene/GoodsItem.cs
+++ b/Assets/GameMain/Scripts/UI/GameScene/View/GoodsItem.cs
@@ -1,4 +1,3 @@
-using Procedure;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
@@ -8,20 +7,21 @@ namespace UI
public class GoodsItem : MonoBehaviour
{
[SerializeField] private Image _iconImage;
+
[SerializeField] private TMP_Text _titleText;
+
[SerializeField] private TMP_Text _typeText;
+
[SerializeField] private TMP_Text _descriptionText;
+
[SerializeField] private TMP_Text _costText;
+
[SerializeField] private CommonButton _purchaseButton;
- private int _cost;
- private GameStateShop _stateShop;
-
#region Init
- public void Init(GameStateShop stateShop, GoodsItemViewData data)
+ public void Init(GoodsItemContext data)
{
- _stateShop = stateShop;
_iconImage.sprite = data.Icon;
_titleText.text = data.Title;
_typeText.text = data.Type;
@@ -31,4 +31,4 @@ namespace UI
#endregion
}
-}
\ No newline at end of file
+}
diff --git a/Assets/GameMain/Scripts/UI/GameScene/GoodsItem.cs.meta b/Assets/GameMain/Scripts/UI/GameScene/View/GoodsItem.cs.meta
similarity index 100%
rename from Assets/GameMain/Scripts/UI/GameScene/GoodsItem.cs.meta
rename to Assets/GameMain/Scripts/UI/GameScene/View/GoodsItem.cs.meta
diff --git a/Assets/GameMain/Scripts/UI/GameScene/HudForm.cs b/Assets/GameMain/Scripts/UI/GameScene/View/HudForm.cs
similarity index 100%
rename from Assets/GameMain/Scripts/UI/GameScene/HudForm.cs
rename to Assets/GameMain/Scripts/UI/GameScene/View/HudForm.cs
diff --git a/Assets/GameMain/Scripts/UI/GameScene/HudForm.cs.meta b/Assets/GameMain/Scripts/UI/GameScene/View/HudForm.cs.meta
similarity index 100%
rename from Assets/GameMain/Scripts/UI/GameScene/HudForm.cs.meta
rename to Assets/GameMain/Scripts/UI/GameScene/View/HudForm.cs.meta
diff --git a/Assets/GameMain/Scripts/UI/GameScene/View/LevelUpForm.cs b/Assets/GameMain/Scripts/UI/GameScene/View/LevelUpForm.cs
new file mode 100644
index 0000000..f5656a3
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/View/LevelUpForm.cs
@@ -0,0 +1,66 @@
+using CustomEvent;
+using TMPro;
+using UnityEngine;
+using UnityGameFramework.Runtime;
+
+namespace UI
+{
+ public class LevelUpForm : UGuiForm
+ {
+ [SerializeField] private TMP_Text _titleText;
+
+ [SerializeField] private LevelUpPropItem[] _propItems;
+
+ private LevelUpFormContext _context;
+
+ public void RefreshUI(LevelUpFormContext context)
+ {
+ _context = context;
+
+ if (_titleText != null)
+ {
+ _titleText.text = $"Level Up (Lv.{_context.Level})";
+ }
+
+ foreach (var propItem in _propItems)
+ {
+ propItem.gameObject.SetActive(false);
+ }
+
+ if (_context.Props == null) return;
+ for (int i = 0; i < _propItems.Length; i++)
+ {
+ _propItems[i].gameObject.SetActive(true);
+ _propItems[i].Init(_context.Props[i]);
+ }
+ }
+
+ #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
+
+ private void OnSelectProp(int index)
+ {
+ GameEntry.Event.Fire(this, LevelUpPropSelectedEventArgs.Create(index));
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/UI/GameScene/View/LevelUpForm.cs.meta b/Assets/GameMain/Scripts/UI/GameScene/View/LevelUpForm.cs.meta
new file mode 100644
index 0000000..657ba65
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/View/LevelUpForm.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 73f52c8a6d8b8ec42ad8cd3c00e0254d
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/GameMain/Scripts/UI/GameScene/View/LevelUpPropItem.cs b/Assets/GameMain/Scripts/UI/GameScene/View/LevelUpPropItem.cs
new file mode 100644
index 0000000..50d6997
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/View/LevelUpPropItem.cs
@@ -0,0 +1,50 @@
+using System;
+using TMPro;
+using UnityEngine;
+using UnityEngine.Events;
+using UnityEngine.UI;
+using UnityGameFramework.Runtime;
+
+namespace UI
+{
+ public class LevelUpPropItem : MonoBehaviour
+ {
+ [SerializeField] private Image _iconImage;
+
+ [SerializeField] private TMP_Text _titleText;
+
+ [SerializeField] private TMP_Text _typeText;
+
+ [SerializeField] private TMP_Text _descriptionText;
+
+ private LevelUpPropContext _context;
+
+
+ public void Init(LevelUpPropContext context)
+ {
+ if (context == null)
+ {
+ Log.Error("LevelUpPropContext context is invalid.");
+ return;
+ }
+
+ _context = context;
+
+ if (_titleText != null) _titleText.text = context.Title;
+ if (_typeText != null) _typeText.text = context.Type;
+ if (_descriptionText != null) _descriptionText.text = context.Description;
+ if (_iconImage != null) _iconImage.sprite = context.Icon;
+
+ LoadIcon(_context.IconAssetName);
+ }
+
+ private void LoadIcon(string iconAssetName)
+ {
+ if (_iconImage == null) return;
+
+ if (string.IsNullOrEmpty(iconAssetName)) return;
+
+ GameEntry.SpriteCache.GetSprite(iconAssetName, sprite => _iconImage.sprite = sprite);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/UI/GameScene/View/LevelUpPropItem.cs.meta b/Assets/GameMain/Scripts/UI/GameScene/View/LevelUpPropItem.cs.meta
new file mode 100644
index 0000000..f79c2e6
--- /dev/null
+++ b/Assets/GameMain/Scripts/UI/GameScene/View/LevelUpPropItem.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 237d64392d274c14f9f5c81b54122a93
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/GameMain/Scripts/UI/GameScene/ShopForm.cs b/Assets/GameMain/Scripts/UI/GameScene/View/ShopForm.cs
similarity index 55%
rename from Assets/GameMain/Scripts/UI/GameScene/ShopForm.cs
rename to Assets/GameMain/Scripts/UI/GameScene/View/ShopForm.cs
index 54555f6..75c7a6a 100644
--- a/Assets/GameMain/Scripts/UI/GameScene/ShopForm.cs
+++ b/Assets/GameMain/Scripts/UI/GameScene/View/ShopForm.cs
@@ -1,6 +1,5 @@
using CustomEvent;
using GameFramework.Event;
-using Procedure;
using TMPro;
using UnityEngine;
@@ -8,57 +7,61 @@ 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 = 0;
+ private int _currentCoin;
[SerializeField] private GoodsItem[] _goodsItems;
- private GameStateShop _stateShop;
+ private ShopFormContext _context;
- public void UpdateForm(ShopFormContext context)
+ #endregion
+
+
+ public void RefreshUI(ShopFormContext context)
{
- _stateShop = context.GameStateShop;
+ _context = context;
- _titleText.text = $"商店(第{context.CurrentLevel}波)";
- _continueButtonText.text = $"继续(第{context.CurrentLevel + 1}波)";
+ _titleText.text = $"商店 (Lv.{context.CurrentLevel})";
+ _continueButtonText.text = $"继续 (Lv.{context.CurrentLevel + 1})";
_refreshPriceText.text = $"-{context.RefreshPrice}";
- _playerCoinText.text = $"{context.PlayerCoin}";
+ _playerCoinText.text = context.PlayerCoin.ToString();
- for (int i = 0; i < _goodsItems.Length; i++)
+ foreach (var item in _goodsItems)
{
- if (i < context.GoodsItems.Count)
- {
- _goodsItems[i].Init(context.GameStateShop, context.GoodsItems[i]);
- _goodsItems[i].gameObject.SetActive(true);
- }
- else
- {
- _goodsItems[i].gameObject.SetActive(false);
- }
+ item.gameObject.SetActive(false);
+ }
+
+ if (_context.GoodsItems == null) return;
+ for (int i = 0; i < _context.GoodsItems.Count; i++)
+ {
+ _goodsItems[i].Init(context.GoodsItems[i]);
+ _goodsItems[i].gameObject.SetActive(true);
}
}
-
+
#region ButtonClick
public void OnContinueButtonClick()
{
- _stateShop.ShopOver();
+ GameEntry.Event.Fire(this, ShopContinueEventArgs.Create());
}
public void OnPurchaseButtonClick(int index)
{
- _stateShop.PurchaseGoods(index);
+ GameEntry.Event.Fire(this, ShopPurchaseEventArgs.Create(index));
}
public void OnRefreshButtonClick()
{
- _stateShop.RefreshGoods();
+ GameEntry.Event.Fire(this, ShopRefreshEventArgs.Create(_context.RefreshPrice));
}
#endregion
@@ -70,32 +73,38 @@ namespace UI
base.OnOpen(userData);
GameEntry.Event.Subscribe(PlayerCoinChangeEventArgs.EventId, OnPlayerCoinChange);
-
- ShopFormContext context = (ShopFormContext)userData;
- UpdateForm(context);
+
+ if (userData is ShopFormContext context)
+ {
+ RefreshUI(context);
+ return;
+ }
+
+ UnityGameFramework.Runtime.Log.Warning("ShopForm requires ShopFormContext as userData.");
}
protected override void OnClose(bool isShutdown, object userData)
{
- _stateShop = null;
+ _context = null;
GameEntry.Event.Unsubscribe(PlayerCoinChangeEventArgs.EventId, OnPlayerCoinChange);
-
+
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 = _currentCoin.ToString();
}
+
#endregion
}
}
\ No newline at end of file
diff --git a/Assets/GameMain/Scripts/UI/GameScene/ShopForm.cs.meta b/Assets/GameMain/Scripts/UI/GameScene/View/ShopForm.cs.meta
similarity index 100%
rename from Assets/GameMain/Scripts/UI/GameScene/ShopForm.cs.meta
rename to Assets/GameMain/Scripts/UI/GameScene/View/ShopForm.cs.meta
diff --git a/Assets/GameMain/UI/UIForms/ShopForm.prefab b/Assets/GameMain/UI/UIForms/ShopForm.prefab
index f80828c..f588e52 100644
--- a/Assets/GameMain/UI/UIForms/ShopForm.prefab
+++ b/Assets/GameMain/UI/UIForms/ShopForm.prefab
@@ -3688,7 +3688,7 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchorMax.y
- value: 1
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -3698,7 +3698,7 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchorMin.y
- value: 1
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -3748,12 +3748,12 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchoredPosition.x
- value: 725
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchoredPosition.y
- value: -350
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -3859,7 +3859,7 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchorMax.y
- value: 1
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -3869,7 +3869,7 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchorMin.y
- value: 1
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -3919,12 +3919,12 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchoredPosition.x
- value: 2725
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchoredPosition.y
- value: -350
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -4414,7 +4414,7 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchorMax.y
- value: 1
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -4424,7 +4424,7 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchorMin.y
- value: 1
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -4474,12 +4474,12 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchoredPosition.x
- value: 1225
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchoredPosition.y
- value: -350
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -4585,7 +4585,7 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchorMax.y
- value: 1
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -4595,7 +4595,7 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchorMin.y
- value: 1
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -4645,12 +4645,12 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchoredPosition.x
- value: 1725
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchoredPosition.y
- value: -350
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -5122,7 +5122,7 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchorMax.y
- value: 1
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -5132,7 +5132,7 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchorMin.y
- value: 1
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -5182,12 +5182,12 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchoredPosition.x
- value: 2225
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchoredPosition.y
- value: -350
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -5288,7 +5288,7 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchorMax.y
- value: 1
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -5298,7 +5298,7 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchorMin.y
- value: 1
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
@@ -5348,12 +5348,12 @@ PrefabInstance:
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchoredPosition.x
- value: 225
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
propertyPath: m_AnchoredPosition.y
- value: -350
+ value: 0
objectReference: {fileID: 0}
- target: {fileID: 1568602919960830097, guid: 9f5bba6d2f5c95049a59fcb56df2d38f,
type: 3}
diff --git a/Assets/StarForce Launcher.unity b/Assets/Launcher.unity
similarity index 100%
rename from Assets/StarForce Launcher.unity
rename to Assets/Launcher.unity
diff --git a/Assets/StarForce Launcher.unity.meta b/Assets/Launcher.unity.meta
similarity index 100%
rename from Assets/StarForce Launcher.unity.meta
rename to Assets/Launcher.unity.meta
diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset
index f7aafdf..3883138 100644
--- a/ProjectSettings/EditorBuildSettings.asset
+++ b/ProjectSettings/EditorBuildSettings.asset
@@ -6,7 +6,7 @@ EditorBuildSettings:
serializedVersion: 2
m_Scenes:
- enabled: 1
- path: Assets/StarForce Launcher.unity
+ path: Assets/Launcher.unity
guid: 9d2d51bf0fc3dfc42908e3a7a64f4feb
- enabled: 1
path: Assets/GameMain/Scenes/Main.unity
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..fd1fdc6
--- /dev/null
+++ b/README.md
@@ -0,0 +1,100 @@
+# VampireLike
+
+`VampireLike` 是一个基于 **Unity 2022.3 LTS** 的 2D/3D(按当前资源配置)动作生存类项目,使用 `GameMain + GameFramework` 分层组织代码与资源。
+
+## 开发环境
+
+- Unity Editor: `2022.3.62f3c1`
+- .NET/C#: Unity 默认编译链
+- 推荐 IDE:
+ - Rider
+ - Visual Studio
+ - VS Code
+
+## 快速开始
+
+1. 使用 Unity Hub 打开项目根目录。
+2. 确认 Unity 版本为 `2022.3.62f3c1`(或兼容的 2022.3 LTS 版本)。
+3. 进入后等待包与资源导入完成。
+4. 在 Editor 中打开场景并运行:
+ - `Assets/GameMain/Scenes/Menu.unity`
+ - `Assets/GameMain/Scenes/Main.unity`
+ - `Assets/GameMain/Scenes/Game.unity`
+
+可选命令行启动(请替换为本机 Unity 路径):
+
+```powershell
+Unity -projectPath .
+```
+
+## 项目结构
+
+主要目录说明:
+
+- `Assets/GameMain/`: 游戏业务代码、场景和内容资源。
+- `Assets/GameFramework/`: 通用框架与编辑器扩展。
+- `Assets/Plugins/`: 第三方插件(如 DOTween)。
+- `Assets/Resources/`: 运行时通过 Resources 加载的资源。
+- `Assets/StreamingAssets/`: 原样打包到客户端的数据。
+- `Json/`、`数据表/`: 配置与数据表。
+- `Tools/`: 本地工具脚本和处理流程。
+
+请避免直接修改自动生成目录:
+
+- `Library/`
+- `Temp/`
+- `Logs/`
+- `obj/`
+
+## 代码规范
+
+- C# 使用 4 空格缩进。
+- 大括号与声明同行(K&R 风格)。
+- 单文件单主类型,文件名与类型名一致。
+- 公有类型/成员使用 `PascalCase`。
+- 局部变量/参数使用 `camelCase`。
+- 需要在 Inspector 暴露的私有字段使用 `[SerializeField]`。
+
+## 测试
+
+项目已包含 `com.unity.test-framework`。
+
+建议约定:
+
+- 测试目录:`Assets/Tests/` 或 `Assets//Tests/`
+- 测试文件命名:`*Tests.cs`
+- 使用 NUnit `[Test]` 编写用例
+- 通过 Unity Test Runner 运行:`Window > General > Test Runner`
+
+## 常用依赖(Packages)
+
+当前项目使用的关键包包括:
+
+- `com.unity.inputsystem`
+- `com.unity.render-pipelines.universal`
+- `com.unity.textmeshpro`
+- `com.unity.ugui`
+- `com.unity.nuget.newtonsoft-json`
+- `com.unity.test-framework`
+
+完整依赖见 `Packages/manifest.json`。
+
+## 协作与提交流程(建议)
+
+- 提交信息使用简短祈使句,例如:`UI: Fix shop item refresh logic`
+- PR 建议包含:
+ - 变更摘要
+ - 测试说明
+ - 关联任务/Issue
+ - UI 改动截图或录屏
+
+## 配置注意事项
+
+- 修改依赖时,请同时关注:
+ - `Packages/manifest.json`
+ - `ProjectSettings/`
+- 大体积二进制资源需与对应 `.meta` 一并提交。
+
+## 许可证
+
+当前仓库未提供许可证文件。若需开源或外发,请先补充 `LICENSE`。