(client) feat:添加自定义瓦片和图片资源自定义加载 (#38)
Co-authored-by: zzdxxz <2079238449@qq.com> Co-committed-by: zzdxxz <2079238449@qq.com>
This commit is contained in:
@ -8,13 +8,15 @@ using System.Xml.Linq;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
public abstract class Define
|
||||
public class Define
|
||||
{
|
||||
public string defName;
|
||||
public string description;
|
||||
public string label;
|
||||
public string packID;
|
||||
|
||||
public bool isReferene=false;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化方法,根据传入的 XML 元素 (<paramref name="xmlDef" />) 进行处理。
|
||||
/// </summary>
|
||||
@ -112,18 +114,5 @@ namespace Data
|
||||
return string.Join(Environment.NewLine, text.Split('\n').Select(line => prefix + line));
|
||||
}
|
||||
}
|
||||
|
||||
public class DefineReference : Define
|
||||
{
|
||||
public Define def;
|
||||
public string className;
|
||||
public string fieldName;
|
||||
|
||||
public DefineReference(string className, string defName, string fieldName)
|
||||
{
|
||||
this.defName = defName;
|
||||
this.className = className;
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -107,10 +107,19 @@ namespace Data
|
||||
|
||||
public PackAbout packAbout;
|
||||
public string packID;
|
||||
public string packRootPath;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return packAbout.name;
|
||||
}
|
||||
}
|
||||
|
||||
public bool LoadPack(string packPath)
|
||||
{
|
||||
packRootPath=System.IO.Path.GetFullPath(packPath);;
|
||||
var packDatas = ConfigProcessor.LoadXmlFromPath(packPath);
|
||||
var aboutXmls = FindDocumentsWithRootName(packDatas, "About");
|
||||
if (aboutXmls == null || aboutXmls.Count < 1)
|
||||
@ -262,8 +271,12 @@ namespace Data
|
||||
}
|
||||
else
|
||||
{
|
||||
value = new DefineReference(field.FieldType.Name, element.Value, field.Name);
|
||||
|
||||
var reference = (Define)Activator.CreateInstance(field.FieldType);
|
||||
reference.isReferene = true;
|
||||
reference.description=field.FieldType.Name;
|
||||
reference.label = field.Name;
|
||||
reference.defName = element.Value;
|
||||
value = reference;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -8,7 +8,7 @@ namespace Data
|
||||
{
|
||||
public class TileDef : Define
|
||||
{
|
||||
public string texturePath = "";
|
||||
public ImageDef texture;
|
||||
public string name = "";
|
||||
|
||||
public override bool Init(XElement xmlDef)
|
||||
@ -45,6 +45,7 @@ namespace Data
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
20
Client/Assets/Scripts/Data/ResourcesDefine.cs
Normal file
20
Client/Assets/Scripts/Data/ResourcesDefine.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
public class ImageDef : Define
|
||||
{
|
||||
public string name;
|
||||
public string path;
|
||||
public int wCount;
|
||||
public int hCount;
|
||||
public int pixelsPerUnit = 16;
|
||||
|
||||
public override bool Init(XElement xmlDef)
|
||||
{
|
||||
base.Init(xmlDef);
|
||||
name = defName;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
3
Client/Assets/Scripts/Data/ResourcesDefine.cs.meta
Normal file
3
Client/Assets/Scripts/Data/ResourcesDefine.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8988509c3c0f4525871f5ccd7ef28363
|
||||
timeCreated: 1752672894
|
Reference in New Issue
Block a user