diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs index 743c5a8..c663335 100644 --- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs +++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs @@ -1422,62 +1422,6 @@ } /// - /// 延时指定时间调用一个回调函数 - /// - public void CallDelay(float delayTime, Action cb) - { - StartCoroutine(_CallDelay(delayTime, cb)); - } - - /// - /// 延时指定时间调用一个回调函数 - /// - public void CallDelay(float delayTime, Action cb, T1 arg1) - { - StartCoroutine(_CallDelay(delayTime, cb, arg1)); - } - - /// - /// 延时指定时间调用一个回调函数 - /// - public void CallDelay(float delayTime, Action cb, T1 arg1, T2 arg2) - { - StartCoroutine(_CallDelay(delayTime, cb, arg1, arg2)); - } - - /// - /// 延时指定时间调用一个回调函数 - /// - public void CallDelay(float delayTime, Action cb, T1 arg1, T2 arg2, T3 arg3) - { - StartCoroutine(_CallDelay(delayTime, cb, arg1, arg2, arg3)); - } - - private IEnumerator _CallDelay(float delayTime, Action cb) - { - yield return new WaitForSeconds(delayTime); - cb(); - } - - private IEnumerator _CallDelay(float delayTime, Action cb, T1 arg1) - { - yield return new WaitForSeconds(delayTime); - cb(arg1); - } - - private IEnumerator _CallDelay(float delayTime, Action cb, T1 arg1, T2 arg2) - { - yield return new WaitForSeconds(delayTime); - cb(arg1, arg2); - } - - private IEnumerator _CallDelay(float delayTime, Action cb, T1 arg1, T2 arg2, T3 arg3) - { - yield return new WaitForSeconds(delayTime); - cb(arg1,arg2, arg3); - } - - /// /// 将当前 ActivityObject 变成静态图像绘制到地面上, 用于优化渲染大量物体
/// 调用该函数后会排队进入渲染队列, 并且禁用所有行为, 当渲染完成后会销毁当前对象, 也就是调用 Destroy() 函数
///
diff --git a/DungeonShooting_Godot/src/framework/common/Utils.cs b/DungeonShooting_Godot/src/framework/common/Utils.cs index 99ce138..765ece3 100644 --- a/DungeonShooting_Godot/src/framework/common/Utils.cs +++ b/DungeonShooting_Godot/src/framework/common/Utils.cs @@ -1,3 +1,5 @@ +using System; +using System.Collections; using System.Linq; using Godot; @@ -160,4 +162,61 @@ return position.X >= rect.Position.X && position.X <= rect.End.X && position.Y >= rect.Position.Y && position.Y <= rect.End.Y; } + + + /// + /// 延时指定时间调用一个回调函数 + /// + public static void CallDelay(this ICoroutine coroutine, float delayTime, Action cb) + { + coroutine.StartCoroutine(_CallDelay(delayTime, cb)); + } + + /// + /// 延时指定时间调用一个回调函数 + /// + public static void CallDelay(this ICoroutine coroutine, float delayTime, Action cb, T1 arg1) + { + coroutine.StartCoroutine(_CallDelay(delayTime, cb, arg1)); + } + + /// + /// 延时指定时间调用一个回调函数 + /// + public static void CallDelay(this ICoroutine coroutine, float delayTime, Action cb, T1 arg1, T2 arg2) + { + coroutine.StartCoroutine(_CallDelay(delayTime, cb, arg1, arg2)); + } + + /// + /// 延时指定时间调用一个回调函数 + /// + public static void CallDelay(this ICoroutine coroutine, float delayTime, Action cb, T1 arg1, T2 arg2, T3 arg3) + { + coroutine.StartCoroutine(_CallDelay(delayTime, cb, arg1, arg2, arg3)); + } + + private static IEnumerator _CallDelay(float delayTime, Action cb) + { + yield return new WaitForSeconds(delayTime); + cb(); + } + + private static IEnumerator _CallDelay(float delayTime, Action cb, T1 arg1) + { + yield return new WaitForSeconds(delayTime); + cb(arg1); + } + + private static IEnumerator _CallDelay(float delayTime, Action cb, T1 arg1, T2 arg2) + { + yield return new WaitForSeconds(delayTime); + cb(arg1, arg2); + } + + private static IEnumerator _CallDelay(float delayTime, Action cb, T1 arg1, T2 arg2, T3 arg3) + { + yield return new WaitForSeconds(delayTime); + cb(arg1,arg2, arg3); + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/ui/UiBase.cs b/DungeonShooting_Godot/src/framework/ui/UiBase.cs index de390b5..3a2f1a2 100644 --- a/DungeonShooting_Godot/src/framework/ui/UiBase.cs +++ b/DungeonShooting_Godot/src/framework/ui/UiBase.cs @@ -244,60 +244,4 @@ { ProxyCoroutineHandler.ProxyStopAllCoroutine(ref _coroutineList); } - - /// - /// 延时指定时间调用一个回调函数 - /// - public void CallDelay(float delayTime, Action cb) - { - StartCoroutine(_CallDelay(delayTime, cb)); - } - - /// - /// 延时指定时间调用一个回调函数 - /// - public void CallDelay(float delayTime, Action cb, T1 arg1) - { - StartCoroutine(_CallDelay(delayTime, cb, arg1)); - } - - /// - /// 延时指定时间调用一个回调函数 - /// - public void CallDelay(float delayTime, Action cb, T1 arg1, T2 arg2) - { - StartCoroutine(_CallDelay(delayTime, cb, arg1, arg2)); - } - - /// - /// 延时指定时间调用一个回调函数 - /// - public void CallDelay(float delayTime, Action cb, T1 arg1, T2 arg2, T3 arg3) - { - StartCoroutine(_CallDelay(delayTime, cb, arg1, arg2, arg3)); - } - - private IEnumerator _CallDelay(float delayTime, Action cb) - { - yield return new WaitForSeconds(delayTime); - cb(); - } - - private IEnumerator _CallDelay(float delayTime, Action cb, T1 arg1) - { - yield return new WaitForSeconds(delayTime); - cb(arg1); - } - - private IEnumerator _CallDelay(float delayTime, Action cb, T1 arg1, T2 arg2) - { - yield return new WaitForSeconds(delayTime); - cb(arg1, arg2); - } - - private IEnumerator _CallDelay(float delayTime, Action cb, T1 arg1, T2 arg2, T3 arg3) - { - yield return new WaitForSeconds(delayTime); - cb(arg1,arg2, arg3); - } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs b/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs index f6a5ab0..3a58b9b 100644 --- a/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs +++ b/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs @@ -1276,7 +1276,7 @@ } else { - CallDelay(Attribute.BeLoadedSoundDelayTime, PlaySpriteAnimation, AnimatorNames.BeLoaded); + this.CallDelay(Attribute.BeLoadedSoundDelayTime, PlaySpriteAnimation, AnimatorNames.BeLoaded); } } @@ -1294,7 +1294,7 @@ //创建一个弹壳 if (Attribute.ThrowShellDelayTime > 0) { - CallDelay(Attribute.ThrowShellDelayTime, () => ThrowShell(Attribute.ShellId, speedScale)); + this.CallDelay(Attribute.ThrowShellDelayTime, () => ThrowShell(Attribute.ShellId, speedScale)); } else if (Attribute.ThrowShellDelayTime == 0) {