From a13dc3da1641ec4093081f532781f0de88c25132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=94=E5=87=A4=E5=95=B8=E5=A4=A9?= <1379113792@qq.com> Date: Tue, 9 Jul 2019 13:07:06 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=80=BC=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Engine/CLEngine.Core/framework/ItemObject.cs | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Engine/CLEngine.Core/framework/ItemObject.cs b/Engine/CLEngine.Core/framework/ItemObject.cs index 497fab6..113ee60 100644 --- a/Engine/CLEngine.Core/framework/ItemObject.cs +++ b/Engine/CLEngine.Core/framework/ItemObject.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; +using System.Collections; namespace CLEngine.Core.framework { @@ -52,6 +53,7 @@ namespace CLEngine.Core.framework [DataMember] private int _addHeroMp; [DataMember] private int _addReturnHp;//回血 [DataMember] private int _addReturnMp;//回蓝 + [DataMember] private Dictionary customProp; /// /// 物品类型 /// @@ -121,6 +123,28 @@ namespace CLEngine.Core.framework /// public int AddReturnMp { get { return _addReturnMp; } set { _addReturnMp = value; } } /// + /// 设置自定义值 + /// + /// + /// + public void SetcustomProp(string name, object customprop) + { + if (customProp.ContainsKey(name)) + { + throw new Exception("自定义值" + name + "不允许重复"); + } + customProp[name] = customprop; + } + /// + /// 获取自定义值 + /// + /// + /// + public object GetcustomProp(string name) + { + return customProp[name]; + } + /// /// 使用物品 /// public void UseItem() -- Gitee From 72a28eea065801020b4fc8712c4fa48b7543fe6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=94=E5=87=A4=E5=95=B8=E5=A4=A9?= <1379113792@qq.com> Date: Tue, 9 Jul 2019 13:29:17 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=96=B0=E5=A2=9EItemObject=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Engine/CLEngine.Core/framework/ItemObject.cs | 33 +++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Engine/CLEngine.Core/framework/ItemObject.cs b/Engine/CLEngine.Core/framework/ItemObject.cs index 113ee60..0547fe6 100644 --- a/Engine/CLEngine.Core/framework/ItemObject.cs +++ b/Engine/CLEngine.Core/framework/ItemObject.cs @@ -5,6 +5,8 @@ using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using System.Collections; +using Microsoft.Xna.Framework.Graphics; +using System.IO; namespace CLEngine.Core.framework { @@ -16,6 +18,9 @@ namespace CLEngine.Core.framework userId = user; } } +#if WIN + [Serializable] +#endif public class ItemObject { /// @@ -54,6 +59,7 @@ namespace CLEngine.Core.framework [DataMember] private int _addReturnHp;//回血 [DataMember] private int _addReturnMp;//回蓝 [DataMember] private Dictionary customProp; + [NonSerialized] private Texture2D _texture; /// /// 物品类型 /// @@ -69,7 +75,32 @@ namespace CLEngine.Core.framework /// /// 物品图标路径 /// - public string IconPath { get { return _iconPath; } set { _iconPath = value; } } + public string IconPath { + get { return _iconPath; } + set { + _iconPath = value; + if (string.IsNullOrEmpty(_iconPath)) + { + IconTex = null; + } + else if (File.Exists(_iconPath)) + { + IconTex = TextureLoader.FromContent(_iconPath); + } + else + { + throw new Exception("文件"+_iconPath+"不存在"); + } + } + } + /// + /// 图标图片 + /// + public Texture2D IconTex + { + get { return _texture; } + set { _texture = value; } + } /// /// 持有者id /// -- Gitee From e0ca4552fdbf5e585428a5b000f341a3055cf974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=94=E5=87=A4=E5=95=B8=E5=A4=A9?= <1379113792@qq.com> Date: Tue, 9 Jul 2019 13:30:43 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=96=B0=E5=A2=9Edatacontract?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Engine/CLEngine.Core/framework/ItemObject.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Engine/CLEngine.Core/framework/ItemObject.cs b/Engine/CLEngine.Core/framework/ItemObject.cs index 0547fe6..84992e9 100644 --- a/Engine/CLEngine.Core/framework/ItemObject.cs +++ b/Engine/CLEngine.Core/framework/ItemObject.cs @@ -21,6 +21,7 @@ namespace CLEngine.Core.framework #if WIN [Serializable] #endif + [DataContract] public class ItemObject { /// -- Gitee