Example #1
0
        public override void DrawSpecial(Microsoft.DirectX.Direct3D.Font font, RectangleF overlay_rect, Rectangle text_rect, Canvas canvas)
        {

            _overlay_rect = overlay_rect;
            _text_rect = text_rect;
            _progressbar_rect = text_rect;
            _border_rect = text_rect;

           

            if ((OwnerID == DDD_Global.Instance.PlayerID) && (DrawProgressBar))
            {

                _progressbar_rect.Y += text_rect.Height;
                _progressbar_rect.Height = _ProgressBarHeight_;
                _progressbar_rect.Width = _ProgressBarWidth_;
                _progressbar_rect.X += ((text_rect.Width - _progressbar_rect.Width) / 2);

                _border_rect.Height = _ProgressBarHeight_ + _text_rect.Height + 2;

                canvas.DrawFillRect(_border_rect, _textbox_color_material);

                DrawObjectID(canvas, font);
                canvas.DrawRect(_border_rect, BorderColor);

                if (FuelCapacity > 0)
                {
                    canvas.DrawProgressBar(_progressbar_rect,
                        progress_bar_background_material,
                        progress_bar_foreground_material,
                        FuelAmount / FuelCapacity);
                }
                else
                {
                    canvas.DrawProgressBar(_progressbar_rect,
                        progress_bar_background_material,
                        progress_bar_foreground_material,
                        0);
                }
            }
            else
            {
                if (DrawUnmanagedAssetLabel)
                {
                    DrawObjectID(canvas, font);
                    canvas.DrawRect(_border_rect, BorderColor);
                }

            }



            foreach (DDDObjects attacker in Attackers)
            {
                float _destinationX = attacker.SpriteArea.X + (attacker.SpriteArea.Width / 2);
                float _destinationY = attacker.SpriteArea.Y + (attacker.SpriteArea.Height / 2);
                canvas.DrawLine(Color.Red, 1,
                    SpriteArea.X + (SpriteArea.Width / 2),
                    SpriteArea.Y + (SpriteArea.Height / 2),
                    _destinationX,
                    _destinationY
                    );
                //engagment_rect.X = (int)(_destinationX - 3);
                //engagment_rect.Y = (int)(_destinationY - 3);
                //engagment_rect.Height = 6;
                //engagment_rect.Width = 6;
                //canvas.DrawFillRect(engagment_rect, red_material);
            }

            if (IsBeingAttacked)
            {
                engagment_rect = font.MeasureString(null, _engagementTimeStr, DrawTextFormat.Center | DrawTextFormat.VerticalCenter, Color.Red);
                engagment_rect.Width += 10;
                engagment_rect.X = (int)(_overlay_rect.X + (_overlay_rect.Width - engagment_rect.Width) / 2);
                engagment_rect.Y = (int)(_overlay_rect.Y + (_overlay_rect.Height - engagment_rect.Height) / 2);
                canvas.DrawFillRect(engagment_rect, black_material);
                canvas.DrawRect(engagment_rect, Color.Red);
                font.DrawText(null, _engagementTimeStr, engagment_rect, DrawTextFormat.Center | DrawTextFormat.VerticalCenter, Color.Red);
            }


            // Draw object "Tags"
            if (Tag != string.Empty && (DDD_Global.Instance.TagPosition != TagPositionEnum.INVISIBLE))
            {
                Rectangle tag_rect = font.MeasureString(null, Tag, DrawTextFormat.Center, Color.Black);

                switch (DDD_Global.Instance.TagPosition)
                {
                    case TagPositionEnum.ABOVE:
                        tag_rect.Y = (int)(overlay_rect.Y - tag_rect.Height);
                        tag_rect.X = (int)(overlay_rect.X + ((overlay_rect.Width - tag_rect.Width) * .5f));
                        break;
                    case TagPositionEnum.BELOW:
                        if (!DrawUnmanagedAssetLabel && (OwnerID != DDD_Global.Instance.PlayerID))
                        {
                            tag_rect.Y = (int)(overlay_rect.Bottom + 1);
                            tag_rect.X = (int)(overlay_rect.X + ((overlay_rect.Width - tag_rect.Width) * .5f));
                        }
                        else
                        {
                            tag_rect.Y = (int)(_border_rect.Bottom + 2);
                            tag_rect.X = (int)(overlay_rect.X + ((overlay_rect.Width - tag_rect.Width) * .5f));
                        }
                        break;
                    case TagPositionEnum.CENTER:
                        //tag_rect.Y = (int)(overlay_rect.Y + ((overlay_rect.Height - tag_rect.Height) * .5f));
                        tag_rect.Y = (int)(overlay_rect.Bottom - tag_rect.Height - 2);
                        tag_rect.X = (int)(overlay_rect.X + ((overlay_rect.Width - tag_rect.Width) * .5f));
                        break;
                }

                canvas.DrawFillRect(tag_rect, tag_material);
                font.DrawText(null, Tag, tag_rect, DrawTextFormat.VerticalCenter | DrawTextFormat.Center, Color.Black);
            }


        }