コード例 #1
0
 public void Update(float elapsedSeconds)
 {
     foreach (Entity e in this.actives.Values)
     {
         SpriteAnimationComponent animation = e.GetComponent<SpriteAnimationComponent>();
         if (e.HasComponent<IntentComponent>())
         {
             if (e.GetComponent<IntentComponent>().IntentManager.HasIntent(Intent.Accelerate))
             {
                 animation.Visible = true;
             }
             else
             {
                 animation.Visible = false;
             }
         }
         animation.Animation.Update(elapsedSeconds);
     }
 }
コード例 #2
0
        public override void Draw(float elapsedSeconds, SpriteBatch spriteBatch)
        {
            //Parallel.ForEach(this.actives.Values, (e) =>
            //{

            //});

            foreach (Entity e in this.actives.Values)
            {
                TransformComponent transform = e.GetComponent<TransformComponent>();
                SpriteAnimationComponent animation = e.GetComponent<SpriteAnimationComponent>();

                System.Diagnostics.Debug.Assert(transform != null, "TransformComponent not found");
                System.Diagnostics.Debug.Assert(animation != null, "SpriteAnimationComponent not found");

                if (animation.Visible)
                {
                    spriteBatch.Draw(animation.Animation.Texture, transform.EntityToWorld(animation.Offset) * WindowSettings.UnitScale, animation.Animation.GetCurrentFrame(),
                        Color.White, transform.Rotation, animation.Animation.Origin, animation.Scale * WindowSettings.UnitScale, SpriteEffects.None, 0.8f);
                }
            }
        }