Exemplo n.º 1
0
 public void UpdateAnimation(GameTime gameTime, IEnumerable <Entity> entities)
 {
     foreach (Entity e in entities)
     {
         AnimatedTexture2D anim = db.GetAnimation(e.texName);
         if (anim != null)
         {
             anim.UpdateTime(gameTime, e);
         }
     }
 }
Exemplo n.º 2
0
        private void ChangeSelection(IEnumerable <Entity> entities)
        {
            int sel = -1;

            foreach (Entity e in entities)
            {
                int width  = 0;
                int height = 0;

                AnimatedTexture2D anim = db.GetAnimation(e.texName);
                if (anim == null)
                {
                    Texture2D tex = db.Get(e.texName);
                    width  = tex.Width;
                    height = tex.Height;
                }
                else
                {
                    Rectangle rect = anim.GetWindow(e.index);
                    width  = rect.Width;
                    height = rect.Height;
                }

                Vector2   p = c.GetRenderPosition(new Point((int)e.x, (int)e.y), new Vector2(width, height));
                Rectangle r = new Rectangle((int)p.X, (int)p.Y, width, height);

                if (r.Contains(newSel))
                {
                    sel = e.id;
                }
            }

            onSelect(sel);
        }