添加 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()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18502a1681d745e46817f0d75a73a7e3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using SepCore.Definition;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public class StatRawData
|
||||
{
|
||||
public Dictionary<StatType, float> Values { get; } = new Dictionary<StatType, float>();
|
||||
|
||||
public float this[StatType statType]
|
||||
{
|
||||
get => GetValue(statType);
|
||||
set => SetValue(statType, value);
|
||||
}
|
||||
|
||||
public float GetValue(StatType statType)
|
||||
{
|
||||
return Values.TryGetValue(statType, out float val) ? val : 0f;
|
||||
}
|
||||
|
||||
public void SetValue(StatType statType, float value)
|
||||
{
|
||||
Values[statType] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4677fc5d940aebd40a5a55cdb8b29628
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user