(client) feat:定义部分消息文件
This commit is contained in:
@ -343,23 +343,6 @@ namespace Data
|
|||||||
// 如果字段的类型直接是基类或其派生类,则返回 true
|
// 如果字段的类型直接是基类或其派生类,则返回 true
|
||||||
return fieldType != baseType && baseType.IsAssignableFrom(fieldType);
|
return fieldType != baseType && baseType.IsAssignableFrom(fieldType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 检查字段的类型是否继承自指定的类
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="field">字段信息</param>
|
|
||||||
/// <param name="baseType">要检查的基类类型</param>
|
|
||||||
/// <returns>如果字段的类型是基类或其派生类,则返回 true</returns>
|
|
||||||
public static bool IsFieldTypeInheritedFrom(FieldInfo field, Type baseType)
|
|
||||||
{
|
|
||||||
// 获取字段的类型
|
|
||||||
var fieldType = field.FieldType;
|
|
||||||
// 如果字段的类型为 null 或不是基类的派生类,则返回 false
|
|
||||||
if (!baseType.IsAssignableFrom(fieldType))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// 如果字段的类型直接是基类或其派生类,则返回 true
|
|
||||||
return fieldType != baseType && baseType.IsAssignableFrom(fieldType);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
18
Client/Assets/Scripts/Entity/Monster.cs
Normal file
18
Client/Assets/Scripts/Entity/Monster.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
namespace Entity
|
||||||
|
{
|
||||||
|
public class Monster
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MonsterAttributes
|
||||||
|
{
|
||||||
|
public int health = 10;
|
||||||
|
public int moveSpeed = 1;
|
||||||
|
public int attack = 1;
|
||||||
|
public int defense = 0;
|
||||||
|
public int attackSpeed = 2;
|
||||||
|
public int attackRange = 3;
|
||||||
|
public int attackTargetCount = 1;
|
||||||
|
}
|
||||||
|
}
|
3
Client/Assets/Scripts/Entity/Monster.cs.meta
Normal file
3
Client/Assets/Scripts/Entity/Monster.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 32995e4c8e0d40dfa39990f0671a3733
|
||||||
|
timeCreated: 1752576973
|
File diff suppressed because it is too large
Load Diff
@ -49,4 +49,57 @@ message SignupRequest {
|
|||||||
message SignupResponse {
|
message SignupResponse {
|
||||||
RequestResult result = 1;
|
RequestResult result = 1;
|
||||||
string message = 2;
|
string message = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义 FilePack 消息
|
||||||
|
message FilePack {
|
||||||
|
string filePath = 1;
|
||||||
|
bytes content = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义 DataPackListPack 消息
|
||||||
|
message DataPackListPack {
|
||||||
|
repeated Pair packIDAndVersion = 1;
|
||||||
|
|
||||||
|
// 定义内部的 Pair 消息(用于替代 Tuple<string, string>)
|
||||||
|
message Pair {
|
||||||
|
string key = 1;
|
||||||
|
string value = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义 TileMapTablePack 消息
|
||||||
|
message TileMapTablePack {
|
||||||
|
map<int32, string> tileMapKey = 1; // 使用 int32 替代 int
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义 MapDataPack 消息
|
||||||
|
message MapDataPack {
|
||||||
|
Vector2 position = 1;
|
||||||
|
Vector2 size = 2;
|
||||||
|
repeated int32 tileMapType = 3; // 使用 int32 替代 int
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义 MonsterAttributes 消息
|
||||||
|
message MonsterAttributes {
|
||||||
|
int32 health = 1;
|
||||||
|
int32 moveSpeed = 2;
|
||||||
|
int32 attack = 3;
|
||||||
|
int32 defense = 4;
|
||||||
|
int32 attackSpeed = 5;
|
||||||
|
int32 attackRange = 6;
|
||||||
|
int32 attackTargetCount = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义 MonsterPack 消息
|
||||||
|
message MonsterPack {
|
||||||
|
int32 monsterID = 1;
|
||||||
|
Vector2 position = 2;
|
||||||
|
MonsterAttributes attributes = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义 Vector2 消息
|
||||||
|
message Vector2 {
|
||||||
|
float x = 1;
|
||||||
|
float y = 2;
|
||||||
}
|
}
|
Reference in New Issue
Block a user