Files
valheim/Assets/_Valheim/Scripts/Data/EnemyInfo.cs
2025-07-04 14:16:14 +08:00

163 lines
3.7 KiB
C#

using System;
using System.Collections.Generic;
using Unity.Mathematics;
using UnityEngine;
using static XPlugin.Data.JsonLiteDB.JsonLiteDB;
public enum EnemyType
{
/// <summary>
/// 小鱼
/// </summary>
Fish,
/// <summary>
/// 小鱼人
/// </summary>
FishMan,
FishManEyePatchSword,
/// <summary>
/// 大鱼人
/// </summary>
FishMermanWithTrident,
/// <summary>
/// 小鱼领主
/// </summary>
FishGiant,
/// <summary>
/// 每关boss
/// </summary>
EnemyBoss,
}
public class EnemyInfo
{
public int ID;
public string Name;
public int EnemyType;
public int Lvl;
public float Hp;
public float Atk;
public float Rate;
public float Speed;
public int EnergyValue;
public int State;
public float AtkArea;
public float ModelScale;
public float Radius;
public float modelHeight;
public EnemyInfo(TableReader table)
{
ID = table["ID"].OptInt();
Name = table["Name"].OptString();
EnemyType = table["EnemyType"].OptInt();
Lvl = table["Lvl"].OptInt();
Hp = table["Hp"].OptFloat();
Atk = table["Atk"].OptFloat();
Rate = table["Rate"].OptFloat();
Speed = table["Speed"].OptFloat();
EnergyValue = table["EnergyValue"].OptInt();
State = table["State"].OptInt();
AtkArea = table["AtkArea"].OptFloat();
ModelScale = table["ModelScale"].OptFloat();
Radius = table["Radius"].OptFloat();
modelHeight = table["modelHeight"].OptFloat();
}
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;
}
}
public class EnemyData
{
public int EnemyId;
public int LevelId;
public int EnemyType;
public string Name;
public int Atk;
public int Hp;
public string EnemyDesc;
public int[] SkillIds;
public int Camp;
public EnemyData(TableReader table)
{
EnemyId=table["EnemyId"].OptInt();
LevelId = table["LevelIds"].OptInt() ;
EnemyType=table["EnemyType"].OptInt();
Name = table["Name"].OptString();
Atk = table["Atk"].OptInt();
Hp = table["Hp"].OptInt();
if (table["SkillIds"].OptString() != "")
{
//Debug.LogError("技能:"+table["SkillIds"].OptString());
string[] skillIds = table["SkillIds"].OptString().Replace("[", "").Replace("]", "").Split(',');
SkillIds=new int[skillIds.Length];
for (int i = 0; i < skillIds.Length; i++)
{
SkillIds[i] = int.Parse(skillIds[i]);
}
}
else
{
SkillIds = Array.Empty<int>();
}
Camp = table["Camp"].OptInt();
}
}
public class LevelData
{
public int ID;
public string LevelName;
public List<List<int>> LevelMonsters;
public LevelData(TableReader table)
{
ID = table["ID"].OptInt();
LevelName = table["LevelName"].OptString();
LevelMonsters = new List<List<int>>();
string[] monsters = table["LevelMonsters"].OptString().Split(';');
foreach (var str in monsters)
{
string[] s = str.Replace("(", "").Replace(")", "").Split(',');
List<int> list = new List<int>();
foreach (var x in s)
{
list.Add(int.Parse(x));
}
LevelMonsters.Add(list);
}
}
}