示例#1
0
 public void Reset()
 {
     AnimationController.ResetTrigger(AnimationData.Move);
     AnimationController.ResetTrigger(AnimationData.Idle);
     AnimationController.ResetTrigger(AnimationData.BasicAbility);
     AnimationController.ResetTrigger(AnimationData.SecondaryAbility);
     AnimationData = DefaultAnimationData;
 }
示例#2
0
 public void SwitchAnimation(string animationName)
 {
     if (AnimationNames.Contains(animationName))
     {
         currentAnimation = Array.IndexOf(AnimationNames, animationName);
     }
     else
     {
         currentAnimation = 0;
     }
 }
        private static AnimationTemplate LoadTemplate(AnimationNames name, string file)
        {
            var text  = File.ReadAllText(file);
            var parts = text.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length < 2)
            {
                throw new InvalidOperationException("Couldn't load animation, insufficient parts");
            }

            if (!int.TryParse(parts[0], out var steps))
            {
                throw new InvalidOperationException($"Couldn't parse step for animation, expected integer, found: {parts[0]}");
            }
            if (steps < 0)
            {
                throw new InvalidOperationException("Steps for animation is < 0");
            }

            var frames  = new AssetNames[4];
            var frameIx = 0;

            for (var i = 1; i < parts.Length; i++)
            {
                var frame = parts[i];
                if (!Enum.TryParse <AssetNames>(frame, ignoreCase: true, out var parsedFrame))
                {
                    throw new InvalidOperationException($"Couldn't parse animation frame, found: {frame}");
                }

                if (frameIx == frames.Length)
                {
                    Array.Resize(ref frames, frames.Length * 2);
                }

                frames[frameIx] = parsedFrame;
                frameIx++;
            }

            Array.Resize(ref frames, frameIx);

            return(new AnimationTemplate(name, frames, steps));
        }
示例#4
0
        public void AddAnimation(Animation animation, string animationName)
        {
            if (AnimationNames.Contains(animationName))
            {
                throw new Exception(string.Format("Animation by given name \"&1\" already exist.", animationName));
            }

            for (int index = 1; index < animationList.Length; index++)
            {
                if (animationList[index] == null)
                {
                    animationList[index]  = animation;
                    AnimationNames[index] = animationName;
                    return;
                }
            }


            throw new IndexOutOfRangeException(string.Format("Animation \"&1\" was out of range of the specified amount.", animationName));
        }
示例#5
0
 public void PlayAnimation(AnimationNames animationName)
 {
     animator.SetBool(animationName.ToString(), true);
 }
 public void SwitchTo(AnimationNames animation)
 {
     Name        = animation;
     TickCounter = 0;
 }
 public void Initialize(IAnimationManager manager, AnimationNames name, int startFrame)
 {
     Name        = name;
     TickCounter = (uint)(startFrame * manager.Get(name).StepAfter);
 }
示例#8
0
 public void SetAnimation(Static.Character animation)
 {
     _animatedSprite.Animation = AnimationNames.GetCharacterAnimation(animation);
 }
示例#9
0
 void Start()
 {
     DefaultAnimationData = AnimationData;
 }
示例#10
0
 public AnimationTemplate(AnimationNames name, AssetNames[] frames, int stepAfter)
 {
     _Name      = name;
     _Frames    = frames;
     _StepAfter = stepAfter;
 }
 public AnimationTemplate Get(AnimationNames names) => Templates[(int)names];
 internal void Play(AnimationNames name)
 {
     animator?.Play(name.ToString(), 0, 0f);
 }