Exemple #1
0
        /// <summary>Draw a tracking arrow pointer over a target on-screen.</summary>
        /// <param name="target">A target on the game location.</param>
        /// <param name="color">The color of the pointer.</param>
        /// <remarks>Note that the game will add a yellow tinge to the color supplied here. Credit to Bpendragon for this logic.</remarks>
        public static void DrawArrowPointerOverTarget(Vector2 target, Color color)
        {
            if (!SUtility.isOnScreen(target * 64f + new Vector2(32f, 32f), 64))
            {
                return;
            }

            ArrowPointer ??= new ArrowPointer(AwesomeProfessions.Content.Load <Texture2D>(Path.Combine("assets", "cursor.png")));

            var         srcRect       = new Rectangle(0, 0, 5, 4);
            const float renderScale   = 4f;
            var         targetPixel   = new Vector2((target.X * 64f) + 32f, (target.Y * 64f) + 32f) + ArrowPointer.GetOffset();
            var         adjustedPixel = Game1.GlobalToLocal(Game1.viewport, targetPixel);

            adjustedPixel = SUtility.ModifyCoordinatesForUIScale(adjustedPixel);
            Game1.spriteBatch.Draw(ArrowPointer.Texture, adjustedPixel, srcRect, color, (float)Math.PI, new Vector2(2f, 2f), renderScale, SpriteEffects.None, 1f);
        }