From fcd581bec86de6d5d4877b7936272a34d9ede577 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: Fri, 19 Jul 2019 20:02:10 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CLEditor.sln | 3 ++ CLEditor/CLEngine.Editor.csproj | 1 + CLEditor/model/GlobalCommands.cs | 2 +- CLEditor/model/ResBuilder.cs | 89 ++++++++++++++++++++++++++++++++ Engine/CLEngine.Core/CProject.cs | 7 +++ ResBuilder.cs | 9 ++++ 6 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 CLEditor/model/ResBuilder.cs create mode 100644 ResBuilder.cs diff --git a/CLEditor.sln b/CLEditor.sln index 4e428c7..e4d89c2 100644 --- a/CLEditor.sln +++ b/CLEditor.sln @@ -6,6 +6,9 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Game", "Game", "{8C812676-F827-4094-853C-ABB9FA80BE38}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Editor", "Editor", "{53AD3C99-B7C7-4D7C-86B9-CA94FD5C9E71}" + ProjectSection(SolutionItems) = preProject + ResBuilder.cs = ResBuilder.cs + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Engine", "Engine", "{690E424D-5677-4998-B1EE-1314634B09F5}" EndProject diff --git a/CLEditor/CLEngine.Editor.csproj b/CLEditor/CLEngine.Editor.csproj index 850384b..1063f37 100644 --- a/CLEditor/CLEngine.Editor.csproj +++ b/CLEditor/CLEngine.Editor.csproj @@ -269,6 +269,7 @@ + diff --git a/CLEditor/model/GlobalCommands.cs b/CLEditor/model/GlobalCommands.cs index 6a2b009..7c50c33 100644 --- a/CLEditor/model/GlobalCommands.cs +++ b/CLEditor/model/GlobalCommands.cs @@ -67,7 +67,7 @@ namespace CLEngine.Editor.model RemoveEmptyFolders(destinationPath, SearchOption.AllDirectories); CHelper.ChangeSettingsToRelease(destinationPath); - + ResBuilder.Build("DesktopGL",projectPath,destinationPath); return true; case "windowsstore": // creates shadow directories diff --git a/CLEditor/model/ResBuilder.cs b/CLEditor/model/ResBuilder.cs new file mode 100644 index 0000000..6e8a9d3 --- /dev/null +++ b/CLEditor/model/ResBuilder.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.IO; +using CLEngine.Core; +using System.Diagnostics; +using System.Threading; + +public class ResBuilder +{ + public static Dictionary image=new Dictionary { { "png", true },{ "jpg", true },{ "bmp", true }, + {"dds",true } }; + + public static Dictionary AllSupportTypes = new Dictionary{ + { "png", true },{ "jpg", true },{ "bmp", true },{ "dds", true },{ "wav", true }, { "mp3", true }, { "ogg", true } + }; + public static Dictionary sound = new Dictionary { { "wav", true }, { "mp3", true }, { "ogg", true } }; + public static void Build(string platform,string ori,string dest){ + DirectoryInfo root = new DirectoryInfo(ori+"\\\\Content"); + FileInfo[] files = root.GetFiles(); + FileInfo file; + int max = files.Length; + string Name,d; + d = dest + "\\\\Content"; + using (StreamWriter sw = new StreamWriter(d + "\\\\Content.mgcb")) + { + sw.WriteLine("\n#----------------------------- Global Properties ----------------------------#\n"); + sw.WriteLine("/outputDir:.\\\n/intermediateDir:.\\\n/platform:"+platform); + sw.WriteLine("/config:\n/profile:Reach\n/compress:True\n"); + sw.WriteLine("#-------------------------------- References --------------------------------#\n"); + sw.WriteLine("#---------------------------------- Content ---------------------------------#"); + for (int i = 0; i < max; i++) + { + file = files[i]; + Name = System.IO.Path.GetExtension(file.Name); + if (AllSupportTypes.ContainsKey(Name)) + { + sw.WriteLine("\n#begin " + file.Name); + if (image.ContainsKey(Name)) + { + sw.WriteLine("/importer:TextureImporter\n/processor:TextureProcessor"); + sw.WriteLine("/processorParam:ColorKeyColor=255,0,255,255"); + sw.WriteLine("/processorParam:ColorKeyEnabled=True"); + sw.WriteLine("/processorParam:GenerateMipmaps=False"); + sw.WriteLine("/processorParam:PremultiplyAlpha=True"); + sw.WriteLine("/processorParam:ResizeToPowerOfTwo=False"); + sw.WriteLine("/processorParam:MakeSquare=False"); + sw.WriteLine("/processorParam:TextureFormat=Color"); + } + else if(sound.ContainsKey(Name)){ + switch(Name){ + case "mp3": + sw.WriteLine("/importer:Mp3Importer"); + sw.WriteLine("/processor:SongProcessor"); + break; + case "wav": + sw.WriteLine("/importer:WavImporter"); + sw.WriteLine("/processor:SoundEffectProcessor"); + break; + case "ogg": + sw.WriteLine("/importer:OggImporter"); + sw.WriteLine("/processor:SongProcessor"); + break; + } + sw.WriteLine("/processorParam:Quality=Best"); + } + sw.WriteLine("/build:" + file.Name + ";" + file.Name); + } + } + } + var p = new Process(); + p.StartInfo =new ProcessStartInfo( "C:\\Program Files (x86)\\MSBuild\\MonoGame\\v3.0\\Tools\\MGCB.exe","/w:"+dest+" /@:"+d+"\\\\Content.mgcb"); + p.Start(); + root = null; + root = new DirectoryInfo(d); + files = root.GetFiles(); + max = files.Length; + for(int i=0;i + /// 获取工程路径 + /// + /// + public string GetPath(){ + return projectPath; + } } } \ No newline at end of file diff --git a/ResBuilder.cs b/ResBuilder.cs new file mode 100644 index 0000000..399c903 --- /dev/null +++ b/ResBuilder.cs @@ -0,0 +1,9 @@ +using System; + +public class ResBuilder +{ + public static void Build(){ + string Path = SceneManager.GameProject.projectPath; + Console.WriteLine(Path); + } +} -- Gitee From 159b62de7f3f6785008738f74a6fea9cbf8d5433 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: Sat, 20 Jul 2019 08:51:48 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E9=9A=90=E8=97=8F=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E6=97=B6=E5=BC=B9=E5=87=BA=E7=9A=84=E5=91=BD=E4=BB=A4=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CLEditor/model/ResBuilder.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CLEditor/model/ResBuilder.cs b/CLEditor/model/ResBuilder.cs index 6e8a9d3..e78d3b8 100644 --- a/CLEditor/model/ResBuilder.cs +++ b/CLEditor/model/ResBuilder.cs @@ -69,6 +69,9 @@ public class ResBuilder } var p = new Process(); p.StartInfo =new ProcessStartInfo( "C:\\Program Files (x86)\\MSBuild\\MonoGame\\v3.0\\Tools\\MGCB.exe","/w:"+dest+" /@:"+d+"\\\\Content.mgcb"); + p.StartInfo.CreateNoWindow = true; + p.StartInfo.UseShellExecute = false; + p.StartInfo.RedirectStandardOutput = true; p.Start(); root = null; root = new DirectoryInfo(d); -- Gitee From afbcf549cd811858eeb8e7680eb5b73322cc9ef3 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: Sat, 20 Jul 2019 09:05:17 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=EF=BC=8C=E5=88=A0=E9=99=A4=E5=8E=9F=E4=BA=8B=E4=BB=B6=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=A1=86=E6=9E=B6=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CLEditor/model/GlobalCommands.cs | 176 ++--- CLEditor/model/ResBuilder.cs | 28 +- Engine/CLEngine.Core/CLEngine.Core.csproj | 2 +- .../CLEngine.Core/components/EventObject.cs | 731 ------------------ Engine/CLEngine.Core/framework/EventObject.cs | 38 + 5 files changed, 144 insertions(+), 831 deletions(-) delete mode 100644 Engine/CLEngine.Core/components/EventObject.cs create mode 100644 Engine/CLEngine.Core/framework/EventObject.cs diff --git a/CLEditor/model/GlobalCommands.cs b/CLEditor/model/GlobalCommands.cs index 7c50c33..cd1f650 100644 --- a/CLEditor/model/GlobalCommands.cs +++ b/CLEditor/model/GlobalCommands.cs @@ -5,106 +5,106 @@ using CLEngine.Core; namespace CLEngine.Editor.model { - public static class GlobalCommands - { - public static void RemoveEmptyFolders(string path, SearchOption searchOption) - { - foreach (string dirPath in Directory.GetDirectories(path, "*", SearchOption.AllDirectories)) - { - if (Directory.GetFiles(dirPath).Count() == 0 && Directory.GetDirectories(dirPath).Count() == 0) - Directory.Delete(dirPath); - } - } + public static class GlobalCommands + { + public static void RemoveEmptyFolders(string path, SearchOption searchOption) + { + foreach (string dirPath in Directory.GetDirectories(path, "*", SearchOption.AllDirectories)) + { + if (Directory.GetFiles(dirPath).Count() == 0 && Directory.GetDirectories(dirPath).Count() == 0) + Directory.Delete(dirPath); + } + } - public static bool DeployProject(string projectPath, string destinationPath, string platform) - { - List blockedDirs = new List(); - blockedDirs.Add("bin"); - blockedDirs.Add("obj"); - blockedDirs.Add(".git"); - blockedDirs.Add(".vs"); + public static bool DeployProject(string projectPath, string destinationPath, string platform) + { + List blockedDirs = new List(); + blockedDirs.Add("bin"); + blockedDirs.Add("obj"); + blockedDirs.Add(".git"); + blockedDirs.Add(".vs"); List blockedFileExtensions = new List(); - blockedFileExtensions.Add(".cs"); - //blockedFileExtensions.Add(".clengine"); - blockedFileExtensions.Add(".csproj"); - blockedFileExtensions.Add(".sln"); + blockedFileExtensions.Add(".cs"); + //blockedFileExtensions.Add(".clengine"); + blockedFileExtensions.Add(".csproj"); + blockedFileExtensions.Add(".sln"); - switch (platform.ToLower()) - { - case "windows": - // creates shadow directories - foreach (string dirPath in Directory.GetDirectories(projectPath, "*", SearchOption.AllDirectories)) - { - Directory.CreateDirectory(dirPath.Replace(projectPath, destinationPath)); - } + switch (platform.ToLower()) + { + case "windows": + // creates shadow directories + foreach (string dirPath in Directory.GetDirectories(projectPath, "*", SearchOption.AllDirectories)) + { + Directory.CreateDirectory(dirPath.Replace(projectPath, destinationPath)); + } - // clear blocked directories from the root folder: - foreach (string dirPath in Directory.GetDirectories(destinationPath, "*", SearchOption.TopDirectoryOnly)) - { - if (blockedDirs.Contains(System.IO.Path.GetFileName(dirPath))) - Directory.Delete(dirPath, true); - } + // clear blocked directories from the root folder: + foreach (string dirPath in Directory.GetDirectories(destinationPath, "*", SearchOption.TopDirectoryOnly)) + { + if (blockedDirs.Contains(System.IO.Path.GetFileName(dirPath))) + Directory.Delete(dirPath, true); + } - // copy all the files - foreach (string path in Directory.GetFiles(projectPath, "*.*", SearchOption.AllDirectories)) - { - string filename = System.IO.Path.GetFileName(path); - string ext = System.IO.Path.GetExtension(path); - if (!blockedFileExtensions.Contains(ext) && - Directory.Exists(System.IO.Path.GetDirectoryName(path.Replace(projectPath, destinationPath)))) - { - if (filename.ToLower().Equals("CLEngine.Windows.exe")) - { - File.Copy(path, System.IO.Path.GetDirectoryName(path.Replace(projectPath, destinationPath)) + "\\" + SceneManager.GameProject.ProjectName + ".exe", true); - } - else - { - File.Copy(path, path.Replace(projectPath, destinationPath), true); - } - } - } + // copy all the files + foreach (string path in Directory.GetFiles(projectPath, "*.*", SearchOption.AllDirectories)) + { + string filename = System.IO.Path.GetFileName(path); + string ext = System.IO.Path.GetExtension(path); + if (!blockedFileExtensions.Contains(ext) && + Directory.Exists(System.IO.Path.GetDirectoryName(path.Replace(projectPath, destinationPath)))) + { + if (filename.ToLower().Equals("CLEngine.Windows.exe")) + { + File.Copy(path, System.IO.Path.GetDirectoryName(path.Replace(projectPath, destinationPath)) + "\\" + SceneManager.GameProject.ProjectName + ".exe", true); + } + else + { + File.Copy(path, path.Replace(projectPath, destinationPath), true); + } + } + } - RemoveEmptyFolders(destinationPath, SearchOption.AllDirectories); - CHelper.ChangeSettingsToRelease(destinationPath); - ResBuilder.Build("DesktopGL",projectPath,destinationPath); + RemoveEmptyFolders(destinationPath, SearchOption.AllDirectories); + CHelper.ChangeSettingsToRelease(destinationPath); + ResBuilder.Build("DesktopGL", projectPath, destinationPath); return true; - case "windowsstore": - // creates shadow directories - foreach (string dirPath in Directory.GetDirectories(projectPath, "*", SearchOption.AllDirectories)) - Directory.CreateDirectory(destinationPath.Replace(projectPath, destinationPath)); + case "windowsstore": + // creates shadow directories + foreach (string dirPath in Directory.GetDirectories(projectPath, "*", SearchOption.AllDirectories)) + Directory.CreateDirectory(destinationPath.Replace(projectPath, destinationPath)); - //Copy all the files - foreach (string path in Directory.GetFiles(projectPath, "*.*", SearchOption.AllDirectories)) - { - if (!Directory.Exists(System.IO.Path.GetDirectoryName(path.Replace(projectPath, destinationPath)))) - { - Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path.Replace(projectPath, destinationPath))); - } + //Copy all the files + foreach (string path in Directory.GetFiles(projectPath, "*.*", SearchOption.AllDirectories)) + { + if (!Directory.Exists(System.IO.Path.GetDirectoryName(path.Replace(projectPath, destinationPath)))) + { + Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path.Replace(projectPath, destinationPath))); + } - if (path.ToLower().EndsWith(".scene")) - { - GameScene scene = (GameScene)CHelper.DeserializeObject(path); - CHelper.SerializeObjectXML(path.Replace(projectPath, destinationPath), scene); - } - else if (path.ToLower().EndsWith(".clengine")) - { - CProject gp = (CProject)CHelper.DeserializeObject(path); - CHelper.SerializeObjectXML(path.Replace(projectPath, destinationPath), gp); - } - else - { - File.Copy(path, path.Replace(projectPath, destinationPath), true); - } - } + if (path.ToLower().EndsWith(".scene")) + { + GameScene scene = (GameScene)CHelper.DeserializeObject(path); + CHelper.SerializeObjectXML(path.Replace(projectPath, destinationPath), scene); + } + else if (path.ToLower().EndsWith(".clengine")) + { + CProject gp = (CProject)CHelper.DeserializeObject(path); + CHelper.SerializeObjectXML(path.Replace(projectPath, destinationPath), gp); + } + else + { + File.Copy(path, path.Replace(projectPath, destinationPath), true); + } + } - RemoveEmptyFolders(destinationPath, SearchOption.AllDirectories); - CHelper.ChangeSettingsToRelease(destinationPath); + RemoveEmptyFolders(destinationPath, SearchOption.AllDirectories); + CHelper.ChangeSettingsToRelease(destinationPath); return true; - } + } - return false; - } - } + return false; + } + } } \ No newline at end of file diff --git a/CLEditor/model/ResBuilder.cs b/CLEditor/model/ResBuilder.cs index e78d3b8..7fd22b0 100644 --- a/CLEditor/model/ResBuilder.cs +++ b/CLEditor/model/ResBuilder.cs @@ -7,24 +7,25 @@ using System.Threading; public class ResBuilder { - public static Dictionary image=new Dictionary { { "png", true },{ "jpg", true },{ "bmp", true }, + public static Dictionary image = new Dictionary { { "png", true },{ "jpg", true },{ "bmp", true }, {"dds",true } }; public static Dictionary AllSupportTypes = new Dictionary{ { "png", true },{ "jpg", true },{ "bmp", true },{ "dds", true },{ "wav", true }, { "mp3", true }, { "ogg", true } }; public static Dictionary sound = new Dictionary { { "wav", true }, { "mp3", true }, { "ogg", true } }; - public static void Build(string platform,string ori,string dest){ - DirectoryInfo root = new DirectoryInfo(ori+"\\\\Content"); + public static void Build(string platform, string ori, string dest) + { + DirectoryInfo root = new DirectoryInfo(ori + "\\\\Content"); FileInfo[] files = root.GetFiles(); FileInfo file; int max = files.Length; - string Name,d; + string Name, d; d = dest + "\\\\Content"; using (StreamWriter sw = new StreamWriter(d + "\\\\Content.mgcb")) { sw.WriteLine("\n#----------------------------- Global Properties ----------------------------#\n"); - sw.WriteLine("/outputDir:.\\\n/intermediateDir:.\\\n/platform:"+platform); + sw.WriteLine("/outputDir:.\\\n/intermediateDir:.\\\n/platform:" + platform); sw.WriteLine("/config:\n/profile:Reach\n/compress:True\n"); sw.WriteLine("#-------------------------------- References --------------------------------#\n"); sw.WriteLine("#---------------------------------- Content ---------------------------------#"); @@ -46,8 +47,10 @@ public class ResBuilder sw.WriteLine("/processorParam:MakeSquare=False"); sw.WriteLine("/processorParam:TextureFormat=Color"); } - else if(sound.ContainsKey(Name)){ - switch(Name){ + else if (sound.ContainsKey(Name)) + { + switch (Name) + { case "mp3": sw.WriteLine("/importer:Mp3Importer"); sw.WriteLine("/processor:SongProcessor"); @@ -68,7 +71,7 @@ public class ResBuilder } } var p = new Process(); - p.StartInfo =new ProcessStartInfo( "C:\\Program Files (x86)\\MSBuild\\MonoGame\\v3.0\\Tools\\MGCB.exe","/w:"+dest+" /@:"+d+"\\\\Content.mgcb"); + p.StartInfo = new ProcessStartInfo("C:\\Program Files (x86)\\MSBuild\\MonoGame\\v3.0\\Tools\\MGCB.exe", "/w:" + dest + " /@:" + d + "\\\\Content.mgcb"); p.StartInfo.CreateNoWindow = true; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; @@ -77,14 +80,17 @@ public class ResBuilder root = new DirectoryInfo(d); files = root.GetFiles(); max = files.Length; - for(int i=0;i + @@ -307,7 +308,6 @@ - diff --git a/Engine/CLEngine.Core/components/EventObject.cs b/Engine/CLEngine.Core/components/EventObject.cs deleted file mode 100644 index f1896f1..0000000 --- a/Engine/CLEngine.Core/components/EventObject.cs +++ /dev/null @@ -1,731 +0,0 @@ -using System; -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.Serialization; -using CLEngine.Core.components; -using CLEngine.Editor.core; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; -using RoyT.AStar; - -namespace CLEngine.Core -{ - /// - /// 事件阵营 - /// -#if WIN - [Serializable] -#endif - [DataContract] - - public enum Camp - { - /// - /// 自身 - /// - Self, - /// - /// 敌人 - /// - Enemy, - /// - /// 友方 - /// - Friendly, - /// - /// 中立 - /// - Neutral, - } - - /// - /// 移动事件参数 - /// - public class EventMove : EventArgs - { - /// - /// 移动方向 - /// - public Vector2 Direction; - /// - /// 是否正在移动 - /// - public bool IsMove; - /// - /// 哪个键按下 - /// 0: 无按键 - /// 1: 左键 - /// 2:右键 - /// - public int KeyCode; - - /// - /// - /// - /// - /// - /// - public EventMove(Vector2 direction, bool isMove = false, int keyCode = 0) - { - Direction = direction; - IsMove = isMove; - KeyCode = keyCode; - } - } - - /// - /// 事件对象 - /// 记录事件的一系列数据 - /// -#if WIN - [Serializable] -#endif - [DataContract] - public class EventObject : ExtendedObjectComponent - { - [DataMember] private Camp _camp; - [DataMember] private object _attachData; - [DataMember] private int _hp = 100; - [DataMember] private int _exp; - [DataMember] private int _nextExp = 100; - [DataMember] private int _level; - [DataMember] private int _mp = 100; - [DataMember] private bool _hasCollider; - [DataMember] private string _objectName; - [DataMember] private bool _hasDelayCamera; - [DataMember] private float _delaySpeed = 0.1f; - [DataMember] private float _leftSpeed = 100; - [DataMember] private float _rightSpeed = 100; - [DataMember] private bool _lockMap = true; - [DataMember] private float _moveSpeed = 100; - [NonSerialized] private bool _isMove = false; - - private const float DirectionRotationOffset = 22.5f; - /// - /// 目标移动坐标 - /// - private Vector2 _targetPos = Vector2.Zero; - /// - /// 下一步移动坐标 - /// - private Vector2 _nextPos = Vector2.Zero; - - /// - /// 事件的阵营 - /// -#if WIN - [Category("事件属性")] - [DisplayName("阵营"), Description("事件的阵营")] -#endif - public Camp Camp - { - get { return _camp;} - set { _camp = value; } - } - - /// - /// 附加属性 - /// -#if WIN - [Browsable(false)] -#endif - public object AttachData - { - get { return _attachData; } - set { _attachData = value; } - } - - /// - /// 事件的血量 - /// -#if WIN - [Category("事件属性")] - [DisplayName("血量"), Description("事件的血量")] -#endif - public int Hp - { - get { return _hp; } - set - { - _hp = value; - if (_hp <= 0) - { - _hp = 0; - OnDead?.Invoke(this, EventArgs.Empty); - } - } - } - - /// - /// 事件的蓝量 - /// -#if WIN - [Category("事件属性")] - [DisplayName("蓝量"), Description("事件的蓝量")] -#endif - public int Mp - { - get { return _mp; } - set { _mp = value; } - } - - /// - /// 事件的经验 - /// -#if WIN - [Category("事件属性")] - [DisplayName("经验"), Description("事件的经验")] -#endif - public int Exp - { - get { return _exp;} - set { _exp = value; } - } - - /// - /// 事件的下一级升级所需经验 - /// -#if WIN - [Category("事件属性")] - [DisplayName("升级所需经验"), Description("事件的下一级升级所需经验")] -#endif - public int NextExp - { - get { return _nextExp; } - set - { - _nextExp = value; - if (_nextExp >= NextExp) - { - _nextExp = _nextExp - NextExp; - _level += 1; - OnLevel?.Invoke(this, EventArgs.Empty); - } - } - } - - /// - /// 事件是否有自己的碰撞器 - /// -#if WIN - [Category("事件属性")] - [DisplayName("是否添加碰撞器"), Description("事件是否有自己的碰撞器")] -#endif - public bool HasCollider - { - get { return _hasCollider; } - set { _hasCollider = value; } - } - - /// - /// 事件等级 - /// -#if WIN - [Category("事件属性")] - [DisplayName("等级"), Description("事件等级")] -#endif - public int Level - { - get { return _level; } - set { _level = value; } - } - -#if WIN - [Category("相机属性")] - [DisplayName("相机延迟跟随"), Description("相机是否延迟跟随")] -#endif - public bool HasDelayCamera - { - get { return _hasDelayCamera; } - set { _hasDelayCamera = value; } - } - -#if WIN - [Category("相机属性")] - [DisplayName("相机跟随速度")] -#endif - public float DelaySpeed - { - get { return _delaySpeed; } - set { _delaySpeed = value; } - } - -#if WIN - [Category("事件属性")] - [DisplayName("左键移动速度")] -#endif - public float LeftSpeed - { - get { return _leftSpeed; } - set { _leftSpeed = value; } - } - -#if WIN - [Category("事件属性")] - [DisplayName("右键移动速度")] -#endif - public float RightSpeed - { - get { return _rightSpeed; } - set { _rightSpeed = value; } - } - -#if WIN - [Category("相机属性")] - [DisplayName("锁定地图边界")] -#endif - public bool LockMap - { - get { return _lockMap; } - set { _lockMap = value; } - } - -#if WIN - [Category("事件属性")] - [DisplayName("移动速度"), Description("事件通用移动速度,用于自动寻路")] -#endif - public float MoveSpeed - { - get { return _moveSpeed; } - set { _moveSpeed = value; } - } - - private GameObject _bindGameObject; - - /// - /// 事件死亡 - /// - public EventHandler OnDead; - - /// - /// 事件升级 - /// - public EventHandler OnLevel; - - /// - /// 事件移动 - /// - public EventHandler OnMove; - - /// - /// 初始化 - /// - public override void Initialize() - { - base.Initialize(); - - //if (!SceneManager.IsEditor) - //{ - // foreach (var activeSceneGameObject in SceneManager.ActiveScene.GameObjects) - // { - // if (activeSceneGameObject is MapObject map) - // { - // map.EventObjects.Add(this); - // break; - // } - // } - //} - } - - private void CheckOpacity() - { - var tileMap = GetTileMap(); - var tilePos = tileMap.GetTilePos(GameObject.Transform.Position); - if (tileMap.OpacityGrid[(int)tilePos.X][(int)tilePos.Y] == 1) - { - if (GameObject is AnimationObject animation) - { - animation.Color = Color.FromNonPremultiplied(255, 255, 255, 96); - } - } - else - { - if (GameObject is AnimationObject animation) - { - animation.Color = Color.FromNonPremultiplied(255, 255, 255, 255); - } - } - } - - /// - /// 事件移动到指定坐标 - /// - /// - /// - /// - public void MoveToTarget(Vector2 target, bool convert = false, bool forceMove = false) - { - if (_isMove && !forceMove) - return; - - var tiledMap = GetTileMap(); - var transform = GameObject.Transform; - var start = tiledMap.GetTilePos(transform.Position); - - var convertPos = target; - if (convert) - convertPos = tiledMap.GetTilePos(target); - - // 可能存在性能问题 - var path = tiledMap.Grid.GetPath(new Position((int) start.X, (int) start.Y), - new Position((int) convertPos.X, (int) convertPos.Y), MovementPatterns.Full, 200); - - if (path.Length < 2) - { - _targetPos = Vector2.Zero; - _nextPos = Vector2.Zero; - return; - } - - _nextPos = new Vector2(path[1].X, path[1].Y); - _targetPos = target; - } - - private MapObject GetTileMap() - { - foreach (var activeSceneGameObject in SceneManager.ActiveScene.GameObjects) - { - if (activeSceneGameObject is MapObject map) - return map; - } - - return null; - } - - /// - /// 更新 - /// - /// - public override void Update(GameTime gameTime) - { - base.Update(gameTime); - - if (SceneManager.IsEditor) - return; - - // 主角控制 - SelfController(); - // 检查移动 - CheckMove(); - // 检查透明 - CheckOpacity(); - } - - #region Overrides of ObjectComponent - - private void CheckMove() - { - if (_targetPos == Vector2.Zero) - return; - - // 移动状态开始 - _isMove = true; - - // 获取绑定物体的属性 - var transform = GameObject.Transform; - - var tileMap = GetTileMap(); - //var targetWorldPos = tileMap.GetWorldPos(_targetPos); - var nextWorldPos = tileMap.GetWorldPos(_nextPos); - var nextRandians = transform.LookAt(nextWorldPos, false); - var nextDegrees = MathHelper.ToDegrees(nextRandians); - var direction = ConvertToDirection(nextDegrees); - - float speed; - if (Mouse.GetState().LeftButton == ButtonState.Pressed) - speed = _leftSpeed; - else if (Mouse.GetState().RightButton == ButtonState.Pressed) - speed = _rightSpeed; - else - speed = _moveSpeed; - - transform.Translate(direction * speed * Time.deltaTime); - - // 无法精确到每位相等 当坐标接近目标时则停下 - if (Math.Abs(transform.Position.X - nextWorldPos.X) <= speed * Time.deltaTime && - Math.Abs(transform.Position.Y - nextWorldPos.Y) <= speed * Time.deltaTime) - { - // 强制移动目标至下一格子坐标点 - transform.Position = nextWorldPos; - // 清空下一格子坐标点 - _nextPos = Vector2.Zero; - // 重新计算下一个目标点 - MoveToTarget(_targetPos, false, true); - // 结束移动状态 - _isMove = false; - } - - } - - private void SelfController() - { - if (Camp == Camp.Self) - { - var camera = SceneManager.ActiveCamera; - var mouseWorldPosition = Camera.ToWorld(Mouse.GetState().Position.ToVector2()); - - var direction = Vector2.Zero; - var isLeft = Mouse.GetState().LeftButton == ButtonState.Pressed; - var isMove = false; - if (Mouse.GetState().LeftButton == ButtonState.Pressed || - Mouse.GetState().RightButton == ButtonState.Pressed) - { - var randians = GameObject.Transform.LookAt(mouseWorldPosition, false); - var degrees = MathHelper.ToDegrees(randians); - - direction = ConvertToDirection(degrees); - - isMove = true; - - // TODO: 寻路会因为鼠标指向障碍而找不到路径 需要指定一个离鼠标最近且离主角最近的一个无障碍坐标点 - var mouseWorldPos = Camera.ToWorld(Mouse.GetState().Position.ToVector2()); - MoveToTarget(mouseWorldPos, true); - //Move(direction, isLeft ? _leftSpeed : _rightSpeed); - } - - var keyCode = 0; - if (isMove) - keyCode = isLeft ? 1 : 2; - - OnMove?.Invoke(this, new EventMove(direction, isMove, keyCode)); - - if (_hasDelayCamera) - { - var x = MathHelper.Lerp(camera.Position.X, GameObject.Transform.Position.X, _delaySpeed); - var y = MathHelper.Lerp(camera.Position.Y, GameObject.Transform.Position.Y, _delaySpeed); - camera.Position = new Vector2(x, y); - } - else - { - camera.Position = Transform.Position; - } - - if (_lockMap) - { - var x = camera.Position.X; - var y = camera.Position.Y; - var halfScreenWidth = SceneManager.Graphics.PreferredBackBufferWidth / 2; - var halfScreenHeight = SceneManager.Graphics.PreferredBackBufferHeight / 2; - var map = GetMap(); - - //左边界 - if (x < halfScreenWidth) - x = halfScreenWidth; - - if (x > map.Texture.Width - halfScreenWidth) - x = map.Texture.Width - halfScreenWidth; - - if (y < halfScreenHeight) - y = halfScreenHeight; - - if (y > map.Texture.Height - halfScreenHeight) - y = map.Texture.Height - halfScreenHeight; - - if (ClampToBound()) - camera.Position = new Vector2(x, y); - } - } - } - - /// - /// 寻找一个离坐标点最近且无障碍的点 - /// - /// - private Vector2 CheckOrGetNearPos(Vector2 worldPos) - { - var map = GetTileMap(); - var tilePos = map.GetTilePos(worldPos); - if (CheckIsCollider(tilePos)) - { - var nearPos = worldPos; - var start = map.GetTilePos(GameObject.Transform.Position); - - return nearPos; - - //// 只寻找它周围最多10格范围 - //// 我们还需要从小往大进行搜寻 - //var searchZRange = 0; - //var searchFRange = 0; - //while (Math.Abs(searchZRange) < 5 && Math.Abs(searchFRange) < 5) - //{ - // // 搜寻分正负 - // searchZRange++; - // searchFRange--; - - // // 先从离主角近的一边开始计算 - // var randians = Transform.LookAt(worldPos, false); - // var degrees = MathHelper.ToDegrees(randians); - // var direction = ConvertToDirection(degrees); - // if (direction.X < 0 && direction.Y < 0) - // { - // nearPos = SearchPos(tilePos, searchFRange, searchFRange); - // if (nearPos != Vector2.Zero) - // return nearPos; - // } - - // if (direction.X < 0 && direction.Y > 0) - // { - // nearPos = SearchPos(tilePos, searchFRange, searchZRange); - // if (nearPos != Vector2.Zero) - // return nearPos; - // } - - // if (direction.X > 0 && direction.Y < 0) - // { - // nearPos = SearchPos(tilePos, searchZRange, searchFRange); - // if (nearPos != Vector2.Zero) - // return nearPos; - // } - - // if (direction.X > 0 && direction.Y > 0) - // { - // nearPos = SearchPos(tilePos, searchZRange, searchFRange); - // if (nearPos != Vector2.Zero) - // return nearPos; - // } - - // // 还需要进行计算周围剩下的点位 - // // 我们需要排除第一个点位 还需要找到后面搜寻的顺序 - // // 从第一个点位向两边进行扩散寻找 - // for (int i = 0; i < searchZRange; i++) - // { - // for (int j = searchFRange; j < 0; j++) - // { - - // } - // } - //} - - return nearPos; - } - - return worldPos; - } - - private Vector2 SearchPos(Vector2 tilePos, int searchX, int searchY) - { - var map = GetTileMap(); - var searchPos = new Vector2(tilePos.X + searchX, tilePos.Y + searchY); - if (!CheckIsCollider(searchPos)) - return map.GetWorldPos(searchPos); - - return Vector2.Zero; - } - - private bool CheckIsCollider(Vector2 tilePos) - { - var map = GetTileMap(); - - return map.CollisionGrid[(int) tilePos.X][(int) tilePos.Y] == 1; - } - - /// - /// 绘制 - /// - /// - /// - public override void Draw(GameTime gameTime, SpriteBatch spriteBatch) - { - base.Draw(gameTime, spriteBatch); - - if (_hasCollider) - { - var map = GetMap(); - var bound = new Point(map.TileWidth, map.TileHeight); - spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, - SceneManager.ActiveCamera.TransformMatrix); - //Primitives.DrawBox(spriteBatch, - // new Rectangle((Transform.Position - bound.ToVector2() / 2).ToPoint(), bound), Color.Red, 1); - //Primitives.DrawBoxFilled(spriteBatch, - // new Rectangle((Transform.Position - bound.ToVector2() / 2).ToPoint(), bound), - // Color.FromNonPremultiplied(255, 0, 0, 128)); - Primitives.DrawBox(spriteBatch, - new Rectangle((Transform.Position).ToPoint(), bound), Color.Red, 1); - Primitives.DrawBoxFilled(spriteBatch, - new Rectangle((Transform.Position).ToPoint(), bound), - Color.FromNonPremultiplied(255, 0, 0, 128)); - spriteBatch.End(); - } - } - - #endregion - - private bool ClampToBound() - { - var camera = SceneManager.ActiveCamera; - var x = camera.Position.X; - var y = camera.Position.Y; - var halfScreenWidth = SceneManager.Graphics.PreferredBackBufferWidth / 2; - var halfScreenHeight = SceneManager.Graphics.PreferredBackBufferHeight / 2; - var map = GetMap(); - - //左边界 - if (x < halfScreenWidth) - return true; - - if (x > map.Texture.Width - halfScreenWidth) - return true; - - if (y < halfScreenHeight) - return true; - - if (y > map.Texture.Height - halfScreenHeight) - return true; - - return false; - } - - private MapObject GetMap() - { - foreach (var activeSceneGameObject in SceneManager.ActiveScene.GameObjects) - { - if (activeSceneGameObject is MapObject map) - return map; - } - - return null; - } - - private Vector2 ConvertToDirection(float degrees) - { - var direction = Vector2.Zero; - - if (degrees > -90 + DirectionRotationOffset && degrees <= -45 + DirectionRotationOffset) - { - direction = new Vector2(1, -1); - } - else if (degrees > -135 + DirectionRotationOffset && degrees <= -90 + DirectionRotationOffset) - { - direction = new Vector2(0, -1); - } - else if (degrees > -180 + DirectionRotationOffset && degrees <= -135 + DirectionRotationOffset) - { - direction = new Vector2(-1, -1); - } - else if (degrees > -45 + DirectionRotationOffset && degrees <= 0 + DirectionRotationOffset) - { - direction = new Vector2(1, 0); - } - else if (degrees > 0 + DirectionRotationOffset && degrees <= 45 + DirectionRotationOffset) - { - direction = new Vector2(1, 1); - } - else if (degrees > 45 + DirectionRotationOffset && degrees <= 90 + DirectionRotationOffset) - { - direction = new Vector2(0, 1); - } - else if (degrees > 90 + DirectionRotationOffset && degrees <= 135 + DirectionRotationOffset) - { - direction = new Vector2(-1, 1); - } - else if ((degrees > 135 + DirectionRotationOffset && degrees <= 180) || - (degrees > -180 && degrees <= -135 + DirectionRotationOffset)) - { - direction = new Vector2(-1, 0); - } - - return direction; - } - } -} \ No newline at end of file diff --git a/Engine/CLEngine.Core/framework/EventObject.cs b/Engine/CLEngine.Core/framework/EventObject.cs new file mode 100644 index 0000000..d73b728 --- /dev/null +++ b/Engine/CLEngine.Core/framework/EventObject.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace CLEngine.Core.framework +{ +#if WIN + [Serializable] +#endif + [DataContract] + public class EventObject + { + [DataMember] private string _name; + [DataMember] private List _bindHero; + [DataMember] private List _bindItem; + /// + /// 事件名 + /// + public string Name { get { return _name; } set { _name = value; } } + /// + /// 绑定的角色 + /// + public List BindHero { get { return _bindHero; } set { _bindHero = value; } } + /// + /// 绑定的物品 + /// + public List BindItem { get { return _bindItem; } set { _bindItem = value; } } + + public void TrigEvent() + { + + } + + } +} -- Gitee From e0b267ebd1df8ac0e6fe42b66d3bccb2b25b725b 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: Sat, 20 Jul 2019 14:05:24 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Engine/CLEngine.Core/framework/ItemObject.cs | 16 +-- .../CLEngine.Core/framework/SkillManager.cs | 3 +- Engine/CLEngine.Core/framework/SkillObject.cs | 111 ++++++++++++++++-- 3 files changed, 111 insertions(+), 19 deletions(-) diff --git a/Engine/CLEngine.Core/framework/ItemObject.cs b/Engine/CLEngine.Core/framework/ItemObject.cs index fff3078..bfcfd3e 100644 --- a/Engine/CLEngine.Core/framework/ItemObject.cs +++ b/Engine/CLEngine.Core/framework/ItemObject.cs @@ -13,7 +13,7 @@ namespace CLEngine.Core.framework /// public class ItemEventArgs : EventArgs { - int userId; + public int userId; /// /// @@ -107,15 +107,15 @@ namespace CLEngine.Core.framework /// /// 仓库唯一 /// - public bool OnlyStoreOne{ get{ return _onlyStoreOne; }set{ _onlyStoreOne = value; } } + public bool OnlyStoreOne { get { return _onlyStoreOne; } set { _onlyStoreOne = value; } } /// /// 分类 /// - public string Classification{ get{ return _classification; }set{ _classification = value; } } + public string Classification { get { return _classification; } set { _classification = value; } } /// /// 施法速率 /// - public float MagicUseSpeed{ get{ return _magicUseSpeed; }set{ _magicUseSpeed = value; } } + public float MagicUseSpeed { get { return _magicUseSpeed; } set { _magicUseSpeed = value; } } /// /// 闪避率 /// @@ -123,19 +123,19 @@ namespace CLEngine.Core.framework /// /// 命中率 /// - public float HitAccuracy{ get{ return _hitAccuracy; }set{ _hitAccuracy = value; } } + public float HitAccuracy { get { return _hitAccuracy; } set { _hitAccuracy = value; } } /// /// 背包唯一 /// - public bool OnlyGetOne{ get{ return _onlyGetOne; }set{ _onlyGetOne = value; } } + public bool OnlyGetOne { get { return _onlyGetOne; } set { _onlyGetOne = value; } } /// /// 冷却时间 /// - public int CD{ get { return _cd; }set { _cd = value; } } + public int CD { get { return _cd; } set { _cd = value; } } /// /// 回复法力值 /// - public int Mp{ get{ return _mp; }set{ _mp = value; } } + public int Mp { get { return _mp; } set { _mp = value; } } /// /// 附加属性:魔法防御 /// diff --git a/Engine/CLEngine.Core/framework/SkillManager.cs b/Engine/CLEngine.Core/framework/SkillManager.cs index 26aa299..b9d0092 100644 --- a/Engine/CLEngine.Core/framework/SkillManager.cs +++ b/Engine/CLEngine.Core/framework/SkillManager.cs @@ -63,7 +63,8 @@ namespace CLEngine.Core.framework /// /// /// - public static SkillObject GetWorldSkill(string name){ + public static SkillObject GetWorldSkill(string name) + { return _worldSkill[name]; } diff --git a/Engine/CLEngine.Core/framework/SkillObject.cs b/Engine/CLEngine.Core/framework/SkillObject.cs index 98b5dc5..b2b1834 100644 --- a/Engine/CLEngine.Core/framework/SkillObject.cs +++ b/Engine/CLEngine.Core/framework/SkillObject.cs @@ -1,5 +1,8 @@ -using System; +using FairyGUI; +using Microsoft.Xna.Framework.Graphics; +using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Runtime.Serialization; using System.Text; @@ -11,16 +14,57 @@ namespace CLEngine.Core.framework [Serializable] #endif [DataContract] + public class SkillEventArgs : EventArgs + { + public int userId; + public SkillEventArgs(int id) + { + userId = id; + } + } public class SkillObject { - [DataMember]private string _name; - [DataMember]private string _iconPath; - [DataMember]private float _coolingTime; - [DataMember]private int _useHp; - [DataMember]private int _useMp; - [DataMember]private string _description; - [DataMember]private int _castingDistance; - [DataMember]private float _castingSpeed; + /// + /// 使用技能事件 + /// + public EventHandler Use; + /// + /// 技能冷却改变事件 + /// + public EventHandler Cooling; + /// + /// 冷却完成事件 + /// + public EventHandler FinishCooling; + + [DataMember] private string _name; + [DataMember] private string _iconPath; + [DataMember] private float _coolingTime; + [DataMember] private float _currentTime = 0; + [DataMember] private int _useHp; + [DataMember] private int _useMp; + [DataMember] private string _description; + [DataMember] private int _castingDistance; + [DataMember] private float _castingSpeed; + [DataMember] private int _userId; + [NonSerialized] private Image _icon; + [NonSerialized] private Texture2D _iconTex; + /// + /// 当前冷却时间 + /// + public float CurrentTime { get { return _currentTime; } set { _currentTime = value; } } + /// + /// 技能使用者id + /// + public int UserId { get { return _userId; } set { _userId = value; } } + /// + /// 游戏图标 + /// + public Texture2D IconTex { get { return _iconTex; } set { _iconTex = value; } } + /// + /// fui图标 + /// + public Image Icon { get { return _icon; } set { _icon = value; } } /// /// 技能名称 /// @@ -35,7 +79,24 @@ namespace CLEngine.Core.framework public string IconPath { get { return _iconPath; } - set { _iconPath = value; } + set + { + _iconPath = value; + if (string.IsNullOrEmpty(_iconPath)) + { + _iconTex = null; + return; + } + var path = Path.Combine(SceneManager.GameProject.ProjectPath, _iconPath); + if (File.Exists(path)) + { + IconTex = TextureLoader.FromContent(_iconPath); + } + else + { + throw new Exception("文件" + path + "不存在"); + } + } } /// /// 技能冷却时间 @@ -111,5 +172,35 @@ namespace CLEngine.Core.framework Target, Mouse } + /// + /// 触发使用技能事件 + /// + public void TrigUse() + { + if (Use != null) + { + Use.Invoke(this, new SkillEventArgs(_userId)); + } + } + /// + /// 触发技能冷却刷新事件 + /// + public void TrigCooling() + { + if (Cooling != null) + { + Cooling.Invoke(this, new SkillEventArgs(_userId)); + } + } + /// + /// 触发技能冷却完成事件 + /// + public void TrigFinishCooling() + { + if (FinishCooling != null) + { + FinishCooling.Invoke(this, new SkillEventArgs(_userId)); + } + } } } -- Gitee From 8edaeac4c4b5b990e41d74e122382f5b2c503dba 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: Sat, 20 Jul 2019 14:32:45 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CLEngine.Core/framework/EventManager.cs | 97 ++++++++----------- Engine/CLEngine.Core/framework/EventObject.cs | 5 + Engine/CLEngine.Core/framework/HeroObject.cs | 2 + Engine/CLEngine.Core/gameObjects/MapObject.cs | 1 + 4 files changed, 50 insertions(+), 55 deletions(-) diff --git a/Engine/CLEngine.Core/framework/EventManager.cs b/Engine/CLEngine.Core/framework/EventManager.cs index c46d8a4..df5dec7 100644 --- a/Engine/CLEngine.Core/framework/EventManager.cs +++ b/Engine/CLEngine.Core/framework/EventManager.cs @@ -3,64 +3,51 @@ using Microsoft.Xna.Framework; namespace CLEngine.Core.framework { - /// - /// 事件管理类 - /// - public static class EventManager - { - private static List eventObjects = new List(); + /// + /// 事件管理类 + /// + public static class EventManager + { + private static List eventObjects = new List(); - /// - /// 添加事件 - /// - /// 事件 - public static EventObject AddEvent() - { - var eventObject = new EventObject(); - eventObjects.Add(eventObject); + /// + /// 添加事件 + /// + /// 事件 + public static EventObject AddEvent() + { + var eventObject = new EventObject(); + eventObjects.Add(eventObject); - return eventObject; - } + return eventObject; + } - /// - /// 移除事件 - /// - /// 事件 - public static void RemoveEvent(EventObject eventObject) - { - eventObjects.Remove(eventObject); - } + /// + /// 移除事件 + /// + /// 事件 + public static void RemoveEvent(EventObject eventObject) + { + eventObjects.Remove(eventObject); + } - /// - /// 绑定对象 - /// - /// 事件 - /// 对象 - public static void BindObject(this EventObject eventObject, GameObject gameObject) - { - eventObject.GameObject = gameObject; - } + /// + /// 绑定对象 + /// + /// 事件 + /// 对象 + public static void BindObject(this EventObject eventObject, GameObject gameObject) + { + eventObject.GameObject = gameObject; + } - /// - /// 释放对象 - /// - /// 事件 - public static void ReleaseObject(this EventObject eventObject) - { - eventObject.GameObject = null; - } - - /// - /// 移动对象 - /// - /// 事件 - /// 移动目标 - /// 是否转换为格子坐标 - /// 是否强制移动 - public static void Move(this EventObject eventObject, Vector2 target, bool convert = false, - bool forceMove = false) - { - eventObject.MoveToTarget(target, convert, forceMove); - } - } + /// + /// 释放对象 + /// + /// 事件 + public static void ReleaseObject(this EventObject eventObject) + { + eventObject.GameObject = null; + } + } } \ No newline at end of file diff --git a/Engine/CLEngine.Core/framework/EventObject.cs b/Engine/CLEngine.Core/framework/EventObject.cs index d73b728..14ebfed 100644 --- a/Engine/CLEngine.Core/framework/EventObject.cs +++ b/Engine/CLEngine.Core/framework/EventObject.cs @@ -16,6 +16,11 @@ namespace CLEngine.Core.framework [DataMember] private string _name; [DataMember] private List _bindHero; [DataMember] private List _bindItem; + [DataMember] private GameObject _gameObj; + /// + /// 游戏对象 + /// + public GameObject GameObject { get { return _gameObj; } set { _gameObj = value; } } /// /// 事件名 /// diff --git a/Engine/CLEngine.Core/framework/HeroObject.cs b/Engine/CLEngine.Core/framework/HeroObject.cs index 882c318..302fe94 100644 --- a/Engine/CLEngine.Core/framework/HeroObject.cs +++ b/Engine/CLEngine.Core/framework/HeroObject.cs @@ -26,6 +26,8 @@ namespace CLEngine.Core.framework [DataMember] private string _occupation; [DataMember] private Dictionary _skill; [DataMember] private Dictionary _state; + [DataMember] private SkillObject _onSkill; + /// /// 添加技能 /// diff --git a/Engine/CLEngine.Core/gameObjects/MapObject.cs b/Engine/CLEngine.Core/gameObjects/MapObject.cs index 57a5ac6..4c31b27 100644 --- a/Engine/CLEngine.Core/gameObjects/MapObject.cs +++ b/Engine/CLEngine.Core/gameObjects/MapObject.cs @@ -7,6 +7,7 @@ using System.Runtime.Serialization; using System.Windows.Forms; using CLEngine.Core.components; using CLEngine.Core.design; +using CLEngine.Core.framework; using CLEngine.Editor.core; using FarseerPhysics.Dynamics; using Microsoft.Xna.Framework; -- Gitee