142 lines
4.9 KiB
C#
142 lines
4.9 KiB
C#
using System;
|
|
using System.Text;
|
|
using GeometryTD.Definition;
|
|
|
|
namespace GeometryTD.CustomUtility
|
|
{
|
|
public static class ItemDescUtility
|
|
{
|
|
public static string BuildTowerDesc(TowerStatsData towerData)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
// MuzzleComp
|
|
sb.Append("攻击伤害:");
|
|
for (int i = 0; i < towerData.AttackDamage.Length; i++)
|
|
{
|
|
if (i != 0) sb.Append("|");
|
|
sb.Append(towerData.AttackDamage[i]);
|
|
}
|
|
sb.Append('\n');
|
|
|
|
sb.Append($"伤害浮动:{towerData.DamageRandomRate:P0}\n");
|
|
|
|
sb.Append($"攻击方式:{ConvertAttackMethod(towerData.AttackMethodType)}\n");
|
|
|
|
// BearingComp
|
|
sb.Append("旋转速度:");
|
|
for (int i = 0; i < towerData.RotateSpeed.Length; i++)
|
|
{
|
|
if (i != 0) sb.Append("|");
|
|
sb.Append(towerData.RotateSpeed[i]);
|
|
}
|
|
sb.Append('\n');
|
|
|
|
sb.Append("攻击范围:");
|
|
for (int i = 0; i < towerData.AttackRange.Length; i++)
|
|
{
|
|
if (i != 0) sb.Append("|");
|
|
sb.Append(towerData.AttackRange[i]);
|
|
}
|
|
sb.Append('\n');
|
|
|
|
// BaseComp
|
|
sb.Append("攻击速度:");
|
|
for (int i = 0; i < towerData.AttackSpeed.Length; i++)
|
|
{
|
|
if (i != 0) sb.Append("|");
|
|
sb.Append(towerData.AttackSpeed[i]);
|
|
}
|
|
sb.Append('\n');
|
|
|
|
sb.Append($"伤害属性:{ConvertAttackProperty(towerData.AttackPropertyType)}\n");
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
public static string BuildMuzzleDesc(MuzzleCompItemData muzzleData)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.Append("攻击伤害:");
|
|
for (int i = 0; i < muzzleData.AttackDamage.Length; i++)
|
|
{
|
|
if (i != 0) sb.Append("|");
|
|
sb.Append(muzzleData.AttackDamage[i]);
|
|
}
|
|
sb.Append('\n');
|
|
|
|
sb.Append($"伤害浮动:{muzzleData.DamageRandomRate:P0}\n");
|
|
|
|
sb.Append($"攻击方式:{ConvertAttackMethod(muzzleData.AttackMethodType)}\n");
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
public static string BuildBearingDesc(BearingCompItemData bearingData)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.Append("旋转速度:");
|
|
for (int i = 0; i < bearingData.RotateSpeed.Length; i++)
|
|
{
|
|
if (i != 0) sb.Append("|");
|
|
sb.Append(bearingData.RotateSpeed[i]);
|
|
}
|
|
sb.Append('\n');
|
|
|
|
sb.Append("攻击范围:");
|
|
for (int i = 0; i < bearingData.AttackRange.Length; i++)
|
|
{
|
|
if (i != 0) sb.Append("|");
|
|
sb.Append(bearingData.AttackRange[i]);
|
|
}
|
|
sb.Append('\n');
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
public static string BuildBaseDesc(BaseCompItemData baseData)
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.Append("攻击速度:");
|
|
for (int i = 0; i < baseData.AttackSpeed.Length; i++)
|
|
{
|
|
if (i != 0) sb.Append("|");
|
|
sb.Append(baseData.AttackSpeed[i]);
|
|
}
|
|
sb.Append('\n');
|
|
|
|
sb.Append($"伤害属性:{ConvertAttackProperty(baseData.AttackPropertyType)}\n");
|
|
|
|
return sb.ToString();
|
|
}
|
|
|
|
public static string ConvertAttackMethod(AttackMethodType type)
|
|
{
|
|
return type switch
|
|
{
|
|
AttackMethodType.None => "无效",
|
|
AttackMethodType.NormalBullet => "发射子弹",
|
|
AttackMethodType.Range => "范围攻击",
|
|
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
|
|
};
|
|
}
|
|
|
|
public static string ConvertAttackProperty(AttackPropertyType type)
|
|
{
|
|
return type switch
|
|
{
|
|
AttackPropertyType.None => "无效",
|
|
AttackPropertyType.Physics => "<color=#ffff00ff>物理</color>", //yellow
|
|
AttackPropertyType.Fire => "<color=#ff0000ff>火</color>", //red
|
|
AttackPropertyType.Water => "<color=#00ffffff>水</color>", //cyan
|
|
AttackPropertyType.Earth => "<color=#00ff00ff>自然</color>", //lime
|
|
AttackPropertyType.Poison => "<color=#008000ff>毒</color>", //green
|
|
AttackPropertyType.Ice => "<color=#0000a0ff>冰</color>", //darkblue
|
|
_ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
|
|
};
|
|
}
|
|
}
|
|
} |