迁移 Player/ProcedureGame/ShopUseCase 里的实体方法调用风格
- Player/ShopUseCase:调整了 Weapon 实体的打开方式 - ProcedureGame:调整初始化时的 Hud 和 Player 的初始化写法,流程更清楚
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using SepCore.CustomUtility;
|
||||
using SepCore.Entity.Weapon;
|
||||
using GameFramework.DataTable;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
@@ -107,7 +109,7 @@ namespace SepCore.UI
|
||||
};
|
||||
}
|
||||
|
||||
public ShopPurchaseResult TryPurchase(int goodsIndex)
|
||||
public async UniTask<ShopPurchaseResult> TryPurchaseAsync(int goodsIndex)
|
||||
{
|
||||
if (goodsIndex < 0 || goodsIndex >= _selections.Count)
|
||||
{
|
||||
@@ -128,7 +130,7 @@ namespace SepCore.UI
|
||||
return null;
|
||||
}
|
||||
|
||||
DisplayItemRawData displayItem = ApplyGoodsPurchase(selection);
|
||||
DisplayItemRawData displayItem = await ApplyGoodsPurchaseAsync(selection);
|
||||
if (displayItem == null)
|
||||
{
|
||||
return null;
|
||||
@@ -318,7 +320,7 @@ namespace SepCore.UI
|
||||
return Mathf.Max(1, finalPrice);
|
||||
}
|
||||
|
||||
private DisplayItemRawData ApplyGoodsPurchase(ShopGoodsSelection goods)
|
||||
private async UniTask<DisplayItemRawData> ApplyGoodsPurchaseAsync(ShopGoodsSelection goods)
|
||||
{
|
||||
if (goods == null || Player == null)
|
||||
{
|
||||
@@ -362,7 +364,13 @@ namespace SepCore.UI
|
||||
return null;
|
||||
}
|
||||
|
||||
GameEntry.Entity.ShowWeapon(weaponData);
|
||||
WeaponBase weapon = await Player.AddWeaponAsync(weaponData);
|
||||
if (weapon == null)
|
||||
{
|
||||
Log.Warning(
|
||||
$"ShopFormUseCase::ApplyGoodsPurchase: Show weapon failed, weapon type id = {goods.GoodsTypeId}");
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DisplayItemRawData
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user