public void update(Person person, GameTime gameTime) { updatePosition(person); animation.update(gameTime); foreach (Resource r in resources) r.update(gameTime); }
// TODO: Untested removeFromQueue() public bool removeFromQueue(Person person) { foreach (var p in spotsInTheQueue) { if (p.Equals(person)) { spotsInTheQueue.Remove(p); return true; } } return false; }
public void draw(Person person, SpriteBatch spriteBatch, int yOffset = 0) { int x = (int)person.Position.X; int y = (int)person.Position.Y; int sx = width * currentFrame; int sy = height * yOffset; bool selected = person.selected; bool highlighted = person.highlighted; Color color = Color.White; SpriteEffects facing = SpriteEffects.None; Rectangle destRect = new Rectangle(x, y, width, height); Rectangle sourceRect = new Rectangle(sx, sy, width, height); if (selected) color = selectColor; else if (highlighted) color = highlightColor; if (flipped) facing = SpriteEffects.FlipHorizontally; spriteBatch.Draw(sprite.sprite, destRect, sourceRect, color, 0f, Vector2.Zero, facing, 0f); }
private void updatePosition(Person person) { int pWidth = person.animation.width; int pHeight = person.animation.height; int x = position.X; int y = position.Y; int flip = 1; if (animation.flipped) { x = (int)person.Position.X - width; flip = -1; } else { x = (int)person.Position.X + pWidth; } y = (int)person.Position.Y - height / 2; x = setX(x); y = setY(y); Point startPos = new Point(x + resourceSideOffset * flip, y + resourceTopOffset); for (int i = 0; i < resources.Count; i++) { int rw = resources[i].animation.width; int rh = resources[i].animation.height; int rx = startPos.X + (i * (rw + resourceSpacing)); int ry = startPos.Y; resources[i].position = new Point(rx, ry); } }