From 1d04cba18a962f874fc6a1bc116a2f65cdc588b9 Mon Sep 17 00:00:00 2001 From: Victor Chelaru Date: Fri, 24 Nov 2023 10:52:01 -0700 Subject: [PATCH] Added animation layer support for sequence. --- .../Graphics/Animation/AnimationLayer.cs | 45 +++++++++++++++++++ .../PreviewProject/bin/Debug/AESettings.json | 1 - 2 files changed, 45 insertions(+), 1 deletion(-) delete mode 100644 FRBDK/AnimationEditor/PreviewProject/bin/Debug/AESettings.json diff --git a/Engines/FlatRedBallXNA/FlatRedBall/Graphics/Animation/AnimationLayer.cs b/Engines/FlatRedBallXNA/FlatRedBall/Graphics/Animation/AnimationLayer.cs index 98eb48cbb..ca027f750 100644 --- a/Engines/FlatRedBallXNA/FlatRedBall/Graphics/Animation/AnimationLayer.cs +++ b/Engines/FlatRedBallXNA/FlatRedBall/Graphics/Animation/AnimationLayer.cs @@ -38,6 +38,8 @@ public class AnimationLayer : INameable /// is facing left/right. /// public Func EveryFrameAction; + public Func> EveryFrameActionSequence; + public Action OnAnimationFinished; /// @@ -103,6 +105,49 @@ internal void Activity() { cachedChainName = EveryFrameAction(); } + else if(EveryFrameActionSequence != null) + { + var list = EveryFrameActionSequence(); + + if(list?.Count > 0) + { + // start the sequence, just in case there are no other animations... + + cachedChainName = list[0]; + var animatable = Container?.AnimatedObject; + + if(animatable != null) + { + + var indexToShow = 0; + + int? matchingIndex = 0; + for(int i = 0; i < list.Count; i++) + { + if (animatable.IsPlayingAnimation(list[i])) + { + matchingIndex = i; + if(animatable.DidAnimationFinishOrLoop) + { + var nextIndex = i < list.Count-1 + ? i + 1 + : i; // don't loop the sequence. Maybe we'll add that option later. + cachedChainName = list[nextIndex]; + } + else + { + cachedChainName = list[i]; + } + break; + } + } + } + } + else + { + cachedChainName = null; + } + } else { var playingModeThisFrame = playingMode; diff --git a/FRBDK/AnimationEditor/PreviewProject/bin/Debug/AESettings.json b/FRBDK/AnimationEditor/PreviewProject/bin/Debug/AESettings.json deleted file mode 100644 index 11226e48d..000000000 --- a/FRBDK/AnimationEditor/PreviewProject/bin/Debug/AESettings.json +++ /dev/null @@ -1 +0,0 @@ -{"RecentFiles":["C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/UiAnimationChains.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/Enemy/Migo.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/Enemy/Evilvine.achx","C:/Users/vchel/Documents/GitHub/FlatRedBall/FRBDK/Glue/OfficialPlugins/Wizard/EmbeddedContent/Platformer/PlatformerAnimations.achx","C:/Users/vchel/Documents/FlatRedBallProjects/WallJumpTutorial/WallJumpTutorial/Content/Entities/Player/PlatformerAnimations.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/Bullet/AnimationChainListFile.achx","C:/Users/vchel/Documents/GitHub/masteroid/Masteroid/Content/GlobalContent/Asteroids.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/StaticDestroyableObject/AnimationChainListFile.achx","C:/Users/vchel/Documents/FlatRedBallProjects/Beefball3/Beefball3/Content/Screens/GameScreen/AnimationChainListFile.achx","C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/Entities/Ui/Emoticons/AnimationChainListFile.achx","C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/Entities/Prop/PropAnimations.achx","C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/Entities/Player/PlayerBodyAnimations1.achx","C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/Entities/HomeBase/HomeBaseAnimations.achx","C:/Users/vchel/Documents/GitHub/KidDefense/GameProject/KidDefense/Content/Entities/Player/FlashlightAnimations.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/Enemy/EyeballThing.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/Enemy/BoomBabyShoggoth.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/EnemyBullet/PoisonCloudAnimation.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/EnemyDeathEffect/AnimationChainListFile.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/EnemyBullet/BlackHoleShotAnimation.achx","C:/Users/vchel/Documents/GitHub/Kimuzukash-chibi-kuto-urufu/CrankyChibiCthulu/Content/Entities/EnemyBullet/ParasiteShotAnimation.achx"]} \ No newline at end of file