From c899cdbfb97f3d45bac919c915a5d7aabbd954a2 Mon Sep 17 00:00:00 2001
From: yhh <359807859@qq.com>
Date: Mon, 15 Jul 2019 09:58:14 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96itemManager?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Engine/CLEngine.Core/framework/ItemManager.cs | 46 ++++++++++++++++++-
1 file changed, 44 insertions(+), 2 deletions(-)
diff --git a/Engine/CLEngine.Core/framework/ItemManager.cs b/Engine/CLEngine.Core/framework/ItemManager.cs
index 3e8bbd7..1b077aa 100644
--- a/Engine/CLEngine.Core/framework/ItemManager.cs
+++ b/Engine/CLEngine.Core/framework/ItemManager.cs
@@ -49,6 +49,25 @@ namespace CLEngine.Core.framework
return item;
}
+ ///
+ /// 删除物品
+ ///
+ ///
+ ///
+ public static bool RemoveItem(ItemObject item)
+ {
+ foreach (var itemObject in _worldItem)
+ {
+ if (itemObject.Value == item)
+ {
+ _worldItem.Remove(itemObject.Key);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
///
/// 保存全局物品
///
@@ -61,12 +80,35 @@ namespace CLEngine.Core.framework
Directory.CreateDirectory(itemPath);
try
{
- CHelper.SerializeObject(Path.Combine(itemPath, "items.db"), _worldItem);
+ CHelper.SerializeObject(Path.Combine(itemPath, "worldItem.db"), _worldItem);
+ CHelper.SerializeObject(Path.Combine(itemPath, "worldId.db"), _worldId);
Logger.Info("物品保存成功");
}
catch (Exception e)
{
- throw new Exception(e.Message);
+ throw new Exception(e.Message, e);
+ }
+ }
+
+ ///
+ /// 加载全局物品
+ ///
+ private static void LoadWorldItem()
+ {
+ if (string.IsNullOrEmpty(SceneManager.GameProject.ProjectPath))
+ throw new Exception("未加载工程前无法加载物品信息");
+
+ var itemPath = Path.Combine(SceneManager.GameProject.ProjectPath, "Content", "Items");
+ try
+ {
+ _worldItem =
+ (Dictionary) CHelper.DeserializeObject(Path.Combine(itemPath, "worldItem.db"));
+ _worldId = (int) CHelper.DeserializeObject(Path.Combine(itemPath, "worldId.db"));
+ Logger.Info("物品加载成功");
+ }
+ catch (Exception e)
+ {
+ throw new Exception(e.Message, e);
}
}
}
--
Gitee
From 11d6d0a0e5765adb98b50ed48145ea0234249c63 Mon Sep 17 00:00:00 2001
From: yhh <359807859@qq.com>
Date: Mon, 15 Jul 2019 10:26:31 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=AD=A3database=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E7=BB=91=E5=AE=9A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CLEditor/viewmodel/DataBaseViewModel.cs | 16 +++++++++++++---
CLEditor/windows/DataBaseWindow.xaml | 2 +-
Engine/CLEngine.Core/framework/ItemManager.cs | 4 ++--
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/CLEditor/viewmodel/DataBaseViewModel.cs b/CLEditor/viewmodel/DataBaseViewModel.cs
index 3cd8590..e05f6e0 100644
--- a/CLEditor/viewmodel/DataBaseViewModel.cs
+++ b/CLEditor/viewmodel/DataBaseViewModel.cs
@@ -1,4 +1,5 @@
-using System.Collections.ObjectModel;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
using CLEngine.Core.framework;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
@@ -18,12 +19,21 @@ namespace CLEngine.Editor.viewmodel
/// 添加物品命令
///
public RelayCommand AddItemCommand { get; set; }
+ ///
+ /// 性别列表
+ ///
+ public List GenderTypes { get; set; }
- public DataBaseViewModel()
+ public DataBaseViewModel()
{
ItemObjects = new ObservableCollection();
AddItemCommand = new RelayCommand(AddItemAction);
- }
+ GenderTypes = new List()
+ {
+ "男",
+ "女"
+ };
+ }
private void AddItemAction()
{
diff --git a/CLEditor/windows/DataBaseWindow.xaml b/CLEditor/windows/DataBaseWindow.xaml
index 46fdbdd..6bb08a0 100644
--- a/CLEditor/windows/DataBaseWindow.xaml
+++ b/CLEditor/windows/DataBaseWindow.xaml
@@ -57,7 +57,7 @@
-
+
diff --git a/Engine/CLEngine.Core/framework/ItemManager.cs b/Engine/CLEngine.Core/framework/ItemManager.cs
index 7f7ee1e..9b5df57 100644
--- a/Engine/CLEngine.Core/framework/ItemManager.cs
+++ b/Engine/CLEngine.Core/framework/ItemManager.cs
@@ -88,7 +88,7 @@ namespace CLEngine.Core.framework
try
{
CHelper.SerializeObject(Path.Combine(itemPath, "worldItem.db"), _worldItem);
- CHelper.SerializeObject(Path.Combine(itemPath, "worldId.db"), _worldId);
+ CHelper.SerializeObject(Path.Combine(itemPath, "worldId.db"), WorldId);
Logger.Info("物品保存成功");
}
catch (Exception e)
@@ -110,7 +110,7 @@ namespace CLEngine.Core.framework
{
_worldItem =
(Dictionary) CHelper.DeserializeObject(Path.Combine(itemPath, "worldItem.db"));
- _worldId = (int) CHelper.DeserializeObject(Path.Combine(itemPath, "worldId.db"));
+ WorldId = (int) CHelper.DeserializeObject(Path.Combine(itemPath, "worldId.db"));
Logger.Info("物品加载成功");
}
catch (Exception e)
--
Gitee
From 023332d75c425e159523be85806eb0a93e68936b Mon Sep 17 00:00:00 2001
From: yhh <359807859@qq.com>
Date: Mon, 15 Jul 2019 10:29:27 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=95=B0=E6=8D=AE?=
=?UTF-8?q?=E8=87=B3frameworksettings?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CLEditor/viewmodel/DataBaseViewModel.cs | 9 +++------
Engine/CLEngine.Core/framework/FrameworkSettings.cs | 9 +++++++++
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/CLEditor/viewmodel/DataBaseViewModel.cs b/CLEditor/viewmodel/DataBaseViewModel.cs
index e05f6e0..888d480 100644
--- a/CLEditor/viewmodel/DataBaseViewModel.cs
+++ b/CLEditor/viewmodel/DataBaseViewModel.cs
@@ -22,17 +22,14 @@ namespace CLEngine.Editor.viewmodel
///
/// 性别列表
///
- public List GenderTypes { get; set; }
+ public List GenderTypes {
+ get { return FrameworkSettings.GenderTypes; }
+ }
public DataBaseViewModel()
{
ItemObjects = new ObservableCollection();
AddItemCommand = new RelayCommand(AddItemAction);
- GenderTypes = new List()
- {
- "男",
- "女"
- };
}
private void AddItemAction()
diff --git a/Engine/CLEngine.Core/framework/FrameworkSettings.cs b/Engine/CLEngine.Core/framework/FrameworkSettings.cs
index 223dc3c..20fbb5b 100644
--- a/Engine/CLEngine.Core/framework/FrameworkSettings.cs
+++ b/Engine/CLEngine.Core/framework/FrameworkSettings.cs
@@ -37,5 +37,14 @@ namespace CLEngine.Core.framework
{"物品",new List{"消耗品","任务用品","材料","礼包" } },
{"装备",new List{"武器","鞋子","帽子","衣服","裤子","首饰","戒指" } },
};
+
+ ///
+ /// 性别列表
+ ///
+ public static List GenderTypes = new List()
+ {
+ "男",
+ "女"
+ };
}
}
\ No newline at end of file
--
Gitee