(client) fix:修复匿名定义中的图片无法加载的问题
This commit is contained in:
@ -2,32 +2,10 @@
|
||||
|
||||
namespace Data
|
||||
{
|
||||
public class CharacterAttributesDef : Define
|
||||
public class AttributesDef : Define
|
||||
{
|
||||
public int health = 10;
|
||||
public int moveSpeed = 1;
|
||||
}
|
||||
public class WeaponAttributesDef : Define
|
||||
{
|
||||
public int attack = 1;
|
||||
public int defense = 0;
|
||||
public int attackSpeed = 2;
|
||||
public int attackRange = 3;
|
||||
public int attackTargetCount = 1;
|
||||
}
|
||||
public class MonsterAttributesDef : Define
|
||||
{
|
||||
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;
|
||||
}
|
||||
public class BuildingAttributesDef : Define
|
||||
{
|
||||
public int health = 10;
|
||||
public int attack = 1;
|
||||
public int defense = 0;
|
||||
public int attackSpeed = 2;
|
||||
|
@ -22,54 +22,13 @@ namespace Data
|
||||
Animation
|
||||
}
|
||||
|
||||
public class CharacterDef : Define
|
||||
public class CharacterDef : PawnDef
|
||||
{
|
||||
public CharacterAttributesDef attributes;
|
||||
public string texturePath = null;
|
||||
public DrawingOrderDef
|
||||
drawingOrder_down,
|
||||
drawingOrder_up,
|
||||
drawingOrder_left,
|
||||
drawingOrder_right;
|
||||
|
||||
public DrawingOrderDef GetDrawingOrder(Orientation orientation)
|
||||
{
|
||||
// 定义一个临时变量用于存储结果
|
||||
DrawingOrderDef result = null;
|
||||
|
||||
// 根据传入的 Orientation 获取对应的 DrawingOrderDef
|
||||
switch (orientation)
|
||||
{
|
||||
case Orientation.Down:
|
||||
result = drawingOrder_down;
|
||||
break;
|
||||
case Orientation.Up:
|
||||
result = drawingOrder_up;
|
||||
break;
|
||||
case Orientation.Left:
|
||||
result = drawingOrder_left;
|
||||
break;
|
||||
case Orientation.Right:
|
||||
result = drawingOrder_right;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Invalid orientation value.");
|
||||
}
|
||||
|
||||
// 如果当前方向的结果为空,则尝试用 drawingOrder_down 填充
|
||||
if (result == null) result = drawingOrder_down;
|
||||
|
||||
// 如果 drawingOrder_down 仍然为空,则尝试用其他非空方向填充
|
||||
if (result == null) result = drawingOrder_up ?? drawingOrder_left ?? drawingOrder_right;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public class DrawingOrderDef : Define
|
||||
{
|
||||
public List<DrawNodeDef> drawNodes = new();
|
||||
|
||||
public override bool Init(XElement xmlDef)
|
||||
{
|
||||
base.Init(xmlDef);
|
||||
|
8
Client/Assets/Scripts/Data/ItemDefine.cs
Normal file
8
Client/Assets/Scripts/Data/ItemDefine.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Data
|
||||
{
|
||||
public class ItemDefine:Define
|
||||
{
|
||||
public ImageDef texture;
|
||||
public AttributesDef attributes;
|
||||
}
|
||||
}
|
3
Client/Assets/Scripts/Data/ItemDefine.cs.meta
Normal file
3
Client/Assets/Scripts/Data/ItemDefine.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c4d338c5c7b24cd5a496acb98ebf5e3c
|
||||
timeCreated: 1752760211
|
51
Client/Assets/Scripts/Data/PawnDefine.cs
Normal file
51
Client/Assets/Scripts/Data/PawnDefine.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
public class PawnDef : Define
|
||||
{
|
||||
public string aiController;
|
||||
public string texturePath = null;
|
||||
public DrawingOrderDef
|
||||
drawingOrder_down,
|
||||
drawingOrder_up,
|
||||
drawingOrder_left,
|
||||
drawingOrder_right;
|
||||
public DrawingOrderDef GetDrawingOrder(Orientation orientation)
|
||||
{
|
||||
// 定义一个临时变量用于存储结果
|
||||
DrawingOrderDef result = null;
|
||||
|
||||
// 根据传入的 Orientation 获取对应的 DrawingOrderDef
|
||||
switch (orientation)
|
||||
{
|
||||
case Orientation.Down:
|
||||
result = drawingOrder_down;
|
||||
break;
|
||||
case Orientation.Up:
|
||||
result = drawingOrder_up;
|
||||
break;
|
||||
case Orientation.Left:
|
||||
result = drawingOrder_left;
|
||||
break;
|
||||
case Orientation.Right:
|
||||
result = drawingOrder_right;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("Invalid orientation value.");
|
||||
}
|
||||
|
||||
// 如果当前方向的结果为空,则尝试用 drawingOrder_down 填充
|
||||
if (result == null) result = drawingOrder_down;
|
||||
|
||||
// 如果 drawingOrder_down 仍然为空,则尝试用其他非空方向填充
|
||||
if (result == null) result = drawingOrder_up ?? drawingOrder_left ?? drawingOrder_right;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public class MonsterDef:PawnDef
|
||||
{
|
||||
|
||||
}
|
||||
}
|
3
Client/Assets/Scripts/Data/PawnDefine.cs.meta
Normal file
3
Client/Assets/Scripts/Data/PawnDefine.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a89bc126c0a466799f6ccb963267419
|
||||
timeCreated: 1752751832
|
Reference in New Issue
Block a user