110 lines
3.4 KiB
C#
110 lines
3.4 KiB
C#
using System;
|
|
using GeometryTD.Definition;
|
|
using GeometryTD.CustomUtility;
|
|
using UnityGameFramework.Runtime;
|
|
|
|
namespace GeometryTD.DataTable
|
|
{
|
|
/// <summary>
|
|
/// 底座组件表
|
|
/// </summary>
|
|
public class DRBaseComp : DataRowBase
|
|
{
|
|
private int m_Id = 0;
|
|
|
|
/// <summary>
|
|
/// 获取底座组件编号
|
|
/// </summary>
|
|
public override int Id => m_Id;
|
|
|
|
/// <summary>
|
|
/// 获取底座组件实体编号
|
|
/// </summary>
|
|
public int EntityId { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 获取底座组件名
|
|
/// </summary>
|
|
public string Name { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 获取底座组件攻击速度数组
|
|
/// </summary>
|
|
public float[] AttackSpeed { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 获取攻击属性
|
|
/// </summary>
|
|
public AttackPropertyType AttackPropertyType { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 获取属性约束
|
|
/// </summary>
|
|
public string Constraint { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 获取可能出现的 Tag
|
|
/// </summary>
|
|
public TagType[] PossibleTag { 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++;
|
|
EntityId = int.Parse(columnStrings[index++]);
|
|
Name = columnStrings[index++];
|
|
AttackSpeed = GenerateAttackSpeed(columnStrings[index++]);
|
|
AttackPropertyType = EnumUtility<AttackPropertyType>.Get(columnStrings[index++]);
|
|
Constraint = columnStrings[index++];
|
|
PossibleTag = GeneratePossibleTag(columnStrings[index++]);
|
|
|
|
return true;
|
|
}
|
|
|
|
private float[] GenerateAttackSpeed(string raw)
|
|
{
|
|
if (!raw.StartsWith('[') || !raw.EndsWith(']'))
|
|
{
|
|
throw new ArgumentException("Input must be enclosed in square brackets.");
|
|
}
|
|
|
|
if (raw.Length == 2) return new float[] { };
|
|
string[] attackSpeedRaws = raw.Substring(1, raw.Length - 2).Split(",");
|
|
int length = attackSpeedRaws.Length;
|
|
var attackSpeed = new float[length];
|
|
for (int i = 0; i < length; i++)
|
|
{
|
|
attackSpeed[i] = float.Parse(attackSpeedRaws[i]);
|
|
}
|
|
|
|
return attackSpeed;
|
|
}
|
|
|
|
private TagType[] GeneratePossibleTag(string raw)
|
|
{
|
|
if (!raw.StartsWith('[') || !raw.EndsWith(']'))
|
|
{
|
|
throw new ArgumentException("Input must be enclosed in square brackets.");
|
|
}
|
|
|
|
if (raw.Length == 2) return new TagType[] { };
|
|
string[] tagTypes = raw.Substring(1, raw.Length - 2).Split(",");
|
|
int length = tagTypes.Length;
|
|
var tags = new TagType[length];
|
|
for (int i = 0; i < length; i++)
|
|
{
|
|
tags[i] = EnumUtility<TagType>.Get(tagTypes[i]);
|
|
}
|
|
|
|
return tags;
|
|
}
|
|
}
|
|
} |