第一批重构,主要是物理迁移脚本和部分命名空间的调整
- 结构上迁移文件,将脚本分成 Base/Runtime/Presentation/Procedure/Editor 五大文件夹 - 调整 DataTable 和 Definition 下脚本的命名空间 - 依据 UI-5层架构设计规范 拆分原先的 UI 到 Runtime 和 Presentation 下
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
public static class BinaryReaderExtension
|
||||
{
|
||||
public static Color32 ReadColor32(this BinaryReader binaryReader)
|
||||
{
|
||||
return new Color32(binaryReader.ReadByte(), binaryReader.ReadByte(), binaryReader.ReadByte(), binaryReader.ReadByte());
|
||||
}
|
||||
|
||||
public static Color ReadColor(this BinaryReader binaryReader)
|
||||
{
|
||||
return new Color(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
|
||||
}
|
||||
|
||||
public static DateTime ReadDateTime(this BinaryReader binaryReader)
|
||||
{
|
||||
return new DateTime(binaryReader.ReadInt64());
|
||||
}
|
||||
|
||||
public static Quaternion ReadQuaternion(this BinaryReader binaryReader)
|
||||
{
|
||||
return new Quaternion(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
|
||||
}
|
||||
|
||||
public static Rect ReadRect(this BinaryReader binaryReader)
|
||||
{
|
||||
return new Rect(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
|
||||
}
|
||||
|
||||
public static Vector2 ReadVector2(this BinaryReader binaryReader)
|
||||
{
|
||||
return new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle());
|
||||
}
|
||||
|
||||
public static Vector3 ReadVector3(this BinaryReader binaryReader)
|
||||
{
|
||||
return new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
|
||||
}
|
||||
|
||||
public static Vector4 ReadVector4(this BinaryReader binaryReader)
|
||||
{
|
||||
return new Vector4(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f303871e05cae2d489d6ba3adb6e39d3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// Bullet config table.
|
||||
/// Id uses BulletType value.
|
||||
/// </summary>
|
||||
public class DRBullet : DataRowBase
|
||||
{
|
||||
private int m_Id;
|
||||
|
||||
public override int Id => m_Id;
|
||||
|
||||
/// <summary>
|
||||
/// 子弹实体 Id,用于在 DREntity 中查询资源路径
|
||||
/// </summary>
|
||||
public int EntityTypeId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子弹速度
|
||||
/// </summary>
|
||||
public float Speed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子弹生存时间
|
||||
/// </summary>
|
||||
public float MaxAliveTime { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
EntityTypeId = int.Parse(columnStrings[index++]);
|
||||
Speed = float.Parse(columnStrings[index++]);
|
||||
MaxAliveTime = float.Parse(columnStrings[index++]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 537419cc75316184b84b9f806b114976
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
public class DREnemy : DataRowBase
|
||||
{
|
||||
private int m_id;
|
||||
|
||||
public override int Id => m_id;
|
||||
|
||||
public int EntityTypeId { get; private set; }
|
||||
|
||||
public int MaxHealth { get; private set; }
|
||||
|
||||
public int HpAddPerLevel { get; private set; }
|
||||
|
||||
public int AttackDamage { get; private set; }
|
||||
|
||||
public float AttackCooldown { get; private set; }
|
||||
|
||||
public float AttackRange { get; private set; }
|
||||
|
||||
public float Speed { get; private set; }
|
||||
|
||||
public int DropCoin { get; private set; }
|
||||
|
||||
public int DropExp { get; private set; }
|
||||
|
||||
public float DropPercent { get; private set; }
|
||||
|
||||
public Dictionary<string, string> Params { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
EntityTypeId = int.Parse(columnStrings[index++]);
|
||||
MaxHealth = int.Parse(columnStrings[index++]);
|
||||
HpAddPerLevel = int.Parse(columnStrings[index++]);
|
||||
AttackDamage = int.Parse(columnStrings[index++]);
|
||||
AttackCooldown = float.Parse(columnStrings[index++]);
|
||||
AttackRange = float.Parse(columnStrings[index++]);
|
||||
Speed = float.Parse(columnStrings[index++]);
|
||||
DropCoin = int.Parse(columnStrings[index++]);
|
||||
DropExp = int.Parse(columnStrings[index++]);
|
||||
DropPercent = float.Parse(columnStrings[index++]);
|
||||
Params = DeserializeParams(columnStrings[index++]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解参数
|
||||
/// </summary>
|
||||
/// <param name="rawParams"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
private Dictionary<string, string> DeserializeParams(string rawParams)
|
||||
{
|
||||
if (!rawParams.StartsWith('[') || !rawParams.EndsWith(']'))
|
||||
{
|
||||
throw new ArgumentException("Input must be enclosed in square brackets.");
|
||||
}
|
||||
|
||||
var dict = new Dictionary<string, string>();
|
||||
|
||||
if (string.IsNullOrEmpty(rawParams)) return dict;
|
||||
|
||||
string[] items = rawParams.Substring(1, rawParams.Length - 2).Split(";");
|
||||
foreach (var item in items)
|
||||
{
|
||||
string entry = item.Trim();
|
||||
if (string.IsNullOrEmpty(entry)) continue;
|
||||
|
||||
string[] pair = entry.Split(':', StringSplitOptions.RemoveEmptyEntries);
|
||||
if (pair.Length != 2) continue;
|
||||
dict.Add(pair[0].ToLower(), pair[1]);
|
||||
}
|
||||
|
||||
return dict;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65140fe454964f14951a73965686fb0e
|
||||
timeCreated: 1769221617
|
||||
@@ -0,0 +1,64 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 实体表。
|
||||
/// </summary>
|
||||
public class DREntity : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取实体编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get { return m_Id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string AssetName { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
for (int i = 0; i < columnStrings.Length; i++)
|
||||
{
|
||||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
AssetName = columnStrings[index++];
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(dataRowBytes, startIndex, length, false))
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))
|
||||
{
|
||||
m_Id = binaryReader.Read7BitEncodedInt32();
|
||||
AssetName = binaryReader.ReadString();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a48a9c6b974d6674f8a0421fc603dc56
|
||||
timeCreated: 1528026147
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
using SepCore.Definition;
|
||||
using CustomUtility;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
public class DRGoods : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取商品Id。
|
||||
/// </summary>
|
||||
public override int Id => m_Id;
|
||||
|
||||
/// <summary>
|
||||
/// 获取商品类型。
|
||||
/// </summary>
|
||||
public GoodsType GoodsType { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取商品对应具体类型的表Id
|
||||
/// </summary>
|
||||
public int GoodsTypeId { get; set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] fields = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
|
||||
int index = 0;
|
||||
|
||||
index++;
|
||||
m_Id = int.Parse(fields[index++]);
|
||||
index++;
|
||||
GoodsType = EnumUtility<GoodsType>.Get(fields[index++]);
|
||||
GoodsTypeId = int.Parse(fields[index++]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 595bda561b5491c4e878f071ceb31089
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using CustomUtility;
|
||||
using SepCore.Definition;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
public class DRLevel : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取关卡编号。
|
||||
/// </summary>
|
||||
public override int Id => m_Id;
|
||||
|
||||
/// <summary>
|
||||
/// 获取关卡内会生成的实体编号
|
||||
/// </summary>
|
||||
public EnemyType[] EntityTypes { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取关卡内每次生成实体的数量
|
||||
/// </summary>
|
||||
public int[] EntityCounts { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取关卡内生成实体的间隔时间
|
||||
/// </summary>
|
||||
public float[] Intervals { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取关卡时间。
|
||||
/// </summary>
|
||||
public int Duration { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
GenerateEntityTypes(columnStrings[index++]);
|
||||
GenerateEntityCounts(columnStrings[index++]);
|
||||
GenerateIntervals(columnStrings[index++]);
|
||||
Duration = int.Parse(columnStrings[index++]);
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
}
|
||||
|
||||
private void GenerateEntityTypes(string raw)
|
||||
{
|
||||
if (!raw.StartsWith('[') || !raw.EndsWith(']'))
|
||||
{
|
||||
throw new ArgumentException("Input must be enclosed in square brackets.");
|
||||
}
|
||||
|
||||
if (raw.Length == 2) return;
|
||||
string[] entityIds = raw.Substring(1, raw.Length - 2).Split(",");
|
||||
int length = entityIds.Length;
|
||||
EntityTypes = new EnemyType[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
EntityTypes[i] = EnumUtility<EnemyType>.Get(entityIds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateEntityCounts(string raw)
|
||||
{
|
||||
if (!raw.StartsWith('[') || !raw.EndsWith(']'))
|
||||
{
|
||||
throw new ArgumentException("Input must be enclosed in square brackets.");
|
||||
}
|
||||
|
||||
if (raw.Length == 2) return;
|
||||
string[] entityCounts = raw.Substring(1, raw.Length - 2).Split(",");
|
||||
int length = entityCounts.Length;
|
||||
EntityCounts = new int[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
EntityCounts[i] = int.Parse(entityCounts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateIntervals(string raw)
|
||||
{
|
||||
if (!raw.StartsWith('[') || !raw.EndsWith(']'))
|
||||
{
|
||||
throw new ArgumentException("Input must be enclosed in square brackets.");
|
||||
}
|
||||
|
||||
if (raw.Length == 2) return;
|
||||
string[] intervals = raw.Substring(1, raw.Length - 2).Split(",");
|
||||
int length = intervals.Length;
|
||||
Intervals = new float[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
Intervals[i] = float.Parse(intervals[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2c6e5a5e57b464397483dd1f164ddf8
|
||||
timeCreated: 1769159930
|
||||
@@ -0,0 +1,39 @@
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
public class DRLevelRarity : DataRowBase
|
||||
{
|
||||
private int m_Id;
|
||||
|
||||
public override int Id => m_Id;
|
||||
|
||||
public int LevelMin { get; private set; }
|
||||
public int LevelMax { get; private set; }
|
||||
|
||||
public int WhiteWeight { get; private set; }
|
||||
public int GreenWeight { get; private set; }
|
||||
public int BlueWeight { get; private set; }
|
||||
public int PurpleWeight { get; private set; }
|
||||
public int RedWeight { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] fields = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(fields[index++]);
|
||||
index++;
|
||||
LevelMin = int.Parse(fields[index++]);
|
||||
LevelMax = int.Parse(fields[index++]);
|
||||
WhiteWeight = int.Parse(fields[index++]);
|
||||
GreenWeight = int.Parse(fields[index++]);
|
||||
BlueWeight = int.Parse(fields[index++]);
|
||||
PurpleWeight = int.Parse(fields[index++]);
|
||||
RedWeight = int.Parse(fields[index++]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2be3a3c9896a441496abfb07467e9e19
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
using SepCore.Definition;
|
||||
using Newtonsoft.Json;
|
||||
using CustomUtility;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
public class DRLevelUpReward : DataRowBase
|
||||
{
|
||||
private int m_Id;
|
||||
|
||||
public override int Id => m_Id;
|
||||
|
||||
public string Title { get; private set; }
|
||||
|
||||
public string IconAssetName { get; private set; }
|
||||
|
||||
public ItemRarity Rarity { get; private set; }
|
||||
|
||||
public StatModifier[] Modifiers { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] fields = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
int index = 0;
|
||||
|
||||
index++;
|
||||
m_Id = int.Parse(fields[index++]);
|
||||
index++;
|
||||
Title = fields[index++];
|
||||
IconAssetName = fields[index++];
|
||||
Rarity = EnumUtility<ItemRarity>.Get(fields[index++]);
|
||||
Modifiers = JsonConvert.DeserializeObject<StatModifier[]>(fields[index++]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d84933d61f76d7942a903b8db26a3ad6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,64 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 音乐配置表。
|
||||
/// </summary>
|
||||
public class DRMusic : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取音乐编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get { return m_Id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string AssetName { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
for (int i = 0; i < columnStrings.Length; i++)
|
||||
{
|
||||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
AssetName = columnStrings[index++];
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(dataRowBytes, startIndex, length, false))
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))
|
||||
{
|
||||
m_Id = binaryReader.Read7BitEncodedInt32();
|
||||
AssetName = binaryReader.ReadString();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5539646031a664344b90aeb64f92930d
|
||||
timeCreated: 1528026147
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
using SepCore.Definition;
|
||||
using Newtonsoft.Json;
|
||||
using CustomUtility;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
public class DRProp : DataRowBase
|
||||
{
|
||||
private int m_Id;
|
||||
|
||||
public override int Id => m_Id;
|
||||
public string Title { get; private set; }
|
||||
public string IconAssetName { get; private set; }
|
||||
public ItemRarity Rarity { get; private set; }
|
||||
public int Price { get; private set; }
|
||||
public float PriceRandomPercent { get; private set; }
|
||||
public StatModifier[] Modifiers { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] fields = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
int index = 0;
|
||||
|
||||
index++;
|
||||
m_Id = int.Parse(fields[index++]);
|
||||
index++;
|
||||
Title = fields[index++];
|
||||
IconAssetName = fields[index++];
|
||||
Rarity = EnumUtility<ItemRarity>.Get(fields[index++]);
|
||||
Price = int.Parse(fields[index++]);
|
||||
PriceRandomPercent = float.Parse(fields[index++]);
|
||||
Modifiers = JsonConvert.DeserializeObject<StatModifier[]>(fields[index++]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84edcc54b1524344a9f7b36d1bf55419
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using SepCore.Definition;
|
||||
using GameFramework;
|
||||
using StarForce;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
public class DRRole : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取角色编号。
|
||||
/// </summary>
|
||||
public override int Id => m_Id;
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string RoleName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取图标名称。
|
||||
/// </summary>
|
||||
public string IconName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取初始最大生命。
|
||||
/// </summary>
|
||||
public int MaxHealth { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取初始速度。
|
||||
/// </summary>
|
||||
public float Speed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取初始金币。
|
||||
/// </summary>
|
||||
public int Coin { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取最大持有武器数。
|
||||
/// </summary>
|
||||
public int WeaponCapacity { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取初始属性。
|
||||
/// </summary>
|
||||
public StatModifier[] InitialProperties { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取初始物品。
|
||||
/// </summary>
|
||||
public KeyValuePair<int, int>[] InitialItemIds { get; private set; }
|
||||
|
||||
public int[] ExpRequires { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
RoleName = columnStrings[index++];
|
||||
IconName = columnStrings[index++];
|
||||
MaxHealth = int.Parse(columnStrings[index++]);
|
||||
Speed = float.Parse(columnStrings[index++]);
|
||||
Coin = int.Parse(columnStrings[index++]);
|
||||
WeaponCapacity = int.Parse(columnStrings[index++]);
|
||||
InitialProperties = Utility.Json.ToObject<StatModifier[]>(columnStrings[index++]);
|
||||
GenerateItems(columnStrings[index++]);
|
||||
GenerateExpRequires(ref columnStrings, index);
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
}
|
||||
|
||||
private void GenerateItems(string raw)
|
||||
{
|
||||
if (!raw.StartsWith('[') || !raw.EndsWith(']'))
|
||||
{
|
||||
throw new ArgumentException("Input must be enclosed in square brackets.");
|
||||
}
|
||||
|
||||
if (raw.Length <= 2) return;
|
||||
|
||||
string[] items = raw.Substring(1, raw.Length - 2).Split(";");
|
||||
int length = items.Length;
|
||||
InitialItemIds = new KeyValuePair<int, int>[length];
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
string input = items[i];
|
||||
if (string.IsNullOrEmpty(input))
|
||||
{
|
||||
Log.Warning("Invalid item: {0}", input);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!input.StartsWith('[') || !input.EndsWith(']'))
|
||||
{
|
||||
throw new ArgumentException("Input must be enclosed in square brackets.");
|
||||
}
|
||||
|
||||
string inner = input.Substring(1, input.Length - 2);
|
||||
|
||||
// 如果是空列表 "[]"
|
||||
if (inner.Length == 0) continue;
|
||||
|
||||
string[] index = inner.Split(",");
|
||||
var item = new KeyValuePair<int, int>(int.Parse(index[0]), int.Parse(index[1]));
|
||||
InitialItemIds[i] = item;
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateExpRequires(ref string[] columnStrings, int index)
|
||||
{
|
||||
List<int> expRequires = new List<int>();
|
||||
int baseExp = int.Parse(columnStrings[index]);
|
||||
for (int i = index; i < columnStrings.Length; i++)
|
||||
{
|
||||
expRequires.Add(int.Parse(columnStrings[i]) - baseExp);
|
||||
}
|
||||
|
||||
ExpRequires = expRequires.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d596bc33ed84659449059b972a2c4e26
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,71 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 场景配置表。
|
||||
/// </summary>
|
||||
public class DRScene : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取场景编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get { return m_Id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string AssetName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取背景音乐编号。
|
||||
/// </summary>
|
||||
public int BackgroundMusicId { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
for (int i = 0; i < columnStrings.Length; i++)
|
||||
{
|
||||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
AssetName = columnStrings[index++];
|
||||
BackgroundMusicId = int.Parse(columnStrings[index++]);
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(dataRowBytes, startIndex, length, false))
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))
|
||||
{
|
||||
m_Id = binaryReader.Read7BitEncodedInt32();
|
||||
AssetName = binaryReader.ReadString();
|
||||
BackgroundMusicId = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ce61902e6e3c23409f9ef10ccc8c550
|
||||
timeCreated: 1528026147
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,99 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 声音配置表。
|
||||
/// </summary>
|
||||
public class DRSound : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取声音编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get { return m_Id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string AssetName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取优先级(默认0,128最高,-128最低)。
|
||||
/// </summary>
|
||||
public int Priority { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取是否循环。
|
||||
/// </summary>
|
||||
public bool Loop { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取音量(0~1)。
|
||||
/// </summary>
|
||||
public float Volume { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取声音空间混合量(0为2D,1为3D,中间值混合效果)。
|
||||
/// </summary>
|
||||
public float SpatialBlend { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取声音最大距离。
|
||||
/// </summary>
|
||||
public float MaxDistance { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
for (int i = 0; i < columnStrings.Length; i++)
|
||||
{
|
||||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
AssetName = columnStrings[index++];
|
||||
Priority = int.Parse(columnStrings[index++]);
|
||||
Loop = bool.Parse(columnStrings[index++]);
|
||||
Volume = float.Parse(columnStrings[index++]);
|
||||
SpatialBlend = float.Parse(columnStrings[index++]);
|
||||
MaxDistance = float.Parse(columnStrings[index++]);
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(dataRowBytes, startIndex, length, false))
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))
|
||||
{
|
||||
m_Id = binaryReader.Read7BitEncodedInt32();
|
||||
AssetName = binaryReader.ReadString();
|
||||
Priority = binaryReader.Read7BitEncodedInt32();
|
||||
Loop = binaryReader.ReadBoolean();
|
||||
Volume = binaryReader.ReadSingle();
|
||||
SpatialBlend = binaryReader.ReadSingle();
|
||||
MaxDistance = binaryReader.ReadSingle();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc0abcc42a26c844d91d422da22eb94d
|
||||
timeCreated: 1528026147
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 界面配置表。
|
||||
/// </summary>
|
||||
public class DRUIForm : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get { return m_Id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string AssetName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取界面组名称。
|
||||
/// </summary>
|
||||
public string UIGroupName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取是否允许多个界面实例。
|
||||
/// </summary>
|
||||
public bool AllowMultiInstance { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取是否暂停被其覆盖的界面。
|
||||
/// </summary>
|
||||
public bool PauseCoveredUIForm { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
for (int i = 0; i < columnStrings.Length; i++)
|
||||
{
|
||||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
AssetName = columnStrings[index++];
|
||||
UIGroupName = columnStrings[index++];
|
||||
AllowMultiInstance = bool.Parse(columnStrings[index++]);
|
||||
PauseCoveredUIForm = bool.Parse(columnStrings[index++]);
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(dataRowBytes, startIndex, length, false))
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))
|
||||
{
|
||||
m_Id = binaryReader.Read7BitEncodedInt32();
|
||||
AssetName = binaryReader.ReadString();
|
||||
UIGroupName = binaryReader.ReadString();
|
||||
AllowMultiInstance = binaryReader.ReadBoolean();
|
||||
PauseCoveredUIForm = binaryReader.ReadBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f28db9f996bc3d04eb73541b1f8b1036
|
||||
timeCreated: 1528026148
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,78 @@
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 声音配置表。
|
||||
/// </summary>
|
||||
public class DRUISound : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取声音编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get { return m_Id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string AssetName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取优先级(默认0,128最高,-128最低)。
|
||||
/// </summary>
|
||||
public int Priority { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取音量(0~1)。
|
||||
/// </summary>
|
||||
public float Volume { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
for (int i = 0; i < columnStrings.Length; i++)
|
||||
{
|
||||
columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
AssetName = columnStrings[index++];
|
||||
Priority = int.Parse(columnStrings[index++]);
|
||||
Volume = float.Parse(columnStrings[index++]);
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
|
||||
{
|
||||
using (MemoryStream memoryStream = new MemoryStream(dataRowBytes, startIndex, length, false))
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8))
|
||||
{
|
||||
m_Id = binaryReader.Read7BitEncodedInt32();
|
||||
AssetName = binaryReader.ReadString();
|
||||
Priority = binaryReader.Read7BitEncodedInt32();
|
||||
Volume = binaryReader.ReadSingle();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePropertyArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d69c673440234c24a9718897060d4e14
|
||||
timeCreated: 1528026148
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,155 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using SepCore.Definition;
|
||||
using GameFramework;
|
||||
using CustomUtility;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
/// <summary>
|
||||
/// 武器表。
|
||||
/// </summary>
|
||||
public class DRWeapon : DataRowBase
|
||||
{
|
||||
private int m_Id = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器编号。
|
||||
/// </summary>
|
||||
public override int Id => m_Id;
|
||||
|
||||
public int EntityTypeId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器名称。
|
||||
/// </summary>
|
||||
public string Title { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取图标资源名称。
|
||||
/// </summary>
|
||||
public string IconAssetName { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器稀有度
|
||||
/// </summary>
|
||||
public ItemRarity Rarity { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器价值
|
||||
/// </summary>
|
||||
public int Price { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器价值浮动率
|
||||
/// </summary>
|
||||
public float PriceRandomPercent { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器伤害。
|
||||
/// </summary>
|
||||
public int Attack { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器冷却。
|
||||
/// </summary>
|
||||
public float Cooldown { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器攻击范围。
|
||||
/// </summary>
|
||||
public float AttackRange { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器攻击音效。
|
||||
/// </summary>
|
||||
public int AttackSoundId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器额外参数。
|
||||
/// </summary>
|
||||
public Dictionary<string, string> Pramas { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器额外参数 Json。
|
||||
/// </summary>
|
||||
public string ParamsJson { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取武器额外属性。
|
||||
/// </summary>
|
||||
public StatModifier[] Modifiers { get; private set; }
|
||||
|
||||
public override bool ParseDataRow(string dataRowString, object userData)
|
||||
{
|
||||
string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
|
||||
|
||||
int index = 0;
|
||||
index++;
|
||||
m_Id = int.Parse(columnStrings[index++]);
|
||||
index++;
|
||||
EntityTypeId = int.Parse(columnStrings[index++]);
|
||||
Title = columnStrings[index++];
|
||||
IconAssetName = columnStrings[index++];
|
||||
Rarity = EnumUtility<ItemRarity>.Get(columnStrings[index++]);
|
||||
Price = int.Parse(columnStrings[index++]);
|
||||
PriceRandomPercent = float.Parse(columnStrings[index++]);
|
||||
Attack = int.Parse(columnStrings[index++]);
|
||||
Cooldown = float.Parse(columnStrings[index++]);
|
||||
AttackRange = float.Parse(columnStrings[index++]);
|
||||
AttackSoundId = int.Parse(columnStrings[index++]);
|
||||
ParamsJson = columnStrings[index++];
|
||||
Pramas = DeserializeParams(ParamsJson);
|
||||
Modifiers = Utility.Json.ToObject<StatModifier[]>(columnStrings[index++]);
|
||||
|
||||
GeneratePropertyArray();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void GeneratePropertyArray()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解参数
|
||||
/// </summary>
|
||||
/// <param name="rawParams"></param>
|
||||
/// <returns></returns>
|
||||
private Dictionary<string, string> DeserializeParams(string rawParams)
|
||||
{
|
||||
var dict = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
if (string.IsNullOrWhiteSpace(rawParams))
|
||||
{
|
||||
return dict;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
JObject paramObject = Utility.Json.ToObject<JObject>(rawParams);
|
||||
if (paramObject == null)
|
||||
{
|
||||
return dict;
|
||||
}
|
||||
|
||||
foreach (var pair in paramObject)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(pair.Key) || pair.Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
dict[pair.Key] = pair.Value.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Warning("Failed to parse weapon params json '{0}'. Error: {1}", rawParams, exception.Message);
|
||||
}
|
||||
|
||||
return dict;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b386151345d3f14ab9b7dc5ed6dd864
|
||||
timeCreated: 1528026148
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,97 @@
|
||||
using GameFramework.DataTable;
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.DataTable
|
||||
{
|
||||
public static class DataTableExtension
|
||||
{
|
||||
private const string DataRowClassPrefixName = "SepCore.DataTable.DR";
|
||||
internal static readonly char[] DataSplitSeparators = new char[] { '\t' };
|
||||
internal static readonly char[] DataTrimSeparators = new char[] { '\"' };
|
||||
|
||||
public static void LoadDataTable(this DataTableComponent dataTableComponent, string dataTableName,
|
||||
string dataTableAssetName, object userData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(dataTableName))
|
||||
{
|
||||
Log.Warning("Data table name is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
string[] splitedNames = dataTableName.Split('_');
|
||||
if (splitedNames.Length > 2)
|
||||
{
|
||||
Log.Warning("Data table name is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
string dataRowClassName = DataRowClassPrefixName + splitedNames[0];
|
||||
Type dataRowType = Type.GetType(dataRowClassName);
|
||||
if (dataRowType == null)
|
||||
{
|
||||
Log.Warning("Can not get data row type with class name '{0}'.", dataRowClassName);
|
||||
return;
|
||||
}
|
||||
|
||||
string name = splitedNames.Length > 1 ? splitedNames[1] : null;
|
||||
DataTableBase dataTable = dataTableComponent.CreateDataTable(dataRowType, name);
|
||||
dataTable.ReadData(dataTableAssetName, Constant.AssetPriority.DataTableAsset, userData);
|
||||
}
|
||||
|
||||
public static Color32 ParseColor32(string value)
|
||||
{
|
||||
string[] splitedValue = value.Split(',');
|
||||
return new Color32(byte.Parse(splitedValue[0]), byte.Parse(splitedValue[1]), byte.Parse(splitedValue[2]),
|
||||
byte.Parse(splitedValue[3]));
|
||||
}
|
||||
|
||||
public static Color ParseColor(string value)
|
||||
{
|
||||
string[] splitedValue = value.Split(',');
|
||||
return new Color(float.Parse(splitedValue[0]), float.Parse(splitedValue[1]), float.Parse(splitedValue[2]),
|
||||
float.Parse(splitedValue[3]));
|
||||
}
|
||||
|
||||
public static Quaternion ParseQuaternion(string value)
|
||||
{
|
||||
string[] splitedValue = value.Split(',');
|
||||
return new Quaternion(float.Parse(splitedValue[0]), float.Parse(splitedValue[1]),
|
||||
float.Parse(splitedValue[2]), float.Parse(splitedValue[3]));
|
||||
}
|
||||
|
||||
public static Rect ParseRect(string value)
|
||||
{
|
||||
string[] splitedValue = value.Split(',');
|
||||
return new Rect(float.Parse(splitedValue[0]), float.Parse(splitedValue[1]), float.Parse(splitedValue[2]),
|
||||
float.Parse(splitedValue[3]));
|
||||
}
|
||||
|
||||
public static Vector2 ParseVector2(string value)
|
||||
{
|
||||
string[] splitedValue = value.Split(',');
|
||||
return new Vector2(float.Parse(splitedValue[0]), float.Parse(splitedValue[1]));
|
||||
}
|
||||
|
||||
public static Vector3 ParseVector3(string value)
|
||||
{
|
||||
string[] splitedValue = value.Split(',');
|
||||
return new Vector3(float.Parse(splitedValue[0]), float.Parse(splitedValue[1]),
|
||||
float.Parse(splitedValue[2]));
|
||||
}
|
||||
|
||||
public static Vector4 ParseVector4(string value)
|
||||
{
|
||||
string[] splitedValue = value.Split(',');
|
||||
return new Vector4(float.Parse(splitedValue[0]), float.Parse(splitedValue[1]), float.Parse(splitedValue[2]),
|
||||
float.Parse(splitedValue[3]));
|
||||
}
|
||||
|
||||
public static T GetDataTableRow<T>(this DataTableComponent dataTableComponent, int id) where T : DataRowBase
|
||||
{
|
||||
return dataTableComponent.GetDataTable<T>().GetDataRow(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23740ffb8ecb90b48ad986504e1d2474
|
||||
timeCreated: 1528026147
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user