Example #1
0
        public override void Draw(DrawingArgs args)
        {
            // Draw the heart if we haven't been accepted
            if (!Prayer.IsAccepted)
            {
                // Start by drawing the speech bubble
                base.Draw(args);

                // Get the heart drawable, large if the mouse is over it
                if (isMouseOver)
                {
                    IDrawable hd = AssetLoader.Instance.CreateDrawable("Heart");
                    PointF point = new PointF(
                        Point.X + args.ScreenOffsetX + 1,
                        Point.Y + args.ScreenOffsetY + 20);
                    hd.Draw(point, Color.White, args.BackendDrawingArgs);
                }
                else
                {
                    // Show the mini heart
                    IDrawable hd = AssetLoader.Instance
                        .CreateDrawable("Half Heart");
                    PointF point = new PointF(
                        Point.X + args.ScreenOffsetX + 15,
                        Point.Y + args.ScreenOffsetY + 45);
                    hd.Draw(point, Color.White, args.BackendDrawingArgs);
                }
            }
            else
            {
                // See if we have no more seconds
                if (secondsLeft < 0)
                {
                    topDown = null;
                    return;
                }

                // Figure out the alpha channel stuff
                double delta = secondsLeft / Constants.PrayerSpeechFade;
                Color c = Color.FromArgb((int) (delta * 255), 255, 255, 255);

                // Start by drawing the speech bubble
                base.Draw(args, c);

                // See if we have a viewport to accept
                if (topDown == null)
                {
                    // Create the top-down element
                    topDown = new TopDownViewport(Prayer.Board);
                    topDown.BlockFilter =
                        IndicatorsViewport.FilterConstruction;

                    // Set up the initial point
                    PointF point = new PointF(
                        Point.X + args.ScreenOffsetX + 13,
                        Point.Y + args.ScreenOffsetY + 73);
                    topDown.Point = point;

                    // Scale the viewport to fit
                    int cols = prayer.Board.Columns;
                    int rows = prayer.Board.Rows;
                    float width = 80
                        - topDown.Margin * 2
                        - topDown.Padding * (cols - 1);
                    float height = 80
                        - topDown.Margin * 2
                        - topDown.Padding * (rows - 1);
                    width = Math.Min(width, height);
                    topDown.BlockWidth = width / (float) cols;
                    topDown.BlockHeight = width / (float) rows;
                }

                // Perform the drawing
                topDown.Draw(args, delta);
            }
        }
Example #2
0
        public override void Draw(DrawingArgs args)
        {
            // Draw the heart if we haven't been accepted
            if (!Prayer.IsAccepted)
            {
                // Start by drawing the speech bubble
                base.Draw(args);

                // Get the heart drawable, large if the mouse is over it
                if (isMouseOver)
                {
                    IDrawable hd    = AssetLoader.Instance.CreateDrawable("Heart");
                    PointF    point = new PointF(
                        Point.X + args.ScreenOffsetX + 1,
                        Point.Y + args.ScreenOffsetY + 20);
                    hd.Draw(point, Color.White, args.BackendDrawingArgs);
                }
                else
                {
                    // Show the mini heart
                    IDrawable hd = AssetLoader.Instance
                                   .CreateDrawable("Half Heart");
                    PointF point = new PointF(
                        Point.X + args.ScreenOffsetX + 15,
                        Point.Y + args.ScreenOffsetY + 45);
                    hd.Draw(point, Color.White, args.BackendDrawingArgs);
                }
            }
            else
            {
                // See if we have no more seconds
                if (secondsLeft < 0)
                {
                    topDown = null;
                    return;
                }

                // Figure out the alpha channel stuff
                double delta = secondsLeft / Constants.PrayerSpeechFade;
                Color  c     = Color.FromArgb((int)(delta * 255), 255, 255, 255);

                // Start by drawing the speech bubble
                base.Draw(args, c);

                // See if we have a viewport to accept
                if (topDown == null)
                {
                    // Create the top-down element
                    topDown             = new TopDownViewport(Prayer.Board);
                    topDown.BlockFilter =
                        IndicatorsViewport.FilterConstruction;

                    // Set up the initial point
                    PointF point = new PointF(
                        Point.X + args.ScreenOffsetX + 13,
                        Point.Y + args.ScreenOffsetY + 73);
                    topDown.Point = point;

                    // Scale the viewport to fit
                    int   cols  = prayer.Board.Columns;
                    int   rows  = prayer.Board.Rows;
                    float width = 80
                                  - topDown.Margin * 2
                                  - topDown.Padding * (cols - 1);
                    float height = 80
                                   - topDown.Margin * 2
                                   - topDown.Padding * (rows - 1);
                    width = Math.Min(width, height);
                    topDown.BlockWidth  = width / (float)cols;
                    topDown.BlockHeight = width / (float)rows;
                }

                // Perform the drawing
                topDown.Draw(args, delta);
            }
        }
Example #3
0
        /// <summary>
        /// Updates the prayer viewport to show/include/remove the
        /// top-down views to fit the current view.
        /// </summary>
        private void UpdatePrayers()
        {
            // Build up a list of ones to remove
            LinkedList<Prayer> oldKeys = new LinkedList<Prayer>();
            oldKeys.AddAll(prayerViews.Keys);

            // Loop through the prayers
            float x = Padding;

            foreach (Prayer prayer in Game.State.Prayers)
            {
                // Ignore invisible prayers
                if (!prayer.IsAccepted)
                    continue;

                // See if we have the view
                if (!prayerViews.Contains(prayer))
                {
                    // We need to create the top-down view
                    TopDownViewport tdv = new TopDownViewport(prayer.Board);
                    tdv.BlockFilter = FilterConstruction;

                    // Set the value
                    prayerViews[prayer] = tdv;
                    prayerViewport.Add(tdv);
                }
                else
                {
                    // Remove this from the to-remove (old) list
                    oldKeys.Remove(prayer);
                }

                // Change the location of the viewport
                TopDownViewport v = prayerViews[prayer];
                v.Point = new PointF(x, Padding);

                // Adjust the size based on how close the mouse is to
                // viewport.
                float size = 8;
                float left = Math.Abs(mousePoint.X - v.Point.X);
                float right =
                    Math.Abs(mousePoint.X - (v.Point.X + v.Size.Width));

                // Average these two to get the midpoint
                float average = (left + right) / 2;

                // Only make a different if we are with 64 of it
                if (average <= 64)
                {
                    float ratio = (64 - average) / 64;
                    size += ratio * 8;
                }

                v.BlockHeight = v.BlockWidth = size;

                // Update the new x coordinate
                v.Size = v.Extents.Size;
                x += Padding + v.Size.Width;
            }

            // Anything left in the old list needs to be removed
            foreach (Prayer prayer in oldKeys)
            {
                // Get the viewport
                TopDownViewport ov = prayerViews[prayer];
                prayerViewport.Remove(ov);
                prayerViews.Remove(prayer);
            }
        }
Example #4
0
        /// <summary>
        /// Updates the prayer viewport to show/include/remove the
        /// top-down views to fit the current view.
        /// </summary>
        private void UpdatePrayers()
        {
            // Build up a list of ones to remove
            LinkedList <Prayer> oldKeys = new LinkedList <Prayer>();

            oldKeys.AddAll(prayerViews.Keys);

            // Loop through the prayers
            float x = Padding;

            foreach (Prayer prayer in Game.State.Prayers)
            {
                // Ignore invisible prayers
                if (!prayer.IsAccepted)
                {
                    continue;
                }

                // See if we have the view
                if (!prayerViews.Contains(prayer))
                {
                    // We need to create the top-down view
                    TopDownViewport tdv = new TopDownViewport(prayer.Board);
                    tdv.BlockFilter = FilterConstruction;

                    // Set the value
                    prayerViews[prayer] = tdv;
                    prayerViewport.Add(tdv);
                }
                else
                {
                    // Remove this from the to-remove (old) list
                    oldKeys.Remove(prayer);
                }

                // Change the location of the viewport
                TopDownViewport v = prayerViews[prayer];
                v.Point = new PointF(x, Padding);

                // Adjust the size based on how close the mouse is to
                // viewport.
                float size  = 8;
                float left  = Math.Abs(mousePoint.X - v.Point.X);
                float right =
                    Math.Abs(mousePoint.X - (v.Point.X + v.Size.Width));

                // Average these two to get the midpoint
                float average = (left + right) / 2;

                // Only make a different if we are with 64 of it
                if (average <= 64)
                {
                    float ratio = (64 - average) / 64;
                    size += ratio * 8;
                }

                v.BlockHeight = v.BlockWidth = size;

                // Update the new x coordinate
                v.Size = v.Extents.Size;
                x     += Padding + v.Size.Width;
            }

            // Anything left in the old list needs to be removed
            foreach (Prayer prayer in oldKeys)
            {
                // Get the viewport
                TopDownViewport ov = prayerViews[prayer];
                prayerViewport.Remove(ov);
                prayerViews.Remove(prayer);
            }
        }