添加 ShopForm 下的 StatForm,展示玩家属性
This commit is contained in:
@@ -4,5 +4,6 @@ namespace SepCore.UI
|
||||
{
|
||||
public int GoodsIndex;
|
||||
public DisplayItemRawData DisplayItem;
|
||||
public StatRawData StatRawData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,5 +14,6 @@ namespace SepCore.UI
|
||||
public int PropMaxCount = -1;
|
||||
public IReadOnlyList<WeaponBase> WeaponItems;
|
||||
public int WeaponMaxCount = -1;
|
||||
public StatRawData StatRawData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.Components;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using SepCore.CustomUtility;
|
||||
@@ -47,10 +48,34 @@ namespace SepCore.UI
|
||||
PropItems = _player.Props,
|
||||
PropMaxCount = GameEntry.Luban.Global.PropMaxCount,
|
||||
WeaponItems = _player.Weapons,
|
||||
WeaponMaxCount = _player.WeaponCapacity
|
||||
WeaponMaxCount = _player.WeaponCapacity,
|
||||
StatRawData = CreateStatRawData()
|
||||
};
|
||||
}
|
||||
|
||||
public StatRawData CreateStatRawData()
|
||||
{
|
||||
var rawData = new StatRawData();
|
||||
StatComponent statComponent = _player.StatComponent;
|
||||
if (statComponent == null)
|
||||
{
|
||||
Log.Error("ShopUseCase.CreateStatRawData: Player StatComponent is null.");
|
||||
return rawData;
|
||||
}
|
||||
|
||||
foreach (StatType statType in (StatType[])Enum.GetValues(typeof(StatType)))
|
||||
{
|
||||
if (statType == StatType.None)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
rawData.SetValue(statType, statComponent.GetStatValue(statType));
|
||||
}
|
||||
|
||||
return rawData;
|
||||
}
|
||||
|
||||
public ShopRefreshResult TryRefresh(int cost)
|
||||
{
|
||||
if (_player.Coin < cost)
|
||||
@@ -102,7 +127,8 @@ namespace SepCore.UI
|
||||
return new ShopPurchaseResult
|
||||
{
|
||||
GoodsIndex = goodsIndex,
|
||||
DisplayItem = displayItem
|
||||
DisplayItem = displayItem,
|
||||
StatRawData = CreateStatRawData()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user