Code: Select all
public class AnimationController {
public void ChangeAnimation(string animation, int priority = 0, float crossfadeDuration = 0.2f, float animationSpeed = 1f) {
if(priority is higher && this animation isn't already playing) {
model.PlayAnimation(animation);
}
}
}
Code: Select all
public void ChangeAnimation(FireballAnimation animation)
Und ich würde es vorziehen, die .ToString()-Methode nicht jedes Mal aufzurufen, wenn ich ChangeAnimation( aufrufen möchte )
Ich möchte, dass Folgendes in derselben Codebasis möglich ist:
Code: Select all
// In the context of a fireball class:
public enum FireballAnimation {
Casted,
Flying,
Impact,
}
AnimationController.ChangeAnimation(FireballAnimation.Impact);
// In the context of a Player class:
public enum PlayerAnimation {
None,
Idle,
Walking,
StrafingLeft,
StrafingRight,
WalkingBackwards,
Jumping,
Casting,
}
AnimationController.ChangeAnimation(PlayerAnimation.Jumping);