From 0efb1bba2737168cd20c60c321c3601ee28fc0ff Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Tue, 17 Jan 2023 14:11:22 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E7=AE=A1=E7=90=86=E8=84=B1?= =?UTF-8?q?=E7=A6=BBMonobehaviour?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Axibug/Axibug.prefab | 142 ++++++++-------- .../Axibug/Script/Runtime/Base/GameEntry.cs | 4 +- Assets/Scripts/Main/Base/GamePlayEntry.cs | 51 ++++-- .../CustomsComponent/EffectMgrComponent.cs | 20 --- .../CustomsComponent/NoMonoBehaviour.meta | 8 + .../BattleNoMono.cs} | 34 ++-- .../BattleNoMono.cs.meta} | 0 .../BulletMgrNoMono.cs} | 33 +++- .../BulletMgrNoMono.cs.meta} | 0 .../NoMonoBehaviour/EffectNoMono.cs | 44 +++++ .../EffectNoMono.cs.meta} | 0 .../NoMonoBehaviour/INoMonoBehaviour.cs | 19 +++ .../NoMonoBehaviour/INoMonoBehaviour.cs.meta | 11 ++ .../InputNoMono.cs} | 56 ++++--- .../InputNoMono.cs.meta} | 0 .../LubanNoMono.cs} | 25 ++- .../LubanNoMono.cs.meta} | 0 .../NoMonoBehaviour/NoMono.cs | 42 +++++ .../NoMonoBehaviour/NoMono.cs.meta | 11 ++ .../RoleMgrNoMono.cs} | 38 ++++- .../RoleMgrNoMono.cs.meta} | 0 .../Main/CustomsComponent/NoMonoComponent.cs | 153 ++++++++++++++++++ .../CustomsComponent/NoMonoComponent.cs.meta | 11 ++ 23 files changed, 552 insertions(+), 150 deletions(-) delete mode 100644 Assets/Scripts/Main/CustomsComponent/EffectMgrComponent.cs create mode 100644 Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour.meta rename Assets/Scripts/Main/CustomsComponent/{BattleMgrComponent.cs => NoMonoBehaviour/BattleNoMono.cs} (88%) rename Assets/Scripts/Main/CustomsComponent/{BattleMgrComponent.cs.meta => NoMonoBehaviour/BattleNoMono.cs.meta} (100%) rename Assets/Scripts/Main/CustomsComponent/{BulletMgrComponent.cs => NoMonoBehaviour/BulletMgrNoMono.cs} (53%) rename Assets/Scripts/Main/CustomsComponent/{BulletMgrComponent.cs.meta => NoMonoBehaviour/BulletMgrNoMono.cs.meta} (100%) create mode 100644 Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/EffectNoMono.cs rename Assets/Scripts/Main/CustomsComponent/{EffectMgrComponent.cs.meta => NoMonoBehaviour/EffectNoMono.cs.meta} (100%) create mode 100644 Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/INoMonoBehaviour.cs create mode 100644 Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/INoMonoBehaviour.cs.meta rename Assets/Scripts/Main/CustomsComponent/{InputComponent.cs => NoMonoBehaviour/InputNoMono.cs} (92%) rename Assets/Scripts/Main/CustomsComponent/{InputComponent.cs.meta => NoMonoBehaviour/InputNoMono.cs.meta} (100%) rename Assets/Scripts/Main/CustomsComponent/{LubanComponent.cs => NoMonoBehaviour/LubanNoMono.cs} (62%) rename Assets/Scripts/Main/CustomsComponent/{LubanComponent.cs.meta => NoMonoBehaviour/LubanNoMono.cs.meta} (100%) create mode 100644 Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/NoMono.cs create mode 100644 Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/NoMono.cs.meta rename Assets/Scripts/Main/CustomsComponent/{RoleMgrComponent.cs => NoMonoBehaviour/RoleMgrNoMono.cs} (92%) rename Assets/Scripts/Main/CustomsComponent/{RoleMgrComponent.cs.meta => NoMonoBehaviour/RoleMgrNoMono.cs.meta} (100%) create mode 100644 Assets/Scripts/Main/CustomsComponent/NoMonoComponent.cs create mode 100644 Assets/Scripts/Main/CustomsComponent/NoMonoComponent.cs.meta diff --git a/Assets/Axibug/Axibug.prefab b/Assets/Axibug/Axibug.prefab index 3501cc9..dea3afd 100644 --- a/Assets/Axibug/Axibug.prefab +++ b/Assets/Axibug/Axibug.prefab @@ -72,18 +72,18 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 120382244} + - {fileID: 1841654392651735884} - {fileID: 658610398} - {fileID: 1657571477} - {fileID: 6993509460263203211} - {fileID: 1300239977} - {fileID: 1319979395} - - {fileID: 1091778791906574039} - {fileID: 4252941443528595760} - - {fileID: 1890265903537811374} - {fileID: 1455161061579575423} - {fileID: 8799381804509301542} - {fileID: 1809405776} - {fileID: 3666144938885549896} + - {fileID: 279668259149659524} - {fileID: 5844614599556982605} - {fileID: 6917580155287762257} m_Father: {fileID: 7219867924276195502} @@ -183,7 +183,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 348142342} - m_RootOrder: 1 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &658610399 MonoBehaviour: @@ -225,7 +225,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 348142342} - m_RootOrder: 4 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1319979394 GameObject: @@ -255,7 +255,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 348142342} - m_RootOrder: 5 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1657571476 GameObject: @@ -285,7 +285,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 348142342} - m_RootOrder: 2 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1692196357 GameObject: @@ -406,7 +406,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 348142342} - m_RootOrder: 11 + m_RootOrder: 10 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &2142655056 GameObject: @@ -531,7 +531,37 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 348142342} - m_RootOrder: 9 + m_RootOrder: 8 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1037504333823053521 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1841654392651735884} + m_Layer: 0 + m_Name: NoMono + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1841654392651735884 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1037504333823053521} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 348142342} + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1266064196098693916 GameObject: @@ -591,7 +621,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 348142342} - m_RootOrder: 10 + m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &3066668558062058701 GameObject: @@ -623,36 +653,6 @@ Transform: m_Father: {fileID: 348142342} m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &4047470345771744446 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1890265903537811374} - m_Layer: 0 - m_Name: Luban - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1890265903537811374 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4047470345771744446} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 348142342} - m_RootOrder: 8 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &5726855267738759965 GameObject: m_ObjectHideFlags: 0 @@ -683,7 +683,7 @@ Transform: - {fileID: 2142655057} - {fileID: 5437893104048697931} m_Father: {fileID: 348142342} - m_RootOrder: 3 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &6116728153081928790 GameObject: @@ -953,6 +953,36 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f2d610724341cc443890ad10e4687938, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!1 &7315382533406682711 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 279668259149659524} + m_Layer: 0 + m_Name: Bullet + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &279668259149659524 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7315382533406682711} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 348142342} + m_RootOrder: 12 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &7681822357474164521 GameObject: m_ObjectHideFlags: 0 @@ -981,37 +1011,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 348142342} - m_RootOrder: 12 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &7900566146616611867 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1091778791906574039} - m_Layer: 0 - m_Name: Input - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1091778791906574039 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7900566146616611867} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 348142342} - m_RootOrder: 6 + m_RootOrder: 11 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &7904639614614389035 PrefabInstance: diff --git a/Assets/Axibug/Script/Runtime/Base/GameEntry.cs b/Assets/Axibug/Script/Runtime/Base/GameEntry.cs index 5dae102..aefa23e 100644 --- a/Assets/Axibug/Script/Runtime/Base/GameEntry.cs +++ b/Assets/Axibug/Script/Runtime/Base/GameEntry.cs @@ -116,7 +116,7 @@ namespace Axibug.Runtime { if (gameFrameworkComponent == null) { - Log.Error("Cao Cao component is invalid."); + Log.Error("Axibug component is invalid."); return; } @@ -127,7 +127,7 @@ namespace Axibug.Runtime { if (current.Value.GetType() == type) { - Log.Error("Cao Cao component type '{0}' is already exist.", type.FullName); + Log.Error("Axibug component type '{0}' is already exist.", type.FullName); return; } diff --git a/Assets/Scripts/Main/Base/GamePlayEntry.cs b/Assets/Scripts/Main/Base/GamePlayEntry.cs index 4db808e..37d2a0f 100644 --- a/Assets/Scripts/Main/Base/GamePlayEntry.cs +++ b/Assets/Scripts/Main/Base/GamePlayEntry.cs @@ -5,6 +5,12 @@ namespace Game { public static class GamePlayEntry { + public static NoMonoComponent NoMono + { + get; + private set; + } + public static ResourcesComponent Resources { get; @@ -23,13 +29,13 @@ namespace Game private set; } - public static RoleMgrComponent RoleMgr + public static RoleMgrNoMono RoleMgr { get; private set; } - public static LubanComponent Luban + public static LubanNoMono Luban { get; set; @@ -41,7 +47,7 @@ namespace Game // set; //} - public static InputComponent Input + public static InputNoMono Input { get; set; @@ -65,13 +71,13 @@ namespace Game // set; //} - public static EffectMgrComponent EffectMgr + public static EffectNoMono EffectMgr { get; set; } - public static BattleMgrComponent Battle + public static BattleNoMono Battle { get; private set; @@ -89,6 +95,12 @@ namespace Game private set; } + public static BulletMgrNoMono BulletMgr + { + get; + private set; + } + //public static TaskComponent Task //{ // get; @@ -117,29 +129,42 @@ namespace Game { //随便取一个Axibug/Customs下的节点 Transform parent = AppEntry.HotUpdate.transform.parent; + NoMono = parent.Find("NoMono").gameObject.AddComponent(); + Transform LogicNode = parent.Find("Logic"); Resources = parent.Find("Resources").gameObject.AddComponent(); - Input = parent.Find("Input").gameObject.AddComponent(); Map = parent.Find("Map").gameObject.AddComponent(); MainPlayer = parent.Find("MainPlayer").gameObject.AddComponent(); - Luban = parent.Find("Luban").gameObject.AddComponent(); - RoleMgr = parent.Find("RoleMgr").gameObject.AddComponent(); + //Luban = parent.Find("Luban").gameObject.AddComponent(); //Network = parent.Find("Network").gameObject.AddComponent(); //DropMgr = parent.Find("DropMgr").gameObject.AddComponent(); //ItemMgr = parent.Find("ItemMgr").gameObject.AddComponent(); //ItemMgr.Init(); - EffectMgr = parent.Find("EffectMgr").gameObject.AddComponent(); + //EffectMgr = parent.Find("EffectMgr").gameObject.AddComponent(); Tips = parent.Find("Tips").gameObject.AddComponent(); //Task = parent.Find("Logic").gameObject.AddComponent(); //FindWay = parent.Find("Logic").gameObject.AddComponent(); - Battle = parent.Find("Logic").gameObject.AddComponent(); + //Battle = parent.Find("Logic").gameObject.AddComponent(); //Audio = parent.Find("Audio").gameObject.AddComponent(); GameObject go = Resources.CloneBySync("Assets/GameAssets/Prefabs/UI/UIYYControl/UIMgr.prefab", parent); - if (go == null) - return; + if (go != null) + UI = go.GetComponent(); + + + #region 无NoMonoBehaviour + Luban = new LubanNoMono(typeof(LubanNoMono).Name, LogicNode); + Input = new InputNoMono(typeof(InputNoMono).Name, LogicNode); + Battle = new BattleNoMono(typeof(BattleNoMono).Name, LogicNode); + RoleMgr = new RoleMgrNoMono(typeof(RoleMgrNoMono).Name, parent.Find("RoleMgr")); + EffectMgr = new EffectNoMono(typeof(EffectNoMono).Name, parent.Find("EffectMgr")); + BulletMgr = new BulletMgrNoMono(typeof(BulletMgrNoMono).Name, parent.Find("Bullet")); + //Input = parent.Find("Input").gameObject.AddComponent(); + //RoleMgr = parent.Find("RoleMgr").gameObject.AddComponent(); + //EffectMgr = parent.Find("EffectMgr").gameObject.AddComponent(); + //Battle = parent.Find("Logic").gameObject.AddComponent(); + #endregion - UI = go.GetComponent(); } } diff --git a/Assets/Scripts/Main/CustomsComponent/EffectMgrComponent.cs b/Assets/Scripts/Main/CustomsComponent/EffectMgrComponent.cs deleted file mode 100644 index c0b14bf..0000000 --- a/Assets/Scripts/Main/CustomsComponent/EffectMgrComponent.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Axibug.Runtime; -using UnityEngine; -using UnityEditor; -using Axibug.Resources; -using System.Collections.Generic; -using System.Diagnostics.SymbolStore; -using System.Runtime.Remoting.Metadata.W3cXsd2001; - -namespace Game -{ - public class EffectMgrComponent : GameComponent - { - public PrefabPool rolegastEftPool; - private void OnEnable() - { - rolegastEftPool = new PrefabPool(this.transform, E_PREFAB_TYPE.EFFECT); - } - } -} - diff --git a/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour.meta b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour.meta new file mode 100644 index 0000000..a67e5d2 --- /dev/null +++ b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d0ee4cb4c220f29428b8df8531f84b3d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Main/CustomsComponent/BattleMgrComponent.cs b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/BattleNoMono.cs similarity index 88% rename from Assets/Scripts/Main/CustomsComponent/BattleMgrComponent.cs rename to Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/BattleNoMono.cs index b71d0b1..7870db9 100644 --- a/Assets/Scripts/Main/CustomsComponent/BattleMgrComponent.cs +++ b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/BattleNoMono.cs @@ -1,28 +1,44 @@ using Axibug; using Axibug.Event; -using Axibug.Resources; using Axibug.Runtime; -using Codice.CM.WorkspaceServer.DataStore; -using Game.Config; using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UnityEditor; using UnityEngine; namespace Game { - public class BattleMgrComponent : GameComponent + public class BattleNoMono : NoMono { public UnitPool _HpDamagePool; - private void Start() + #region 生命周期 + public BattleNoMono(string Name, Transform trans = null) : base(Name, trans) { + //注册回调 + AddEvent(E_LIFE_MONO_CYCLE.Update | E_LIFE_MONO_CYCLE.FixUpdate); AppEntry.Event.Subscribe(AttackHitEventArgs.EventId, OnAttackHitEventArgs); _HpDamagePool = new UnitPool(GamePlayEntry.UI.m_NodeScreen); } + public override void Update() + { + + } + + public override void FixedUpdate() + { + + } + + public override void OnApplicationPause() + { + + } + public override void OnApplicationQuit() + { + + } + #endregion + private void OnAttackHitEventArgs(object sender, LogicEventArgs e) { AttackHitEventArgs msg = (AttackHitEventArgs)e; diff --git a/Assets/Scripts/Main/CustomsComponent/BattleMgrComponent.cs.meta b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/BattleNoMono.cs.meta similarity index 100% rename from Assets/Scripts/Main/CustomsComponent/BattleMgrComponent.cs.meta rename to Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/BattleNoMono.cs.meta diff --git a/Assets/Scripts/Main/CustomsComponent/BulletMgrComponent.cs b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/BulletMgrNoMono.cs similarity index 53% rename from Assets/Scripts/Main/CustomsComponent/BulletMgrComponent.cs rename to Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/BulletMgrNoMono.cs index edda759..4c7a655 100644 --- a/Assets/Scripts/Main/CustomsComponent/BulletMgrComponent.cs +++ b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/BulletMgrNoMono.cs @@ -8,22 +8,39 @@ using System.Runtime.Remoting.Metadata.W3cXsd2001; namespace Game { - public class BulletMgrComponent : GameComponent + public class BulletMgrNoMono : NoMono { public PrefabPoolForPath _BulletPool; - class BullteInfo - { - - } - - - private void OnEnable() + #region 生命周期 + public BulletMgrNoMono(string Name, Transform trans = null) : base(Name, trans) { _BulletPool = new PrefabPoolForPath(this.transform, E_PREFAB_TYPE.NONE, Common.GetBulletProfabPath("1")); + //注册回调 + AddEvent(E_LIFE_MONO_CYCLE.Update | E_LIFE_MONO_CYCLE.FixUpdate); } + public override void Update() + { + + } + + public override void FixedUpdate() + { + + } + + public override void OnApplicationPause() + { + + } + public override void OnApplicationQuit() + { + + } + #endregion + void NewBullet() { GameObject obj = _BulletPool.GetAnyHide(); diff --git a/Assets/Scripts/Main/CustomsComponent/BulletMgrComponent.cs.meta b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/BulletMgrNoMono.cs.meta similarity index 100% rename from Assets/Scripts/Main/CustomsComponent/BulletMgrComponent.cs.meta rename to Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/BulletMgrNoMono.cs.meta diff --git a/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/EffectNoMono.cs b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/EffectNoMono.cs new file mode 100644 index 0000000..49b48e3 --- /dev/null +++ b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/EffectNoMono.cs @@ -0,0 +1,44 @@ +using Axibug.Runtime; +using UnityEngine; +using UnityEditor; +using Axibug.Resources; +using System.Collections.Generic; +using System.Diagnostics.SymbolStore; +using System.Runtime.Remoting.Metadata.W3cXsd2001; + +namespace Game +{ + public class EffectNoMono : NoMono + { + public PrefabPool rolegastEftPool; + + #region 生命周期 + public EffectNoMono(string Name, Transform trans = null) : base(Name, trans) + { + rolegastEftPool = new PrefabPool(this.transform, E_PREFAB_TYPE.EFFECT); + //注册回调 + AddEvent(E_LIFE_MONO_CYCLE.Update | E_LIFE_MONO_CYCLE.FixUpdate); + } + + public override void Update() + { + + } + + public override void FixedUpdate() + { + + } + + public override void OnApplicationPause() + { + + } + public override void OnApplicationQuit() + { + + } + #endregion + } +} + diff --git a/Assets/Scripts/Main/CustomsComponent/EffectMgrComponent.cs.meta b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/EffectNoMono.cs.meta similarity index 100% rename from Assets/Scripts/Main/CustomsComponent/EffectMgrComponent.cs.meta rename to Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/EffectNoMono.cs.meta diff --git a/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/INoMonoBehaviour.cs b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/INoMonoBehaviour.cs new file mode 100644 index 0000000..dd5f796 --- /dev/null +++ b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/INoMonoBehaviour.cs @@ -0,0 +1,19 @@ +锘縰sing System; +using UnityEngine; + +namespace Game +{ + [Flags] + public enum E_LIFE_MONO_CYCLE + { + Update = 1, + FixUpdate, + ApplicationPause, + ApplicationQuit + } + interface INoMonoBehaviour + { + public void AddEvent(E_LIFE_MONO_CYCLE type); + + } +} diff --git a/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/INoMonoBehaviour.cs.meta b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/INoMonoBehaviour.cs.meta new file mode 100644 index 0000000..f002ca4 --- /dev/null +++ b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/INoMonoBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0dfef096df0f3224aa370ee013d22c4c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Main/CustomsComponent/InputComponent.cs b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/InputNoMono.cs similarity index 92% rename from Assets/Scripts/Main/CustomsComponent/InputComponent.cs rename to Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/InputNoMono.cs index d78f4b1..203291e 100644 --- a/Assets/Scripts/Main/CustomsComponent/InputComponent.cs +++ b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/InputNoMono.cs @@ -3,13 +3,14 @@ using Axibug.Event; using Axibug.Resources; using Axibug.Runtime; using System.Collections.Generic; +using Unity.Collections.LowLevel.Unsafe; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UIElements; namespace Game { - public class InputComponent : GameComponent + public class InputNoMono : NoMono { public Vector2 InputV2 { get { return _InputV2; } } public bool Attack { get { return _Attack; } } @@ -20,6 +21,37 @@ namespace Game public InputMotionData mInputMotionData = new InputMotionData(); + #region 生命周期 + public InputNoMono(string Name, Transform trans = null) :base(Name, trans) + { + mInputMotionData.OnEnable(); + AddEvent(E_LIFE_MONO_CYCLE.Update | E_LIFE_MONO_CYCLE.FixUpdate); + } + + public override void Update() + { + if (!GamePlayEntry.MainPlayer.InGame) + return; + + Update_Touch(); + Update_Input(); + Update_InputKeyCode(); + //更新行为列表逻辑 + mInputMotionData.Update_Logic(); + } + + public override void FixedUpdate() + { + } + public override void OnApplicationPause() + { + } + + public override void OnApplicationQuit() + { + } + #endregion + private void Start() { //事件注册 @@ -36,13 +68,12 @@ namespace Game void OnEnable() { - mInputMotionData.OnEnable(); } - void OnDisable() - { - mInputMotionData.OnDestory(); - } + //void OnDisable() + //{ + // mInputMotionData.OnDestory(); + //} /// /// 检测是否点击UI @@ -142,18 +173,6 @@ namespace Game return false; } - // Update is called once per frame - void Update() - { - if (!GamePlayEntry.MainPlayer.InGame) - return; - - Update_Touch(); - Update_Input(); - Update_InputKeyCode(); - //更新行为列表逻辑 - mInputMotionData.Update_Logic(); - } /// /// 点击 @@ -270,6 +289,7 @@ namespace Game return false; } } + #endregion } } diff --git a/Assets/Scripts/Main/CustomsComponent/InputComponent.cs.meta b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/InputNoMono.cs.meta similarity index 100% rename from Assets/Scripts/Main/CustomsComponent/InputComponent.cs.meta rename to Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/InputNoMono.cs.meta diff --git a/Assets/Scripts/Main/CustomsComponent/LubanComponent.cs b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/LubanNoMono.cs similarity index 62% rename from Assets/Scripts/Main/CustomsComponent/LubanComponent.cs rename to Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/LubanNoMono.cs index f3a6646..cedb63d 100644 --- a/Assets/Scripts/Main/CustomsComponent/LubanComponent.cs +++ b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/LubanNoMono.cs @@ -9,15 +9,34 @@ using static Axibug.Utility; namespace Game { - public class LubanComponent : GameComponent + public class LubanNoMono : NoMono { public Tables tables = null; - // Start is called before the first frame update - void Start() + #region 生命周期 + public LubanNoMono(string Name, Transform trans = null) : base(Name, trans) { tables = new Tables(LoadByteBuf); + //注册回调 + AddEvent(E_LIFE_MONO_CYCLE.Update | E_LIFE_MONO_CYCLE.FixUpdate); } + public override void Update() + { + + } + public override void FixedUpdate() + { + + } + public override void OnApplicationPause() + { + + } + public override void OnApplicationQuit() + { + + } + #endregion public static string GetConfigBytesPath(string fileName) { diff --git a/Assets/Scripts/Main/CustomsComponent/LubanComponent.cs.meta b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/LubanNoMono.cs.meta similarity index 100% rename from Assets/Scripts/Main/CustomsComponent/LubanComponent.cs.meta rename to Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/LubanNoMono.cs.meta diff --git a/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/NoMono.cs b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/NoMono.cs new file mode 100644 index 0000000..733b769 --- /dev/null +++ b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/NoMono.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using UnityEditorInternal; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace Game +{ + public abstract class NoMono : INoMonoBehaviour + { + public Transform transform; + public GameObject gameObject; + public E_LIFE_MONO_CYCLE mMonoCyle; + + public NoMono(string Name, Transform trans = null) + { + transform = trans; + gameObject = trans.gameObject; + NoMonoSys.RegisterNoMono(Name,this); + } + + public void AddEvent(E_LIFE_MONO_CYCLE type) + { + mMonoCyle = type; + if ((type & E_LIFE_MONO_CYCLE.Update) > 0) + NoMonoSys.AddUpdateEvent(Update); + if ((type & E_LIFE_MONO_CYCLE.FixUpdate) > 0) + NoMonoSys.AddUpdateEvent(FixedUpdate); + if ((type & E_LIFE_MONO_CYCLE.ApplicationPause) > 0) + NoMonoSys.AddUpdateEvent(OnApplicationPause); + if ((type & E_LIFE_MONO_CYCLE.ApplicationQuit) > 0) + NoMonoSys.AddUpdateEvent(OnApplicationQuit); + } + + public abstract void Update(); + public abstract void FixedUpdate(); + public abstract void OnApplicationPause(); + public abstract void OnApplicationQuit(); + + } +} + diff --git a/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/NoMono.cs.meta b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/NoMono.cs.meta new file mode 100644 index 0000000..b309c41 --- /dev/null +++ b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/NoMono.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4498ca1042e147149b733349e641d256 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Main/CustomsComponent/RoleMgrComponent.cs b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/RoleMgrNoMono.cs similarity index 92% rename from Assets/Scripts/Main/CustomsComponent/RoleMgrComponent.cs rename to Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/RoleMgrNoMono.cs index b6e70b1..2961998 100644 --- a/Assets/Scripts/Main/CustomsComponent/RoleMgrComponent.cs +++ b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/RoleMgrNoMono.cs @@ -11,7 +11,7 @@ using UnityEngine; namespace Game { - public class RoleMgrComponent : GameComponent + public class RoleMgrNoMono : NoMono { private Queue temp_RemoveUser = new Queue();//需要移除的玩家列表 private Dictionary dictAllRole = new Dictionary(); @@ -22,10 +22,11 @@ namespace Game private float temp_CheckTime = 0; private float temp_RequestTime = 0; - private int mRoleIdSeed = 0; - private void Start() + + #region 生命周期 + public RoleMgrNoMono(string Name, Transform trans = null) : base(Name, trans) { //AppEntry.Event.Subscribe(UserMoveEventArgs.EventId, OnUserMoveEvent); //AppEntry.Event.Subscribe(UserPlayerSkillEventArgs.EventId, OnUserPlayerSkill); @@ -34,6 +35,30 @@ namespace Game //AppEntry.Event.Subscribe(RoleLevelupEventArgs.EventId, OnRoleLevelUp); //AppEntry.Event.Subscribe(AddRoleBufferEvent.EventId, AddBuffer); //AppEntry.Event.Subscribe(RemoveRoleBufferEvent.EventId, RemoveBuffer); + AddEvent(E_LIFE_MONO_CYCLE.Update | E_LIFE_MONO_CYCLE.FixUpdate); + } + + public override void Update() + { + + } + + public override void FixedUpdate() + { + + } + public override void OnApplicationPause() + { + + } + public override void OnApplicationQuit() + { + + } + #endregion + + private void Start() + { } int GetNewRoleId() @@ -197,7 +222,7 @@ namespace Game { role.enabled = false; RemoveRole(role); - Destroy(role.gameObject); + GameObject.Destroy(role.gameObject); } private GameObject CloneRole(string RoleName,Transform parent) @@ -227,7 +252,7 @@ namespace Game return null; } - GameObject go = Instantiate(asset, parent) as GameObject; + GameObject go = GameObject.Instantiate(asset, parent) as GameObject; if (go == null) { Debug.LogError("LoadPrefabByEditor2. go == null. asset:" + asset); @@ -262,7 +287,7 @@ namespace Game return null; } - GameObject go = Instantiate(asset, parent) as GameObject; + GameObject go = GameObject.Instantiate(asset, parent) as GameObject; if (go == null) { Debug.LogError("LoadPrefabByEditor2. go == null. asset:" + asset); @@ -278,6 +303,7 @@ namespace Game mRigidbody.constraints = RigidbodyConstraints.FreezeRotation; } + } } diff --git a/Assets/Scripts/Main/CustomsComponent/RoleMgrComponent.cs.meta b/Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/RoleMgrNoMono.cs.meta similarity index 100% rename from Assets/Scripts/Main/CustomsComponent/RoleMgrComponent.cs.meta rename to Assets/Scripts/Main/CustomsComponent/NoMonoBehaviour/RoleMgrNoMono.cs.meta diff --git a/Assets/Scripts/Main/CustomsComponent/NoMonoComponent.cs b/Assets/Scripts/Main/CustomsComponent/NoMonoComponent.cs new file mode 100644 index 0000000..1f15bbd --- /dev/null +++ b/Assets/Scripts/Main/CustomsComponent/NoMonoComponent.cs @@ -0,0 +1,153 @@ +using Axibug; +using Axibug.Event; +using Axibug.Runtime; +using Codice.Client.Common.TreeGrouper; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data.Odbc; +using System.Xml.Serialization; +using UnityEngine; +using UnityEngine.SceneManagement; +using static Game.NoMonoComponent; + +namespace Game +{ + public class NoMonoComponent : GameComponent + { + public List NoMonoInfos = new List(); + + public event Action ApplicationPauseEvent; + public event Action ApplicationQuitEvent; + public event Action UpdateEvent; + public event Action FixedUpdateEvent; + public event Action SceneChangedEvent; + + [Serializable] + public class NoMonoInfo + { + public string Name; + public GameObject Obj; + public NoMono noMono; + } + + protected override void Awake() + { + base.Awake(); + } + + #region 提供生命周期 + + void Update() + { + //for (int i = 0; i < Nodes.Count; i++) + // Nodes[i].Update(); + + UpdateEvent?.Invoke(); + } + void FixedUpdate() + { + //for (int i = 0; i < Nodes.Count; i++) + // Nodes[i].FixedUpdate(); + + FixedUpdateEvent?.Invoke(); + } + + private void OnApplicationPause(bool pauseStatus) + { + if (pauseStatus) + { + ApplicationPauseEvent?.Invoke(); + } + } + private void OnApplicationQuit() + { + ApplicationQuitEvent?.Invoke(); + } + + #endregion + + } + + public static class NoMonoSys + { + static private NoMonoComponent _monoController => GamePlayEntry.NoMono; + + static public void RegisterNoMono(string Name, NoMono node) + { + _monoController.NoMonoInfos.Add(new NoMonoInfo() { Name = Name, Obj = node.gameObject, noMono = node }); + } + + static public Coroutine StartCoroutine(IEnumerator routine) + { + return _monoController.StartCoroutine(routine); + } + + static public void StopCoroutine(IEnumerator routine) + { + if (_monoController != null) + { + _monoController.StopCoroutine(routine); + } + } + + static public void AddApplicationQuitEvent(Action action) + { + _monoController.ApplicationQuitEvent += action; + } + + static public void RemoveApplicationQuitEvent(Action action) + { + _monoController.ApplicationQuitEvent -= action; + } + + static public void AddApplicationPauseEvent(Action action) + { + _monoController.ApplicationPauseEvent += action; + } + + static public void RemoveApplicationPauseEvent(Action action) + { + _monoController.ApplicationPauseEvent -= action; + } + + static public void AddUpdateEvent(Action action) + { + _monoController.UpdateEvent += action; + } + + static public void RemoveUpdateEvent(Action action) + { + _monoController.UpdateEvent -= action; + } + static public void AddSceneChangedEvent(Action action) + { + _monoController.SceneChangedEvent += action; + } + static public void RemoveSceneChangedEvent(Action action) + { + _monoController.SceneChangedEvent -= action; + } + + static public IEnumerator DelayCall(float delayTime, Action action, bool isRealTime = false) + { + var coroutine = DelayCallCoroutine(); + StartCoroutine(coroutine); + return coroutine; + + IEnumerator DelayCallCoroutine() + { + if (isRealTime) + { + yield return new WaitForSecondsRealtime(delayTime); + } + else + { + yield return new WaitForSeconds(delayTime); + } + action?.Invoke(); + } + } + } +} + diff --git a/Assets/Scripts/Main/CustomsComponent/NoMonoComponent.cs.meta b/Assets/Scripts/Main/CustomsComponent/NoMonoComponent.cs.meta new file mode 100644 index 0000000..187ab1a --- /dev/null +++ b/Assets/Scripts/Main/CustomsComponent/NoMonoComponent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d628ef740e7b0d440b49aebf096af744 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: