From 21a25148e68114ffe8012514ef458857074617fa Mon Sep 17 00:00:00 2001
From: yhh <359807859@qq.com>
Date: Wed, 29 Aug 2018 23:42:18 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EC#=E7=9A=84Game=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CLEditor.Core/IBehaviour.cs | 1 +
CLEditor/Properties/AssemblyInfo.cs | 4 ++--
CLEngine/CGame.Api.cs | 19 +++++++++++++++++++
CLEngine/CGame.cs | 13 ++++++++-----
CLEngine/CLEngine.csproj | 1 +
CLEngine/Templates/Core.cs | 4 ++++
CLEngine/Templates/importEngine.lua | 2 ++
ExePacker.iss | 2 +-
8 files changed, 38 insertions(+), 8 deletions(-)
create mode 100644 CLEngine/CGame.Api.cs
diff --git a/CLEditor.Core/IBehaviour.cs b/CLEditor.Core/IBehaviour.cs
index e1cdc61..d630e54 100644
--- a/CLEditor.Core/IBehaviour.cs
+++ b/CLEditor.Core/IBehaviour.cs
@@ -7,6 +7,7 @@ namespace CLEngine
///
public interface IBehaviour
{
+ Game Game { get; set; }
///
/// 初始化游戏
///
diff --git a/CLEditor/Properties/AssemblyInfo.cs b/CLEditor/Properties/AssemblyInfo.cs
index 4a2af17..909480b 100644
--- a/CLEditor/Properties/AssemblyInfo.cs
+++ b/CLEditor/Properties/AssemblyInfo.cs
@@ -49,5 +49,5 @@ using System.Windows;
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("3.0.5.5")]
-[assembly: AssemblyFileVersion("3.0.5.5")]
+[assembly: AssemblyVersion("3.0.5.6")]
+[assembly: AssemblyFileVersion("3.0.5.6")]
diff --git a/CLEngine/CGame.Api.cs b/CLEngine/CGame.Api.cs
new file mode 100644
index 0000000..75fdb92
--- /dev/null
+++ b/CLEngine/CGame.Api.cs
@@ -0,0 +1,19 @@
+using Microsoft.Xna.Framework;
+
+namespace CLEngine
+{
+ ///
+ /// CGame
+ ///
+ public partial class CGame
+ {
+ ///
+ /// 创建Point
+ ///
+ ///
+ public Point Point(int x = 0, int y = 0)
+ {
+ return new Point(x, y);
+ }
+ }
+}
diff --git a/CLEngine/CGame.cs b/CLEngine/CGame.cs
index 7663b40..9dab2c9 100644
--- a/CLEngine/CGame.cs
+++ b/CLEngine/CGame.cs
@@ -5,6 +5,7 @@ using System.Text;
using CLEditor.Core.Diagnostics;
using CLEngine.Properties;
using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
using NLua;
using Lua = NLua.Lua;
// ReSharper disable VirtualMemberCallInConstructor
@@ -14,7 +15,7 @@ namespace CLEngine
///
/// 主要游戏类系统
///
- public class CGame : Game
+ public partial class CGame : Game
{
///
/// 日志引擎
@@ -36,7 +37,7 @@ namespace CLEngine
private readonly LuaFunction LuaUnLoadContentFunc;
private const string MainCoreLuaFile = "core.lua";
- private const string MainCoreCSFile = "Core.cs";
+ private const string MainCoreCsFile = "Core.cs";
private const string MainImportEngineFile = "importEngine.lua";
public CGame()
@@ -58,6 +59,7 @@ namespace CLEngine
var lua = new Lua();
lua.LoadCLRPackage();
lua["Game"] = this;
+ lua.RegisterFunction("Point", this, typeof(CGame).GetMethod("Point"));
lua.RegisterFunction("Load", this, typeof(CGame).GetMethod("Load"));
NoExistAndCreateFile(MainImportEngineFile, Resources.importEngine);
DoFile(lua, MainImportEngineFile.GetScriptPath());
@@ -78,10 +80,11 @@ namespace CLEngine
LuaUnLoadContentFunc = FindValueIndex(unloadContentIndex);
#endif
- NoExistAndCreateFile(MainCoreCSFile, Resources.CSCore);
+ NoExistAndCreateFile(MainCoreCsFile, Resources.CSCore);
var scriptEngine = new ScriptEngine.ScriptEngine();
- scriptEngine.CompileFile(MainCoreCSFile.GetScriptPath());
- Behaviour = scriptEngine.EvaluatorLoadFile(MainCoreCSFile.GetScriptPath());
+ scriptEngine.CompileFile(MainCoreCsFile.GetScriptPath());
+ Behaviour = scriptEngine.EvaluatorLoadFile(MainCoreCsFile.GetScriptPath());
+ Behaviour.Game = this;
}
///
diff --git a/CLEngine/CLEngine.csproj b/CLEngine/CLEngine.csproj
index 6226ec9..583197f 100644
--- a/CLEngine/CLEngine.csproj
+++ b/CLEngine/CLEngine.csproj
@@ -83,6 +83,7 @@
+
diff --git a/CLEngine/Templates/Core.cs b/CLEngine/Templates/Core.cs
index 567ee69..2c9ced8 100644
--- a/CLEngine/Templates/Core.cs
+++ b/CLEngine/Templates/Core.cs
@@ -8,6 +8,10 @@ using Microsoft.Xna.Framework;
///
public class Core : IBehaviour
{
+ ///
+ /// 游戏库
+ ///
+ public Microsoft.Xna.Framework.Game Game { get; set; }
///
/// 游戏初始化
///
diff --git a/CLEngine/Templates/importEngine.lua b/CLEngine/Templates/importEngine.lua
index 49edf9c..4ec76ed 100644
--- a/CLEngine/Templates/importEngine.lua
+++ b/CLEngine/Templates/importEngine.lua
@@ -2,6 +2,8 @@ import("CLEditor")
import("CLEditor.Core")
import("CLEditor.Core.Diagnostics")
import("CLEditor.Core.Diagnostics.GlobalLogger")
+import("Microsoft.Xna.Framework")
+import("Microsoft.Xna.Framework.Graphics")
import("MonoGame.Extended")
import("MonoGame.Extended.Tiled")
import("MonoGame.Extended.Graphics")
diff --git a/ExePacker.iss b/ExePacker.iss
index 39effca..ab8535a 100644
--- a/ExePacker.iss
+++ b/ExePacker.iss
@@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "CLEngine"
-#define MyAppVersion "3.0.5.5"
+#define MyAppVersion "3.0.5.6"
#define MyAppPublisher "Hyuan Company, Inc."
#define MyAppURL "http://www.hyuan.org/"
#define MyAppExeName "CLEditor.exe"
--
Gitee