116 lines
3.6 KiB
C#
116 lines
3.6 KiB
C#
using System;
|
|
using GeometryTD.Definition;
|
|
using GeometryTD.CustomUtility;
|
|
using UnityGameFramework.Runtime;
|
|
|
|
namespace GeometryTD.DataTable
|
|
{
|
|
/// <summary>
|
|
/// 枪口组件表
|
|
/// </summary>
|
|
public class DRMuzzleComp : DataRowBase
|
|
{
|
|
private int m_Id = 0;
|
|
|
|
/// <summary>
|
|
/// 获取枪口组件编号
|
|
/// </summary>
|
|
public override int Id => m_Id;
|
|
|
|
/// <summary>
|
|
/// 获取枪口组件名
|
|
/// </summary>
|
|
public string Name { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 获取枪口组件攻击伤害数组
|
|
/// </summary>
|
|
public int[] AttackDamage { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 获取枪口组件每级提升攻击伤害值
|
|
/// </summary>
|
|
public int AttackDamagePerLevel { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 获取攻击伤害浮动
|
|
/// </summary>
|
|
public float DamageRandomRate { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 获取枪口攻击方式
|
|
/// </summary>
|
|
public AttackMethodType AttackMethodType { 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++;
|
|
Name = columnStrings[index++];
|
|
AttackDamage = GenerateAttackDamage(columnStrings[index++]);
|
|
AttackDamagePerLevel = int.Parse(columnStrings[index++]);
|
|
DamageRandomRate = float.Parse(columnStrings[index++]);
|
|
AttackMethodType = EnumUtility<AttackMethodType>.Get(columnStrings[index++]);
|
|
Constraint = columnStrings[index++];
|
|
PossibleTag = GeneratePossibleTag(columnStrings[index++]);
|
|
|
|
return true;
|
|
}
|
|
|
|
private int[] GenerateAttackDamage(string raw)
|
|
{
|
|
if (!raw.StartsWith('[') || !raw.EndsWith(']'))
|
|
{
|
|
throw new ArgumentException("Input must be enclosed in square brackets.");
|
|
}
|
|
|
|
if (raw.Length == 2) return new int[] { };
|
|
string[] raws = raw.Substring(1, raw.Length - 2).Split(",");
|
|
int length = raws.Length;
|
|
var damages = new int[length];
|
|
for (int i = 0; i < length; i++)
|
|
{
|
|
damages[i] = int.Parse(raws[i]);
|
|
}
|
|
|
|
return damages;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |