226 lines
6.5 KiB
C#
226 lines
6.5 KiB
C#
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using UnityEngine;
|
||
using static XPlugin.Data.JsonLiteDB.JsonLiteDB;
|
||
|
||
public class StoryInfo
|
||
{
|
||
|
||
public int Id;
|
||
|
||
public int NextId;
|
||
|
||
public int[] CrackAmount;
|
||
|
||
public Vector3[] CracksPos;
|
||
|
||
public Vector3[] Angle;
|
||
|
||
public int[] EnemyAmount;
|
||
|
||
public Vector3[] EnemysScale;
|
||
|
||
|
||
public Vector3[] EnemysPos;
|
||
|
||
public int[] ALLEnemyAmount;
|
||
|
||
public float[] CreateInterva;
|
||
|
||
|
||
public int type;
|
||
|
||
public int Wait;
|
||
|
||
/// <summary>
|
||
/// <20><><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>)
|
||
/// </summary>
|
||
public int ItemRule;
|
||
|
||
public Dictionary<int, int> BulletAmount = new Dictionary<int, int>();
|
||
|
||
/// <summary>
|
||
/// <20><><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD>(<28><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD>ֿ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>)
|
||
/// </summary>
|
||
public int[] ItemDrop;
|
||
|
||
/// <summary>
|
||
/// StoryItem
|
||
/// </summary>
|
||
public Dictionary<int, Vector3> EnergyPump = new Dictionary<int, Vector3>();
|
||
public Dictionary<int, Vector3> EnergyMask = new Dictionary<int, Vector3>();
|
||
/// <summary>
|
||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
||
/// </summary>
|
||
/// <param name="table"></param>
|
||
public int PathId;
|
||
|
||
|
||
|
||
|
||
public StoryInfo(TableReader table)
|
||
{
|
||
|
||
Id = table["ID"].OptInt();
|
||
NextId = table["NextId"].OptInt();
|
||
|
||
string crackAmount = table["CrackAmount"].OptString();
|
||
CrackAmount = ParseStringToIntArray(crackAmount);
|
||
|
||
string crackpos = table["CracksPos"].OptString();
|
||
CracksPos = ParseStringToVectorArray(crackpos);
|
||
//Angle
|
||
string angle = table["Angle"].OptString();
|
||
Angle = ParseStringToVectorArray(angle);
|
||
|
||
string enemyAmount = table["EnemyAmount"].OptString();
|
||
EnemyAmount = ParseStringToIntArray(enemyAmount);
|
||
|
||
string enemyscale = table["EnemysScale"].OptString();
|
||
EnemysScale = ParseStringToVectorArray(enemyscale);
|
||
|
||
string enemyspos = table["EnemysPos"].OptString();
|
||
EnemysPos = ParseStringToVectorArray(enemyspos);
|
||
|
||
string allEnemyAmount = table["ALLEnemyAmount"].OptString();
|
||
ALLEnemyAmount = ParseStringToIntArray(allEnemyAmount);
|
||
|
||
string createInterva = table["CreateInterva"].OptString();
|
||
CreateInterva = ParseStringToFloatArray(createInterva);
|
||
type = table["type"].OptInt();
|
||
|
||
Wait = table["Wait"].OptInt();
|
||
|
||
ItemRule = table["ItemRule"].OptInt();
|
||
|
||
|
||
string bulletAmount = table["BulletAmount"].OptString();
|
||
BulletAmount = ParseToDictionary(bulletAmount);
|
||
|
||
string itemDrop = table["ItemDrop"].OptString();
|
||
ItemDrop = ParseStringToIntArray(itemDrop);
|
||
|
||
string energyPump = table["EnergyPump"].OptString();
|
||
EnergyPump = ParseStringToDictionary(energyPump);
|
||
|
||
string energyMask = table["EnergyMask"].OptString();
|
||
EnergyMask = ParseStringToDictionary(energyMask);
|
||
|
||
PathId = table["PathId"].OptInt();
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
Vector3[] ParseStringToVectorArray(string input)
|
||
{
|
||
if (input == "")
|
||
{
|
||
|
||
return null;
|
||
}
|
||
|
||
//Debug.Log(input);
|
||
string[] elements = input.Replace("(", "").Replace(")", "").Split(',');
|
||
|
||
List<Vector3> vectorList = new List<Vector3>();
|
||
|
||
for (int i = 0; i < elements.Length; i += 3)
|
||
{
|
||
// <20><>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD>Ԫ<EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD>Ϊһ<CEAA><D2BB> Vector3<72><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>б<EFBFBD><D0B1><EFBFBD>
|
||
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();
|
||
|
||
}
|
||
//Unity "(505, (7.83, 1, -11.59))"
|
||
Dictionary<int, Vector3> ParseStringToDictionary(string input)
|
||
{
|
||
if (input == "")
|
||
{
|
||
return null;
|
||
}
|
||
|
||
Dictionary<int, Vector3> result = new Dictionary<int, Vector3>();
|
||
|
||
float[] tempArry = ParseStringToFloatArray(input);
|
||
|
||
//string[] elements = input.Replace("(", "").Replace(")", "").Split(',');
|
||
float x = tempArry[1];
|
||
float y = tempArry[2];
|
||
float z = tempArry[3];
|
||
Vector3 vector3 = new Vector3(x, y, z);
|
||
|
||
int key = (int)tempArry[0];
|
||
result.Add(key, vector3);
|
||
|
||
return result;
|
||
}
|
||
|
||
|
||
int[] ParseStringToIntArray(string input)
|
||
{
|
||
if (input == "")
|
||
{
|
||
return null;
|
||
}
|
||
|
||
// ȥ<><C8A5><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6>ŷָ<C5B7><D6B8>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
string[] elements = input.Replace("(", "").Replace(")", "").Split(',');
|
||
int[] intArray = new int[elements.Length];
|
||
|
||
for (int i = 0; i < elements.Length; i++)
|
||
{
|
||
// <20><>ÿ<EFBFBD><C3BF>Ԫ<EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
intArray[i] = int.Parse(elements[i]);
|
||
}
|
||
|
||
return intArray;
|
||
}
|
||
|
||
float[] ParseStringToFloatArray(string input)
|
||
{
|
||
// ȥ<><C8A5><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6>ŷָ<C5B7><D6B8>Ԫ<EFBFBD><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
string[] elements = input.Replace("(", "").Replace(")", "").Split(',');
|
||
float[] intArray = new float[elements.Length];
|
||
|
||
for (int i = 0; i < elements.Length; i++)
|
||
{
|
||
// <20><>ÿ<EFBFBD><C3BF>Ԫ<EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
intArray[i] = float.Parse(elements[i]);
|
||
}
|
||
|
||
return intArray;
|
||
}
|
||
|
||
|
||
static Dictionary<int, int> ParseToDictionary(string input)
|
||
{
|
||
// "((1,1000),(4,20))" ȥ<><C8A5><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>,<2C><>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>һ<EFBFBD><D2BB>Ԫ<EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>Key,<2C>ڶ<EFBFBD><DAB6><EFBFBD>Ԫ<EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>value <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Dictionary<int,int>
|
||
|
||
// <20>Ƴ<EFBFBD><C6B3>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>еķ<D0B5><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>
|
||
string cleanedInput = new string(input.Where(c => char.IsDigit(c) || c == ',' || c == '(' || c == ')').ToArray());
|
||
|
||
// <20><><EFBFBD>ݶ<EFBFBD><DDB6>ź<EFBFBD><C5BA><EFBFBD><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ɼ<EFBFBD>ֵ<EFBFBD><D6B5>
|
||
string[] pairs = cleanedInput.Split(new char[] { '(', ')', ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||
|
||
// <20><><EFBFBD><EFBFBD> Dictionary <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>
|
||
Dictionary<int, int> dict = new Dictionary<int, int>();
|
||
for (int i = 0; i < pairs.Length; i += 2)
|
||
{
|
||
int key = int.Parse(pairs[i]);
|
||
int value = int.Parse(pairs[i + 1]);
|
||
dict[key] = value;
|
||
}
|
||
return dict;
|
||
}
|
||
}
|
||
|
||
|