diff --git a/CLEditor/viewmodel/DataBaseViewModel.cs b/CLEditor/viewmodel/DataBaseViewModel.cs
index 3cd85901e703697167182cd187be4feeaf2eabe8..888d480863a8c58be39b6c8d805f44b22ce96637 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,18 @@ namespace CLEngine.Editor.viewmodel
/// 添加物品命令
///
public RelayCommand AddItemCommand { get; set; }
+ ///
+ /// 性别列表
+ ///
+ public List GenderTypes {
+ get { return FrameworkSettings.GenderTypes; }
+ }
- public DataBaseViewModel()
+ public DataBaseViewModel()
{
ItemObjects = new ObservableCollection();
AddItemCommand = new RelayCommand(AddItemAction);
- }
+ }
private void AddItemAction()
{
diff --git a/CLEditor/windows/DataBaseWindow.xaml b/CLEditor/windows/DataBaseWindow.xaml
index 46fdbdd5401cea9ebd344441f140b37d9e8e55c3..6bb08a0933d92db120fb8121d8cffc15ebc09898 100644
--- a/CLEditor/windows/DataBaseWindow.xaml
+++ b/CLEditor/windows/DataBaseWindow.xaml
@@ -57,7 +57,7 @@
-
+
diff --git a/Engine/CLEngine.Core/framework/FrameworkSettings.cs b/Engine/CLEngine.Core/framework/FrameworkSettings.cs
index 223dc3c829d423432047c0f0d4c734c37926d0e4..20fbb5ba06faf48d421f32f8636fe2f70e3521de 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
diff --git a/Engine/CLEngine.Core/framework/ItemManager.cs b/Engine/CLEngine.Core/framework/ItemManager.cs
index f0273e365db2fbfd0b403c5205ba9cd1ea4fe299..9b5df57a963b1d952bdeab72bc88af774d28d88e 100644
--- a/Engine/CLEngine.Core/framework/ItemManager.cs
+++ b/Engine/CLEngine.Core/framework/ItemManager.cs
@@ -56,6 +56,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;
+ }
+
///
/// 保存全局物品
///
@@ -68,12 +87,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);
}
}
///