예제 #1
0
        public void Draw(SpriteBatch spriteBatch, int x, int y)
        {
            Color color = IsIdling ? Color.Green : Color.Orange;

            spriteBatch.Draw(Texture,
                             new Rectangle(x, y, World.BlockSize, World.BlockSize),
                             new Rectangle(0, 0, Texture.Width, Texture.Height),
                             color,
                             0.0f,
                             new Vector2(0),
                             SpriteEffects.None,
                             DrawLayer.Pawn
                             );

            if (carrying != null)
            {
                Point drawCarrying = new Point(x, y);
                int   offset       = World.BlockSize / 4;
                if (direction == Facing.North)
                {
                    drawCarrying.Y -= offset;
                }
                else if (direction == Facing.East)
                {
                    drawCarrying.X += offset;
                }
                else if (direction == Facing.South)
                {
                    drawCarrying.Y += offset;
                }
                else if (direction == Facing.West)
                {
                    drawCarrying.X -= offset;
                }
                carrying.Draw(spriteBatch, drawCarrying.X, drawCarrying.Y, DrawLayer.Pawn - 0.02f);
            }

            if (IsSelected)
            {
                ShapeManager.DrawCircle(spriteBatch, new Point(x + World.BlockSize / 2, y + World.BlockSize / 2), World.BlockSize / 2, Color.Red);

                if (pathfinder != null && pathfinder.Path != null)
                {
                    Cell previous = nextCell;

                    foreach (Cell next in pathfinder.Path)
                    {
                        ShapeManager.DrawLine(spriteBatch,
                                              new Point(previous.X * World.BlockSize + World.BlockSize / 2, previous.Y * World.BlockSize + World.BlockSize / 2),
                                              new Point(next.X * World.BlockSize + World.BlockSize / 2, next.Y * World.BlockSize + World.BlockSize / 2),
                                              Color.Magenta
                                              );
                        previous = next;
                    }
                }
            }
        }