118 lines
2.8 KiB
C#
118 lines
2.8 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using static XPlugin.Data.JsonLiteDB.JsonLiteDB;
|
||
|
||
public class StoryDeamonInfo
|
||
{
|
||
public int Id;
|
||
|
||
public int CrackAmount;
|
||
|
||
public Vector3[] CracksPos;
|
||
|
||
public Vector3[] Angle;
|
||
|
||
public int EnemyAmount;
|
||
|
||
public Vector3[] EnemysPos;
|
||
|
||
|
||
|
||
public int ALLEnemyAmount;
|
||
|
||
public float[] CreateInterva;
|
||
|
||
|
||
public int type;
|
||
|
||
public int Wait;
|
||
|
||
|
||
public StoryDeamonInfo(TableReader table)
|
||
{
|
||
|
||
Id = table["ID"].OptInt();
|
||
CrackAmount = table["CrackAmount"].OptInt();
|
||
|
||
string crackpos = table["CracksPos"].OptString();
|
||
CracksPos = ParseStringToVectorArray(crackpos);
|
||
//Angle
|
||
string angle = table["Angle"].OptString();
|
||
Angle = ParseStringToVectorArray(angle);
|
||
|
||
EnemyAmount = table["EnemyAmount"].OptInt();
|
||
|
||
string enemyspos = table["EnemysPos"].OptString();
|
||
|
||
EnemysPos = ParseStringToVectorArray(enemyspos);
|
||
|
||
ALLEnemyAmount = table["ALLEnemyAmount"].OptInt();
|
||
|
||
string createInterva = table["CreateInterva"].OptString();
|
||
CreateInterva = ParseStringToFloatArray(createInterva);
|
||
type = table["type"].OptInt();
|
||
|
||
Wait = table["Wait"].OptInt();
|
||
|
||
}
|
||
|
||
Vector3[] ParseStringToVectorArray(string input)
|
||
{
|
||
|
||
Debug.Log(input);
|
||
if (input == "")
|
||
{
|
||
|
||
return null;
|
||
}
|
||
|
||
string[] elements = input.Replace("(", "").Replace(")", "").Split(',');
|
||
|
||
List<Vector3> vectorList = new List<Vector3>();
|
||
|
||
for (int i = 0; i < elements.Length; i += 3)
|
||
{
|
||
// 将每三个元素解析为一个 Vector3,并添加到列表中
|
||
float x = float.Parse(elements[i]);
|
||
float y = float.Parse(elements[i + 1]);
|
||
float z = float.Parse(elements[i + 2]);
|
||
vectorList.Add(new Vector3(x, y, z));
|
||
}
|
||
return vectorList.ToArray();
|
||
|
||
}
|
||
|
||
|
||
|
||
int[] ParseStringToIntArray(string input)
|
||
{
|
||
// 去除字符串中的括号,并以逗号分割成元素数组
|
||
string[] elements = input.Replace("(", "").Replace(")", "").Split(',');
|
||
int[] intArray = new int[elements.Length];
|
||
|
||
for (int i = 0; i < elements.Length; i++)
|
||
{
|
||
// 将每个元素解析为整数并存入整数数组
|
||
intArray[i] = int.Parse(elements[i]);
|
||
}
|
||
|
||
return intArray;
|
||
}
|
||
|
||
float[] ParseStringToFloatArray(string input)
|
||
{
|
||
// 去除字符串中的括号,并以逗号分割成元素数组
|
||
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;
|
||
}
|
||
}
|