调整部分数据表配置,优化 SpriteCache 功能
This commit is contained in:
@@ -143,7 +143,7 @@ namespace SepCore.UI
|
||||
return;
|
||||
}
|
||||
|
||||
_player.AddProp(new PropItem(reward.Modifiers, reward.Rarity, reward.Title, reward.IconAssetName));
|
||||
_player.AddProp(new PropItem(reward.Modifiers, reward.Rarity, reward.Title, reward.Sprite));
|
||||
}
|
||||
|
||||
private void BuildRewardRarityPools()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity.Weapon;
|
||||
using SepCore.Entity;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@ using Cysharp.Threading.Tasks;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using SepCore.CustomUtility;
|
||||
using SepCore.Entity.Weapon;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
using Random = UnityEngine.Random;
|
||||
@@ -45,7 +44,8 @@ namespace SepCore.UI
|
||||
private sealed class ShopGoodsSelection
|
||||
{
|
||||
public GoodsType GoodsType;
|
||||
public int GoodsTypeId;
|
||||
public int PropId;
|
||||
public WeaponType WeaponType;
|
||||
public int Price;
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ namespace SepCore.UI
|
||||
|
||||
if (goodsConfig.GoodsType == GoodsType.Prop)
|
||||
{
|
||||
PropConfig propConfig = GameEntry.Luban.Get<PropConfig>(goodsConfig.GoodsTypeId);
|
||||
PropConfig propConfig = GameEntry.Luban.Get<PropConfig>(goodsConfig.PropId);
|
||||
int basePrice = propConfig.Price;
|
||||
float randomPercent = 0.05f;
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace SepCore.UI
|
||||
}
|
||||
else if (goodsConfig.GoodsType == GoodsType.Weapon)
|
||||
{
|
||||
WeaponConfig weaponConfig = GameEntry.Luban.Get<WeaponConfig>(goodsConfig.GoodsTypeId);
|
||||
WeaponConfig weaponConfig = GameEntry.Luban.Get<WeaponConfig>((int)goodsConfig.WeaponType);
|
||||
int basePrice = weaponConfig.Price;
|
||||
float randomPercent = 0.05f;
|
||||
|
||||
@@ -206,7 +206,8 @@ namespace SepCore.UI
|
||||
_selections.Add(new ShopGoodsSelection
|
||||
{
|
||||
GoodsType = goodsConfig.GoodsType,
|
||||
GoodsTypeId = goodsConfig.GoodsTypeId,
|
||||
PropId = goodsConfig.PropId,
|
||||
WeaponType = goodsConfig.WeaponType,
|
||||
Price = price
|
||||
});
|
||||
|
||||
@@ -269,14 +270,14 @@ namespace SepCore.UI
|
||||
|
||||
if (goods.GoodsType == GoodsType.Prop)
|
||||
{
|
||||
PropConfig propConfig = GameEntry.Luban.Get<PropConfig>(goods.GoodsTypeId);
|
||||
PropConfig propConfig = GameEntry.Luban.Get<PropConfig>(goods.PropId);
|
||||
rarity = propConfig.Rarity;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (goods.GoodsType == GoodsType.Weapon)
|
||||
{
|
||||
WeaponConfig weaponConfig = GameEntry.Luban.Get<WeaponConfig>(goods.GoodsTypeId);
|
||||
WeaponConfig weaponConfig = GameEntry.Luban.Get<WeaponConfig>((int)goods.WeaponType);
|
||||
rarity = weaponConfig.Rarity;
|
||||
return true;
|
||||
}
|
||||
@@ -308,7 +309,7 @@ namespace SepCore.UI
|
||||
|
||||
if (goods.GoodsType == GoodsType.Prop)
|
||||
{
|
||||
PropConfig propConfig = GameEntry.Luban.Get<PropConfig>(goods.GoodsTypeId);
|
||||
PropConfig propConfig = GameEntry.Luban.Get<PropConfig>(goods.PropId);
|
||||
if (propConfig.Modifiers == null || propConfig.Modifiers.Count == 0)
|
||||
{
|
||||
Log.Warning("ShopFormUseCase::ApplyGoodsPurchase: Prop modifiers are empty");
|
||||
@@ -318,7 +319,7 @@ namespace SepCore.UI
|
||||
Player.AddProp(new PropItem(propConfig));
|
||||
return new DisplayItemRawData
|
||||
{
|
||||
IconAssetName = propConfig.IconAssetName,
|
||||
IconAssetName = propConfig.Sprite,
|
||||
Rarity = propConfig.Rarity,
|
||||
IsWeapon = false
|
||||
};
|
||||
@@ -332,7 +333,7 @@ namespace SepCore.UI
|
||||
return null;
|
||||
}
|
||||
|
||||
WeaponConfig weaponConfig = GameEntry.Luban.Get<WeaponConfig>(goods.GoodsTypeId);
|
||||
WeaponConfig weaponConfig = GameEntry.Luban.Get<WeaponConfig>((int)goods.WeaponType);
|
||||
int id = GameEntry.Entity.NextId();
|
||||
var weaponData = EntityDataFactory.Create(id, weaponConfig, Player.Id, CampType.Player);
|
||||
|
||||
@@ -340,13 +341,13 @@ namespace SepCore.UI
|
||||
if (weapon == null)
|
||||
{
|
||||
Log.Warning(
|
||||
$"ShopFormUseCase::ApplyGoodsPurchase: Show weapon failed, weapon type id = {goods.GoodsTypeId}");
|
||||
$"ShopFormUseCase::ApplyGoodsPurchase: Show weapon failed, weapon type id = {goods.WeaponType}");
|
||||
return null;
|
||||
}
|
||||
|
||||
return new DisplayItemRawData
|
||||
{
|
||||
IconAssetName = weaponConfig.IconAssetName,
|
||||
IconAssetName = weaponConfig.Sprite,
|
||||
Rarity = weaponConfig.Rarity,
|
||||
IsWeapon = true
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ namespace SepCore.UI
|
||||
{
|
||||
public class RoleItemRawData
|
||||
{
|
||||
public int RoleId;
|
||||
public string RoleName;
|
||||
public string IconName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,7 @@ namespace SepCore.UI
|
||||
{
|
||||
public class RolePropertyAreaRawData
|
||||
{
|
||||
public int RoleId;
|
||||
public string RoleName;
|
||||
public string Name;
|
||||
public List<modifier> InitialProperties;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace SepCore.UI
|
||||
{
|
||||
private readonly IProcedureMenu _procedureMenu;
|
||||
|
||||
public int SelectedRoleId { get; private set; }
|
||||
public string SelectedRoleName { get; private set; }
|
||||
|
||||
public SelectRoleUseCase(IProcedureMenu procedureMenu)
|
||||
{
|
||||
@@ -19,40 +19,36 @@ namespace SepCore.UI
|
||||
|
||||
public SelectRoleRawData CreateModel()
|
||||
{
|
||||
return BuildModel(0);
|
||||
return BuildModel(null);
|
||||
}
|
||||
|
||||
public SelectRoleRawData SelectRole(int roleId)
|
||||
public SelectRoleRawData SelectRole(string roleName)
|
||||
{
|
||||
SelectedRoleId = roleId;
|
||||
return BuildModel(roleId);
|
||||
SelectedRoleName = roleName;
|
||||
return BuildModel(roleName);
|
||||
}
|
||||
|
||||
public SelectRoleRawData ClearSelection()
|
||||
{
|
||||
SelectedRoleId = 0;
|
||||
return BuildModel(0);
|
||||
SelectedRoleName = null;
|
||||
return BuildModel(null);
|
||||
}
|
||||
|
||||
public bool ConfirmSelectedRole()
|
||||
{
|
||||
IReadOnlyList<RoleConfig> roles = GameEntry.Luban.GetTable<RoleConfig>();
|
||||
if (roles == null || roles.Count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (SelectedRoleId <= 0 || !roles.Any(r => r.Id == SelectedRoleId))
|
||||
var roles = GameEntry.Luban.GetTable<RoleConfig>();
|
||||
var config = GameEntry.Luban.Get<RoleConfig>(SelectedRoleName);
|
||||
if (string.IsNullOrEmpty(SelectedRoleName) || config == null)
|
||||
{
|
||||
int randomIndex = Random.Range(0, roles.Count);
|
||||
SelectedRoleId = roles[randomIndex].Id;
|
||||
SelectedRoleName = roles[randomIndex].Name;
|
||||
}
|
||||
|
||||
_procedureMenu.ConfirmSelectRole(SelectedRoleId);
|
||||
_procedureMenu.ConfirmSelectRole(SelectedRoleName);
|
||||
return true;
|
||||
}
|
||||
|
||||
private SelectRoleRawData BuildModel(int selectedRoleId)
|
||||
private SelectRoleRawData BuildModel(string selectedRoleName)
|
||||
{
|
||||
IReadOnlyList<RoleConfig> roles = GameEntry.Luban.GetTable<RoleConfig>();
|
||||
int count = roles.Count;
|
||||
@@ -61,18 +57,19 @@ namespace SepCore.UI
|
||||
{
|
||||
roleItems[i] = new RoleItemRawData
|
||||
{
|
||||
RoleId = roles[i].Id,
|
||||
IconName = roles[i].IconName
|
||||
RoleName = roles[i].Name,
|
||||
IconName = roles[i].Sprite
|
||||
};
|
||||
}
|
||||
|
||||
RoleConfig selectedRole = selectedRoleId > 0 ? roles.FirstOrDefault(r => r.Id == selectedRoleId) : null;
|
||||
RoleConfig selectedRole = string.IsNullOrEmpty(selectedRoleName)
|
||||
? null
|
||||
: roles.FirstOrDefault(r => r.Name == selectedRoleName);
|
||||
RolePropertyAreaRawData selectedRoleData = selectedRole == null
|
||||
? null
|
||||
: new RolePropertyAreaRawData
|
||||
{
|
||||
RoleId = selectedRole.Id,
|
||||
RoleName = selectedRole.RoleName,
|
||||
Name = selectedRole.Name,
|
||||
InitialProperties = selectedRole.Modifiers
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user