Пример #1
0
        public override void Update(GameTime gameTime, GameInfo gameInfo)
        {
            if (Properties != null)
            {
                if (Info.AnimationProperty != Util.GetEngineNull() && CurrentAnimationKey != Properties[Info.AnimationProperty].GetAsString())
                {
                    CurrentAnimationKey = Properties[Info.AnimationProperty].GetAsString();
                    CurrentAnimation    = ContentLoader.GetAnimation(CurrentAnimationKey);

                    if (CurrentAnimation != null)
                    {
                        CurrentAnimation.Play();
                    }
                    else
                    {
                        CurrentAnimation = Info.DefaultAnimation;
                    }
                }
            }

            foreach (ComponentInfo component in Components)
            {
                component.Update(gameTime, gameInfo);
            }

            base.Update(gameTime, gameInfo);
        }
Пример #2
0
        public override void Update(DwarfTime gameTime, ChunkManager chunks, Camera camera)
        {
            CalculateCurrentOrientation(camera);

            string s = currentMode + OrientationStrings[(int)CurrentOrientation];

            if (Animations.ContainsKey(s))
            {
                CurrentAnimation = Animations[s];
                CurrentAnimation.Play();

                SpriteSheet = CurrentAnimation.SpriteSheet;
            }

            base.Update(gameTime, chunks, camera);
        }
Пример #3
0
        public bool PlayAnimation(bool play)
        {
            if (CurrentAnimation == null)
            {
                return(false);
            }

            if (play)
            {
                CurrentAnimation.Play();
                return(true);
            }

            CurrentAnimation.Pause();
            return(false);
        }
Пример #4
0
        public void Play(string name, bool forceRestart = false)
        {
            if (name == null || !_animations.ContainsKey(name))
            {
                //TODO: Logger
                return;
            }

            Animation newAnimation = _animations[name];

            if (CurrentAnimation != newAnimation)
            {
                newAnimation.Reset();
            }

            CurrentAnimation = newAnimation;
            CurrentAnimation.Play(forceRestart);
        }