using static XPlugin.Data.JsonLiteDB.JsonLiteDB; public enum EnemyType { ThinZombie=0, FatZombie=1, ExplosionDog=2, RunZombie=3, ZombieBoss = 4, } public class EnemyInfo { public int ID; public int Type; public string Name; public string CN_Name; public int Lvl; public float Hp; public float Atk; public float SpecialAtk1; public float SpecialAtk2; public float Speed; public float Frequency;//攻击频率 public int Score; public int Weight;//权重 public float MinAtkArea; public float MaxAtkArea; public EnemyInfo(TableReader table) { ID = table["ID"].OptInt(); Type = table["Type"].OptInt(); Name = table["Name"].OptString(); CN_Name = table["CN_Name"].OptString(); Lvl = table["Lvl"].OptInt(); Hp = table["Hp"].OptFloat(); Atk = table["Atk"].OptFloat(); Speed = table["Speed"].OptFloat(); SpecialAtk1 = table["SpecialAtk1"].OptInt(); SpecialAtk2= table["SpecialAtk2"].OptFloat(); Frequency = table["Frequency"].OptFloat(); Score = table["Score"].OptInt(); Weight = table["Weight"].OptInt(); float[] areas = ParseStringToIntArray(table["AtkArea"].OptString()); MinAtkArea = areas[0]; MaxAtkArea = areas[1]; } float[] ParseStringToIntArray(string input) { if (input == "") { return null; } string[] elements = input.Replace("[", "").Replace("]", "").Split(','); float[] intArray = new float[elements.Length]; for (int i = 0; i < elements.Length; i++) { intArray[i] = float.Parse(elements[i]); } return intArray; } }