There are many ways to implement animations, generally you would use a sprite sheet. This can get compilcated, but an easy way is to predefine character size, for example 128*64, and pre-calculate the number of lines and columns to get the total number of frames. I assume you are familiar with this however.
You could end up with something like this (C# esque assuming tightly packed sprite sheet) :
class Animation {
Texture2D spriteSheet;
ushort rows, columns;
Animation(ushort spriteWidth, ushort spriteHeight)
{
rows = spriteSheet.Height / spriteHeight;
columns = spriteSheet.Width / spriteWidth;
}
Rectangle GetFrame(ushort frameNumber);
};
If you have hundreds of animations, this will mean hundreds of sprite sheets and lots of memory. If you look at some older games, you could have the same animation for each melee attack, but the weapon's animation was put on top of that. This means a big save in sprite sheets, and could be useful.
To check what attack a player currently has, I would simply have an array of animations (pre-loaded or not) which will be referenced by the player depending on the attacks he chooses. If you choose to decouple parts of the animation, an AttackAnimation
could contain multiple animations for the top half of the body, the bottom hals, the weapon, etc.
That could be something like this :
class AttackingAnimation {
List<Animations> animationList;
// Draw and update all animations...
}
class Player {
AttackingAnimation attackingAnimations[10];
DoAttack(int attackIndex);
};