コード例 #1
0
ファイル: SplashScene.cs プロジェクト: wshanshan/DDD
 public override void OnRender(Canvas canvas)
 {
     font_small.DrawText(null, "Selected Item: " + Item, 300, 10, Color.Yellow);
     menu.OnRender(canvas);
     
     //base.OnRender(canvas);
 }
コード例 #2
0
ファイル: MapPlayfield.cs プロジェクト: wshanshan/DDD
        public MapPlayfield(Canvas canvas, Obj_Sprite map, Rectangle client_area, ICommand command)
        {
            ViewCamera = new Camera();
            Map = map;
            _pause = false;

            _client_area = client_area;
            Command = command;

            EnterMoveMode();
            MinimumScale();
        }
コード例 #3
0
ファイル: WindowManager.cs プロジェクト: wshanshan/DDD
        public void ScaleWindowManager(Canvas c, float Width, float Height)
        {
            _visible_rect.X = _visible_rect.Y = 0;
            _visible_rect.Height = (int)Height;
            _visible_rect.Width = (int)Width;
           
            foreach (Aptima.Asim.DDD.Client.Common.GLCore.Window w in WINDOWS)
            {
                w.FitToTextureDimensions(c, Width, Height);
            }
            foreach (Aptima.Asim.DDD.Client.Common.GLCore.Controls.Panel p in PANELS)
            {
                p.FitToTextureDimensions(c, Width, Height);
            }

        }
コード例 #4
0
        public override void OnRender(Canvas canvas)
        {
            if (!PauseRendering)
            {
                Rectangle PlayfieldRect = canvas.TargetControl.ClientRectangle;
                _playfield.ClientArea = PlayfieldRect;

                int bottom_left = (PlayfieldRect.Y + PlayfieldRect.Height);

                Rectangle SpriteRect = Rectangle.Empty;

                if (Map != null)
                {
                    SpriteRect = Map.ToRectangle();

                    // Prevent black from appearing on sides of map.
                    if (!SpriteRect.Contains(PlayfieldRect))
                    {
                        int right = (int)(Map.Position.X + (Map.TextureWidth * _playfield.Scale));
                        int bottom = (int)(Map.Position.Y + (Map.TextureHeight * _playfield.Scale));
                        if (right < PlayfieldRect.Width)
                        {
                            Pan(PlayfieldRect.Width - right, 0);
                        }
                        if (bottom < PlayfieldRect.Height)
                        {
                            Pan(0, PlayfieldRect.Height - bottom);
                        }
                        if (Map.Position.Y > PlayfieldRect.Y)
                        {
                            Pan(0, -(Map.Position.Y));
                        }
                        if (Map.Position.X > PlayfieldRect.X)
                        {
                            Pan(-(Map.Position.X), 0);
                        }
                    }
                }

                switch (MapScrollState)
                {
                    case MapPlayfieldScrollState.UP:
                        Pan(0, -10);
                        break;
                    case MapPlayfieldScrollState.DOWN:
                        Pan(0, 10);
                        break;
                    case MapPlayfieldScrollState.LEFT:
                        Pan(-10, 0);
                        break;
                    case MapPlayfieldScrollState.RIGHT:
                        Pan(10, 0);
                        break;
                }

                _playfield.OnRender(canvas);

                if (WBRoom != null)
                {
                    // Draw Whiteboard information from other selected rooms
                    List<string> otherWBNames = WBRoom.GetOtherWBRoomNames();
                    if (otherWBNames != null)
                    {
                        foreach (string otherWBName in otherWBNames)
                        {
                            DrawWhiteboardRoomObjects(WBRoom.GetOtherWBRoom(otherWBName), canvas);
                        }
                    }

                    // Draw Whiteboard information from current room
                    DrawWhiteboardRoomObjects(WBRoom, canvas);

                    // Draw any commands in progress
                    if ((WBRoom.DrawMode == DrawModes.Line) &&
                        (DrawDistanceLine == true) && (WhiteboardDrawing == true))
                    {
                        if ((WBRoom.DrawText != null) && (WBRoom.DrawText.Length > 0))
                        {
                            int lineTextSize = LineTextSize;

                            DrawShortenedLine(canvas, WBRoom.DrawColor, WBRoom.DrawPointSize, LineStartLocation.X, LineStartLocation.Y,
                                LineEndLocation.X, LineEndLocation.Y, 1f);

                            if (lineTextSize > MaxFontSize)
                            {
                                lineTextSize = MaxFontSize;
                            }
                            if (lineTextSize < 1)
                            {
                                lineTextSize = 1;
                            }
                            if (wbFonts[lineTextSize] == null)
                            {
                                wbFonts[lineTextSize] = canvas.CreateFont(new System.Drawing.Font("Arial", lineTextSize, FontStyle.Bold, GraphicsUnit.Pixel));
                            }
                            DrawCenteredText(wbFonts[lineTextSize], WBRoom.DrawText, LineEndLocation.X, LineEndLocation.Y, WBRoom.DrawColor);
                        }
                        else
                        {
                            canvas.DrawLine(WBRoom.DrawColor, WBRoom.DrawPointSize, LineStartLocation.X, LineStartLocation.Y,
                                LineEndLocation.X, LineEndLocation.Y);
                        }
                    }
                    else if ((WBRoom.DrawMode == DrawModes.Circle) &&
                        (DrawDistanceLine == true) && (WhiteboardDrawing == true))
                    {
                        canvas.DrawCircle(WBRoom.DrawColor, WBRoom.DrawPointSize, LineStartLocation.X, LineStartLocation.Y,
                            LineEndLocation.X, LineEndLocation.Y);
                    }
                    else if ((WBRoom.DrawMode == DrawModes.Arrow) &&
                        (DrawDistanceLine == true) && (WhiteboardDrawing == true))
                    {
                        canvas.DrawArrow(WBRoom.DrawColor, WBRoom.DrawPointSize, LineStartLocation.X, LineStartLocation.Y,
                            LineEndLocation.X, LineEndLocation.Y);
                    }
                    else if ((WBRoom.DrawMode == DrawModes.Text) &&
                        (DrawDistanceLine == true) && (WhiteboardDrawing == true))
                    {
                        if ((WBRoom.DrawText != null) && (WBRoom.DrawText.Length > 0))
                        {
                            int drawPointSize = WBRoom.DrawPointSize + 7;

                            if (drawPointSize > MaxFontSize)
                            {
                                drawPointSize = MaxFontSize;
                            }
                            if (wbFonts[drawPointSize] == null)
                            {
                                wbFonts[drawPointSize] = canvas.CreateFont(new System.Drawing.Font("Arial", drawPointSize, FontStyle.Bold, GraphicsUnit.Pixel));
                            }
                            DrawCenteredText(wbFonts[drawPointSize], WBRoom.DrawText, LineEndLocation.X, LineEndLocation.Y, WBRoom.DrawColor);
                        }
                    }
                    else if ((WBRoom.DrawMode == DrawModes.Selection) &&
                        (DrawDistanceLine == true) && (WhiteboardDrawing == true))
                    {
                        RectangleF selectionRect;

                        int selectionX = Math.Min(LineStartLocation.X, LineEndLocation.X);
                        int selectionY = Math.Min(LineStartLocation.Y, LineEndLocation.Y);

                        selectionRect = new RectangleF((float)selectionX, (float)selectionY,
                            (float)Math.Abs(LineStartLocation.X - LineEndLocation.X),
                            (float)Math.Abs(LineStartLocation.Y - LineEndLocation.Y));
                        canvas.DrawRect(selectionRect, Color.Orange);
                    }
                }

                // Draw Mini map
                _bottom_status_bar.Height = 35;
                _bottom_status_bar.Width = PlayfieldRect.Width;
                _bottom_status_bar.X = PlayfieldRect.X;
                _bottom_status_bar.Y = bottom_left - _bottom_status_bar.Height;
                canvas.DrawFillRect(_bottom_status_bar, _mini_map_background);
                
                if (true) //check DDD_Global or playfield
                {
                    if (_rangeFinderFont == null && this.Fonts.ContainsKey("RangeRing"))
                    {
                        _rangeFinderFont = this.Fonts["RangeRing"];
                    }
                    string rangeText = DDD_Global.Instance.GetRangeFinderDisplayString();

                    if (_rangeFinderFont != null && rangeText.Trim() != string.Empty)
                    {
                        _mouseoverRangeFinderDisplay = _rangeFinderFont.MeasureString(null, rangeText, DrawTextFormat.Center, Color.White);
                        _mouseoverRangeFinderDisplay.X = Convert.ToInt32(DDD_Global.Instance.RangeFinderXDisplay);// 500;
                        _mouseoverRangeFinderDisplay.Y = Convert.ToInt32(DDD_Global.Instance.RangeFinderYDisplay);// 400;
                        _mouseoverRangeFinderDisplay.Width += 10;
                        canvas.DrawFillRect(_mouseoverRangeFinderDisplay, _mini_map_background);//_rangeFinderMaterial);
                        _rangeFinderFont.DrawText(null, rangeText, _mouseoverRangeFinderDisplay, DrawTextFormat.Center, Color.White);

                        //DRAW LINE FROM OBJECT TO CURSOR

                        float objX = 0f;
                        float objY = 0f;
                        DDDObjects obj = _playfield.GetSelectedObject();
                        if (obj != null)
                        {
                            objX = obj.ScreenCoordinates.X;
                            objY = obj.ScreenCoordinates.Y;

                            canvas.DrawLine(Color.Black, 3, _mouseoverRangeFinderDisplay.X - 10, _mouseoverRangeFinderDisplay.Y - 15, objX, objY);
                        }
                    }
                }

                if (!MiniMapOverride)
                {
                    if ((!Map_IsContained_Horizontal(PlayfieldRect)) && (!Map_IsContained_Vertical(PlayfieldRect)))
                    {
                        ShowMiniMap = false;
                    }
                    else
                    {
                        ShowMiniMap = true;
                    }

                    if (WBRoom != null)
                    {
                        ShowMiniMap = true;
                    }
     
                    if (ShowMiniMap)
                    {
                        _mini_map.X = (PlayfieldRect.X + PlayfieldRect.Width) - _mini_map.Width;
                        _mini_map.Y = 0;
                        _mini_map.Height = (int)((Map.TextureHeight / Map.TextureWidth) * (float)_mini_map.Width);

                        _mini_map_thumb.X = (int)(-(Map.Position.X / (Map.TextureWidth * _playfield.Scale)) * (float)_mini_map.Width) + _mini_map.X;
                        _mini_map_thumb.Y = (int)(-(Map.Position.Y / (Map.TextureHeight * _playfield.Scale)) * (float)_mini_map.Height) + _mini_map.Y;
                        _mini_map_thumb.Width = (int)(_mini_map.Width * ((float)PlayfieldRect.Width / (Map.TextureWidth * _playfield.Scale)));
                        _mini_map_thumb.Height = (int)(_mini_map.Height * ((float)PlayfieldRect.Height / (Map.TextureHeight * _playfield.Scale)));

                        canvas.DrawFillRect(_mini_map, _mini_map_background);

                        // Draw rect for other users in a whiteboard room
                        if (wbRoom != null)
                        {
                            int originX = 0;
                            int originY = 0;
                            int screenSizeWidth = 0;
                            int screenSizeHeight = 0;
                            double screenZoom = 0.0;

                            foreach (string wbUser in wbRoom.MembershipList)
                            {
                                if (string.Compare(wbUser, DDD_Global.Instance.PlayerID) == 0)
                                {
                                    continue;
                                }

                                if (wbRoom.GetScreenViewInfo(wbUser, ref originX, ref originY, ref screenSizeWidth, ref screenSizeHeight,
                                        ref screenZoom))
                                {
                                    Rectangle userMiniMapRect = Rectangle.Empty;
                                    Vector2 _metersPerPixelValues = new Vector2();
                                    Vector2 userPosition = new Vector2();
                                    _metersPerPixelValues.X = UTM_Mapping.HorizonalMetersPerPixel;
                                    _metersPerPixelValues.Y = UTM_Mapping.VerticalMetersPerPixel;

                                    userPosition.X = (float) originX / _metersPerPixelValues.X;
                                    userPosition.Y = (float)originY  / _metersPerPixelValues.Y;
                                    userMiniMapRect.X = (int)((userPosition.X / (Map.TextureWidth)) * (float)_mini_map.Width) + _mini_map.X;
                                    userMiniMapRect.Y = (int)((userPosition.Y / (Map.TextureHeight)) * (float)_mini_map.Height) + _mini_map.Y;
                                    userMiniMapRect.Width = (int)((float)screenSizeWidth / _metersPerPixelValues.X /
                                        Map.TextureWidth * (float)_mini_map.Width);
                                    userMiniMapRect.Height = (int)((float)screenSizeHeight / _metersPerPixelValues.Y /
                                        Map.TextureHeight * (float)_mini_map.Height);

                                    // Draw rect for this a whiteboard user
                                    if (DMColorMap.ContainsKey(wbUser))
                                    {
                                        canvas.DrawRect(userMiniMapRect, Color.FromArgb(DMColorMap[wbUser]));
                                    }
                                    else
                                    {
                                        canvas.DrawRect(userMiniMapRect, Color.DarkBlue);
                                    }
                                }

                            }
                        }

                        // Draw rect for this user
                        if ((wbRoom != null) && DMColorMap.ContainsKey(DDD_Global.Instance.PlayerID))
                        {
                            canvas.DrawRect(_mini_map_thumb, Color.FromArgb(DMColorMap[DDD_Global.Instance.PlayerID]));
                        }
                        else
                        {
                            canvas.DrawRect(_mini_map_thumb, Color.Red);
                        }

                        lock (this)
                        {
                            DDDObjects selected = GetSelectedObject();
                            foreach (string obj_name in _playfield.PlayfieldObjects)
                            {
                                DDDObjects obj = (DDDObjects)_playfield.GetMappableObject(obj_name);
                                if (obj != null)
                                {
                                    _mini_map_track.X = (int)(((_mini_map.Width / Map.TextureWidth) * obj.Position.X) + _mini_map.X) - (int)(.5 * _mini_map_track.Width);
                                    _mini_map_track.Y = (int)(((_mini_map.Height / Map.TextureHeight) * obj.Position.Y) + _mini_map.Y) - (int)(.5 * _mini_map_track.Height);
                                    if (selected != null)
                                    {
                                        if ((selected.ID == obj.ID) && !ShowUnitColorOnMiniMap)
                                        {
                                            canvas.DrawTri(_mini_map_track, Color.Yellow, DIRECTION.UP);
                                            continue;
                                        }
                                    }

                                    if (!ShowUnitColorOnMiniMap)
                                    {
                                        canvas.DrawTri(_mini_map_track, Color.DodgerBlue, DIRECTION.UP);
                                    }
                                    else
                                    {
                                        canvas.DrawTri(_mini_map_track, obj.TextBoxColor, DIRECTION.UP);
                                    }

                                }
                            }


                            foreach (string obj_name in _playfield.PlayfieldObjects)
                            {
                                DDDObjects obj = (DDDObjects)_playfield.GetMappableObject(obj_name);
                                if (obj != null)
                                {
                                    _mini_map_track.X = (int)(((_mini_map.Width / Map.TextureWidth) * obj.Position.X) + _mini_map.X) - (int)(.5 * _mini_map_track.Width);
                                    _mini_map_track.Y = (int)(((_mini_map.Height / Map.TextureHeight) * obj.Position.Y) + _mini_map.Y) - (int)(.5 * _mini_map_track.Height);

                                    if (obj.IsBeingAttacked)
                                    {
                                        if (GameFramework.ElapsedSeconds(AnimationTimer, AnimationCycle))
                                        {
                                            AnimationTimer = GameFramework.QueryPerformanceTimer();
                                        }
                                        if (GameFramework.ElapsedSeconds(AnimationTimer, BlinkCycle))
                                        {
                                            canvas.DrawTri(_mini_map_track, Color.White, DIRECTION.UP);
                                            continue;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }



                if (ShowPosition)
                {

                    DDDObjects obj = _playfield.GetSelectedObject();
                    if (obj != null)
                    {
                        if (obj.IsPathCalculatorRunning())
                        {
                            canvas.DrawFillRect(_bottom_status_bar, _mini_map_background);
                            SizeF size = obj.DrawIcon(canvas, PlayfieldRect.X, _bottom_status_bar.Y, 30, 30);

                            int font_height = (Fonts["Arial8B"].MeasureString(null, obj.FullVelocityStr, DrawTextFormat.None, Color.White)).Height;

                            Fonts["Arial8B"].DrawText(null, obj.FullVelocityStr, PlayfieldRect.X + (int)size.Width + 2, _bottom_status_bar.Y, Color.White);
                            Fonts["Arial8B"].DrawText(null, obj.FullTTDStr, PlayfieldRect.X + (int)size.Width + 2, (_bottom_status_bar.Y + font_height), Color.White);
                            Fonts["Arial8B"].DrawText(null, obj.FullDestinationStr, PlayfieldRect.X + (int)size.Width + 2, (_bottom_status_bar.Y + (2 * font_height)), Color.White);
                        }
                        else
                        {
                            SizeF size = obj.DrawIcon(canvas, PlayfieldRect.X, _bottom_status_bar.Y, 30, 30);

                            int font_height = (Fonts["Arial10B"].MeasureString(null, obj.ObjectID, DrawTextFormat.None, Color.White)).Height;
                            Fonts["Arial10B"].DrawText(null, obj.ObjectID, PlayfieldRect.X + (int)size.Width, (_bottom_status_bar.Bottom - font_height), Color.White);
                        }
                    }
                }


                int width;
                String str = String.Empty;
                if (!IsPaused)
                {
                    if (DDD_Global.Instance.IsForkReplay)
                    {
                        str = String.Format("Fork Replay {0}", Time);
                    }
                    else
                    {
                        str = Time;
                    }
                }
                else
                {
                    str = "Paused";
                }
                width = (Fonts["Arial10B"].MeasureString(null, str, DrawTextFormat.None, Color.Yellow)).Width + 5;
                Fonts["Arial10B"].DrawText(null, str, _bottom_status_bar.X + (_bottom_status_bar.Width - width), _bottom_status_bar.Y + 5, Color.Yellow);
                //if (!IsPaused)
                //{
                //    if (DDD_Global.Instance.IsForkReplay)
                //    {
                //        width = (Fonts["Arial10B"].MeasureString(null, Time, DrawTextFormat.None, Color.Yellow)).Width + 5;
                //        Fonts["Arial10B"].DrawText(null, String.Format("Fork Replay {0}",Time), _bottom_status_bar.X + (_bottom_status_bar.Width - width), _bottom_status_bar.Y + 5, Color.Yellow);
                //    }
                //    else
                //    {
                //        width = (Fonts["Arial10B"].MeasureString(null, Time, DrawTextFormat.None, Color.Yellow)).Width + 5;
                //        Fonts["Arial10B"].DrawText(null, Time, _bottom_status_bar.X + (_bottom_status_bar.Width - width), _bottom_status_bar.Y + 5, Color.Yellow);
                //    }
                //}
                //else
                //{
                //    width = (Fonts["Arial10B"].MeasureString(null, Time, DrawTextFormat.None, Color.Yellow)).Width + 5;
                //    Fonts["Arial10B"].DrawText(null, "Paused", _bottom_status_bar.X + (_bottom_status_bar.Width - width), _bottom_status_bar.Y + 5, Color.Yellow);
                //}

            }

        }
コード例 #5
0
        public void DrawShortenedLine(Canvas canvas, int color, int pointSize,
            float x1, float y1, float x2, float y2, float scale)
        {
            float lineLength = (float) Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2));
            int shortenLineBy = (int) (ShortenLineBy * scale);

            if (lineLength < shortenLineBy)
            {
                canvas.DrawLine(color, pointSize, x1, y1, x2, y2);
            }
            else
            {
                float angle = (float) Math.Atan2(y2 - y1, x2 - x1);
                float newEndX = x1 + (lineLength - shortenLineBy) * (float)Math.Cos(angle);
                float newEndY = y1 + (lineLength - shortenLineBy) * (float)Math.Sin(angle);

                canvas.DrawLine(color, pointSize, x1, y1, newEndX, newEndY);
            }
        }
コード例 #6
0
ファイル: MappableObject.cs プロジェクト: wshanshan/DDD
 public void DrawSpecial(Canvas canvas, Microsoft.DirectX.Direct3D.Font font)
 {
     DrawSpecial(font, _overlay_rect, _text_rect, canvas);
 }
コード例 #7
0
ファイル: MappableObject.cs プロジェクト: wshanshan/DDD
 public SizeF DrawIcon(Canvas canvas, float x, float y, float width, float height)
 {
     _size = SizeF.Empty;
     if (_sprite != null)
     {
         float scale = 1;
         if (width > height)
         {
             scale = width / _sprite.TextureWidth;
         }
         else
         {
             scale = height / _sprite.TextureHeight;
         }
         _sprite.SetScale(scale, scale, 0);
         _size.Width = scale * _sprite.TextureWidth;
         _size.Height = scale * _sprite.TextureHeight;
         _sprite.DrawIcon(canvas, x, y);
     }
     return _size;
 }
コード例 #8
0
ファイル: MappableObject.cs プロジェクト: wshanshan/DDD
        public void DrawHeading(Canvas canvas)
        {
            if (IsPathCalculatorRunning())
            {
                Vector2 destination = ToScreenCoordinates(_destination.X, _destination.Y);

                float center_x = _overlay_rect.X + (_overlay_rect.Width / 2);
                float center_y = _overlay_rect.Y + (_overlay_rect.Height / 2);

                canvas.DrawLine(HeadingColor, 1, center_x, center_y, destination.X, destination.Y);
                _destination_area.X = destination.X - 3;
                _destination_area.Y = destination.Y - 3;
                _destination_area.Height = 6;
                _destination_area.Width = 6;
                canvas.DrawFillRect(this._destination_area, _heading_color_material);
            }
        }
コード例 #9
0
ファイル: MappableObject.cs プロジェクト: wshanshan/DDD
        //if color changes, or new ring radius is selected
        public void ModifyVulnerabilityRing(float vulnerabilityRadius, Color vulnerabilityColor, float h_metersPerPixel, float v_metersPerPixel, Canvas canvas)
        {
            bool hasChanged = false;
            if (_vulnerabilityRadius != vulnerabilityRadius)
            {
                _vulnerabilityRadius = vulnerabilityRadius;
                hasChanged = true;
            }
            if (_vulnerabilityColor.Name != vulnerabilityColor.Name)
            {
                _vulnerabilityColor = vulnerabilityColor;
                hasChanged = true;
            }

            if (hasChanged)
            {
                float height, width;
                int t_height, t_width;
                TransformMetersToPixels(vulnerabilityRadius, h_metersPerPixel, v_metersPerPixel, out width, out height);
                _vulnerabilityWidthPixels = width;
                _vulnerabilityHeightPixels = height;
                _vulnerabilityRing = new Obj_Sprite(SpriteFlags.AlphaBlend); //allows transparency
                _vulnerabilityRadius = vulnerabilityRadius;

                _vulnerabilityBitmap = new Bitmap(Convert.ToInt32(DefaultDisplayRadius), Convert.ToInt32(DefaultDisplayRadius));
                _vulnerabilityColor = vulnerabilityColor;
                _vulnerabilityBrush = new SolidBrush(_vulnerabilityColor);
                _vulnerabilityGraphic = Graphics.FromImage(_vulnerabilityBitmap);
                _vulnerabilityRing.Initialize(canvas);
                _vulnerabilityGraphic.FillEllipse(_vulnerabilityBrush, 0, 0, DefaultDisplayRadius, DefaultDisplayRadius); //just fill ellipse once, or else you get a solid color.
                _vulnerabilityTexture = canvas.CreateTexture(_vulnerabilityBitmap, out t_width, out t_height);
                _vulnerabilityRing.Texture(_vulnerabilityTexture, t_width, t_height);

            }

        }
コード例 #10
0
ファイル: MapScene.cs プロジェクト: wshanshan/DDD
 public void DrawActiveZones(Canvas c)
 {
     lock (this)
     {
         foreach (ActiveZone zone in _active_zones.Values)
         {
             if (zone.Visible)
             {
                 c.DrawShape(zone.Vertices, this.Scale, Map.Position.X, Map.Position.Y, true);
             }
         }
     }
 }
コード例 #11
0
ファイル: SplashScene2.cs プロジェクト: wshanshan/DDD
        public override void OnRender(Canvas canvas)
        {
            canvas.DrawFillRect(_background, _background_color_material);
            canvas.DrawRect(_background, Color.White);
            if (DDD_Global.Instance.IsConnected)
            {
                if (_loading_textures)
                {
                    //player_rect.Height = (font_small.MeasureString(null, DDD_Global.Instance.PlayerBrief, DrawTextFormat.WordBreak, Color.Yellow)).Height;
                    canvas.DrawFillRect(player_rect, _background_window_material);
                    font_small.DrawText(null, DDD_Global.Instance.PlayerBrief, player_rect, DrawTextFormat.WordBreak, Color.Yellow);
                    _continue_btn.SetClientArea(player_rect.Left,
                                                                             player_rect.Bottom + 2,
                                                                             player_rect.Right,
                                                                             player_rect.Bottom + 27);

                    _continue_btn.Text = "Start Game";
                }
                _continue_btn.OnRender(canvas);
            }

            font_small.DrawText(null, Program.Build_ID, 12, 12, Color.Yellow);
            font_large.DrawText(null, Message, bounding_rect, DrawTextFormat.None, MsgColor);

            base.OnRender(canvas);
        }
コード例 #12
0
ファイル: Window.cs プロジェクト: wshanshan/DDD
        public void OnRender(Canvas c)
        {
            if (State != WindowState.HIDE)
            {

                _shade_btn = _caption_bar;
                _shade_btn.Width = 12;
                _shade_btn.Height = 12;
                _shade_btn.X = _caption_bar.Right - 28;
                _shade_btn.Y += 7;

                _v_scroll_rect.X = _client_area.Right - ScrollWidth;
                _v_scroll_rect.Y = _caption_bar.Bottom;
                _v_scroll_rect.Height = _client_area.Height - (ScrollWidth + _caption_bar.Height);
                _v_scroll_rect.Width = ScrollWidth - 1;

                _h_scroll_rect.X = _client_area.X;
                _h_scroll_rect.Y = _client_area.Bottom - ScrollWidth;
                _h_scroll_rect.Width = _client_area.Width - ScrollWidth;
                _h_scroll_rect.Height = ScrollWidth - 1;

                _v_scroll_thumb = _v_scroll_rect;
                _h_scroll_thumb = _h_scroll_rect;


                c.DrawFillRect(_main_panel.ClientArea, _background_color_material);

                _main_panel.OnRender(c);

                if (HasScrollBars)
                {
                    if (this._ShowHorizontalScroll)
                    {
                        DrawHorizontalScroll(c);
                    }
                    if (this._ShowVerticalScroll)
                    {
                        DrawVerticalScroll(c);
                    }
                }

                c.DrawRect(_client_area, BorderColor);


                if (CaptionText != string.Empty)
                {
                    c.DrawFillRect(_caption_bar, _caption_color_material);
                    if (Font != null)
                    {
                        Font.DrawText(null, CaptionText, _caption_bar, DrawTextFormat.VerticalCenter | DrawTextFormat.Center, CaptionForeground);
                    }

                    if (AllowShade)
                    {
                        switch (State)
                        {
                            case WindowState.MINIMIZED:
                                c.DrawFillTri(_shade_btn, _caption_foreground_material, DIRECTION.UP);
                                c.DrawTri(_shade_btn, BorderColor, DIRECTION.UP);
                                break;
                            case WindowState.MAXIMIZED:
                                c.DrawFillTri(_shade_btn, _caption_foreground_material, DIRECTION.DOWN);
                                c.DrawTri(_shade_btn, BorderColor, DIRECTION.DOWN);
                                break;
                        }
                    }
                    
                    if (Selected)
                    {
                        c.DrawRect(_caption_bar, Color.White);
                    }
                    else
                    {
                        c.DrawRect(_caption_bar, BorderColor);
                    }
                }


                if (AllowResize)
                {
                    _resize_btn.X = _client_area.Right - 15;
                    _resize_btn.Y = _client_area.Bottom - 15;
                    _resize_btn.Width = 10;
                    _resize_btn.Height = 10;

                    c.DrawFillRect(_resize_btn, _caption_color_material);
                    c.DrawRect(_resize_btn, BorderColor);
                }


            }
        }
コード例 #13
0
ファイル: Window.cs プロジェクト: wshanshan/DDD
        private void DrawHorizontalScroll(Canvas c)
        {
            float pct = (float)this._h_scroll_rect.Width / (float)_control.DocumentWidth;

            _h_scroll_thumb = _h_scroll_rect;
            _h_scroll_thumb.Height -= 3;
            _h_scroll_thumb.Y += 2;
            if (pct < 1)
            {
                _h_scroll_thumb.Width = pct * _h_scroll_rect.Width;
                _h_scroll_thumb.X += _control.DocumentPositionX * pct;
            }
            if (_h_scroll_thumb.Right < _h_scroll_rect.Right)
            {
                CanHScroll = true;
            }
            else
            {
                CanHScroll = false;
                _h_scroll_thumb.Width = _h_scroll_rect.Right - _h_scroll_thumb.Left;
            }

            // Scrollbar background
            c.DrawFillRect(_h_scroll_rect, _scroll_background_material);

            // Scrollbar thumb
            c.DrawFillRect(_h_scroll_thumb, _scroll_color_material);
            c.DrawRect(_h_scroll_rect, BorderColor);

        }
コード例 #14
0
ファイル: Window.cs プロジェクト: wshanshan/DDD
        private void DrawVerticalScroll(Canvas c)
        {
            float pct = (float)this._v_scroll_rect.Height / (float) _control.DocumentHeight;

            _v_scroll_thumb = _v_scroll_rect;
            _v_scroll_thumb.Width -= 3;
            _v_scroll_thumb.X += 2;
            if (pct < 1)
            {
                _v_scroll_thumb.Height = pct * _v_scroll_rect.Height;
                _v_scroll_thumb.Y += Math.Abs(_control.DocumentPositionY) * pct;
            }


            if (_v_scroll_thumb.Bottom <= _v_scroll_rect.Bottom)
            {
                CanVScroll = true;
            }
            else
            {
                CanVScroll = false;
                _v_scroll_thumb.Height = _v_scroll_rect.Bottom - _v_scroll_thumb.Top;
            }

            // Scrollbar background
            c.DrawFillRect(_v_scroll_rect, _scroll_background_material);

            // Scrollbar thumb
            c.DrawFillRect(_v_scroll_thumb, _scroll_color_material);
            c.DrawRect(_v_scroll_rect, BorderColor);

        }
コード例 #15
0
ファイル: Window.cs プロジェクト: wshanshan/DDD
 public void FitToTextureDimensions(Canvas c, float TextureWidth, float TextureHeight)
 {
     _main_panel.FitToTextureDimensions(c, TextureWidth, TextureHeight);
 }
コード例 #16
0
ファイル: WindowManager.cs プロジェクト: wshanshan/DDD
        public override void OnRender(Canvas canvas)
        {

            foreach (Aptima.Asim.DDD.Client.Common.GLCore.Controls.Panel p in PANELS)
            {
                p.OnRender(canvas);
            }

            foreach (Aptima.Asim.DDD.Client.Common.GLCore.Window w in WINDOWS)
            {
                w.OnRender(canvas);
            }

        }
コード例 #17
0
ファイル: MappableObject.cs プロジェクト: wshanshan/DDD
        public void SetVulnerabilityRingValues(float vulnerabilityRadius, Color ringColor, Canvas canvas, float h_metersPerPixel, float v_metersPerPixel)
        {
            float height, width;
            int t_height, t_width;
            try
            {
                TransformMetersToPixels(vulnerabilityRadius, h_metersPerPixel, v_metersPerPixel, out width, out height);
                _vulnerabilityWidthPixels = width;
                _vulnerabilityHeightPixels = height;
                _vulnerabilityRing = new Obj_Sprite(SpriteFlags.AlphaBlend); //allows transparency
                _vulnerabilityRadius = vulnerabilityRadius;

                _vulnerabilityBitmap = new Bitmap(Convert.ToInt32(DefaultDisplayRadius), Convert.ToInt32(DefaultDisplayRadius));
                _vulnerabilityColor = ringColor; //Color.FromArgb(33, 0, 255, 0);
                _vulnerabilityBrush = new SolidBrush(_vulnerabilityColor);
                _vulnerabilityGraphic = Graphics.FromImage(_vulnerabilityBitmap);
                _vulnerabilityRing.Initialize(canvas);
                _vulnerabilityGraphic.FillEllipse(_vulnerabilityBrush, 0, 0, DefaultDisplayRadius, DefaultDisplayRadius); //just fill ellipse once, or else you get a solid color.
                _vulnerabilityTexture = canvas.CreateTexture(_vulnerabilityBitmap, out t_width, out t_height);
                _vulnerabilityRing.Texture(_vulnerabilityTexture, t_width, t_height);

            }
            catch (Exception e)
            {
                Console.WriteLine("Error Setting Vulnerability Ring Value: {0};\r\n{1}", e.Message, e.StackTrace);
            }
        }
コード例 #18
0
ファイル: MapObjects.cs プロジェクト: wshanshan/DDD
        private void DrawRangeRing(int color, float radius, float origin_x, float origin_y, float origin_z, int numberOfVertices, Canvas canvas, float h_metersPerPixel, float v_metersPerPixel)
        {
            //if (!IsSensorRingSet())
            //{
            //    SetSensorRingValues(5000, Color.Green, 33, canvas, h_metersPerPixel, v_metersPerPixel);
            //}

            DrawSensorRangeRing(origin_x, origin_y, origin_z, canvas);

            /*
            //Sprite sp_ring = canvas.CreateSprite();
            Obj_Sprite ring = new Obj_Sprite(SpriteFlags.None);
            ring.Initialize(canvas);
            Bitmap b = new Bitmap(Convert.ToInt32(radius), Convert.ToInt32(radius));
            / *
            List<Point> points = new List<Point>();
            points.Add(new Point(0,0));
            points.Add(new Point(25,0));
            points.Add(new Point(50,0));
            points.Add(new Point(75,0));
            points.Add(new Point(100,0));

            Brush brush = new System.Drawing.Drawing2D.PathGradientBrush(points.ToArray()); //((Point[]){new Point(0,0), new Point(25, 0), new Point(50,0), new Point(75,0), new Point(100,0)});
             * /
            Color semiTransRed = Color.FromArgb(33, 255, 0, 0);
            //semiTransRed.A = 100;
            Brush brush = new System.Drawing.SolidBrush(semiTransRed);
            
            Graphics g = Graphics.FromImage(b);
            int width, height;
            //SizeF ringSize = SizeF.Empty;
            float scale = 1;
            //scale logic
    //g.
            g.FillEllipse(brush, 0, 0, 100, 100);
            
            ring.Texture(canvas.CreateTexture(b, out width, out height), Convert.ToInt32(radius), Convert.ToInt32(radius));

            ring.SetScale(scale, scale, 0);
            //ringSize.Width = ring.TextureWidth * scale;
            //ringSize.Height = ring.TextureHeight * scale;
            //ring.Draw(canvas);
            ring.Flags = SpriteFlags.AlphaBlend;
            ring.DrawIcon(canvas, origin_x, origin_y);
            
            //sp_ring.Draw2D(
             */
            return;


            //AD: This could have performance issues.  Might explore saving list of vertices in memory once and retrieving them when drawing.
            List<CustomVertex.TransformedColored> vertexList = new List<CustomVertex.TransformedColored>();
            for (int x = 0; x <= 360; x += (360/numberOfVertices))
            {
                vertexList.Add(new CustomVertex.TransformedColored((float)Math.Cos(DegreeToRadian(x)) * radius, (float)Math.Sin(DegreeToRadian(x)) * radius + 50, 0, 1, color));
            }
            //AD: If you don't convert degree to radian, then you get cool spirograph-like shapes.
            canvas.DrawShape(vertexList, Scale, origin_x, origin_y, true);
        }
コード例 #19
0
ファイル: MappableObject.cs プロジェクト: wshanshan/DDD
        public void DrawVulnerabilityRangeRing(float xpos, float ypos, float zpos, Canvas canvas)
        {
            float height = _vulnerabilityRing.TextureHeight;
            float width = _vulnerabilityRing.TextureWidth;
            float modifiedScale = GetRatioScale(_vulnerabilityWidthPixels, Scale);

            _vulnerabilityRing.SetScale(modifiedScale, modifiedScale, 0);

            xpos -= ((width / 2) * modifiedScale);
            ypos -= (((height / 2)) * modifiedScale) - (45 * Scale);

            _vulnerabilityRing.DrawIcon(canvas, xpos, ypos);

        }
コード例 #20
0
ファイル: MapObjects.cs プロジェクト: wshanshan/DDD
        public void DrawRangeRings(Canvas canvas)
        { 
             /* RANGE RING LOGIC */
            float xpos = (SpriteArea.X + (SpriteArea.Width / 2));
            float ypos = (SpriteArea.Y + (SpriteArea.Height / 2) - (Scale * 50)); 
            float zpos = 0.0F;
            
            if (CurrentlySelectedSensor != string.Empty && CurrentlySelectedSensorRange > 0)
            {
                if (!IsSensorRingSet())
                {
                    SetSensorRingValues(CurrentlySelectedSensorRange, Color.FromArgb(DDD_RangeRings.GetInstance().SensorRangeRings.OpaqueRingColor), canvas, UTM_Mapping.HorizonalMetersPerPixel, UTM_Mapping.VerticalMetersPerPixel);
                }
                DrawSensorRangeRing(xpos, ypos, zpos, canvas);
            }
            if (CurrentlySelectedCapability != string.Empty && CurrentlySelectedCapabilityRange > 0)
            {
                if (!IsCapabilityRingSet())
                {
                    SetCapabilityRingValues(CurrentlySelectedCapabilityRange, Color.FromArgb(DDD_RangeRings.GetInstance().CapabilityRangeRings.OpaqueRingColor), canvas, UTM_Mapping.HorizonalMetersPerPixel, UTM_Mapping.VerticalMetersPerPixel);
                }
                DrawCapabilityRangeRing(xpos, ypos, zpos, canvas);
            }

            if (CurrentlySelectedVulnerability != string.Empty && CurrentlySelectedVulnerabilityRange > 0)
            {
                if (!IsVulnerabilityRingSet())
                {
                    SetVulnerabilityRingValues(CurrentlySelectedVulnerabilityRange, Color.FromArgb(DDD_RangeRings.GetInstance().VulnerabilityRangeRings.OpaqueRingColor), canvas, UTM_Mapping.HorizonalMetersPerPixel, UTM_Mapping.VerticalMetersPerPixel);
                }
                DrawVulnerabilityRangeRing(xpos, ypos, zpos, canvas);
            }

            /*       END        */
        }
コード例 #21
0
ファイル: MappableObject.cs プロジェクト: wshanshan/DDD
 public void DrawObjectID(Canvas canvas, Microsoft.DirectX.Direct3D.Font font)
 {
     if (ID != string.Empty)
     {
         _text_rect = font.MeasureString(null, ID, DrawTextFormat.Center, TextColor);
         _text_rect.X = (SpriteArea.X + ((SpriteArea.Width - _text_rect.Width) / 2)) - 5;
         _text_rect.Y = SpriteArea.Bottom;
         _text_rect.Width += 10;
         canvas.DrawFillRect(_text_rect, _textbox_color_material);
    
         font.DrawText(null, ID, _text_rect, DrawTextFormat.Center, TextColor);
     }
 }
コード例 #22
0
ファイル: MapObjects.cs プロジェクト: wshanshan/DDD
        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);
            }


        }
コード例 #23
0
ファイル: MappableObject.cs プロジェクト: wshanshan/DDD
        public void Draw(Canvas canvas, Microsoft.DirectX.Direct3D.Font font)
        {
            if (_sprite != null)
            {
                if (!Hide)
                {

                    if (IsPathCalculatorRunning())
                    {
                        CalculateNewPosition();
                    }
                    else
                    {
                        PositionUpdate();
                    }

                    Vector2 screen = ToScreenCoordinates(_position.X, _position.Y);


                    _sprite.Diffuse = DiffuseColor;
                    if (Scale <= MinScale)
                    {
                        _sprite.SetScale(MinScale, MinScale, 0);
                    }
                    else
                    {
                        _sprite.SetScale(Scale, Scale, 0);
                    }

                    if (DrawWithRotation)
                    {
                        _sprite.SetRotation(_path_calculator.AngleOfAttack, _path_calculator.AngleOfAttack, _path_calculator.AngleOfAttack);
                    }
                    _sprite.SetPosition(screen.X, screen.Y, 0);
                    _sprite_area = _sprite.ToRectangleF();

                    _sprite.Draw(canvas);

                    // *** Overlay Controls and Display *** 
                    _overlay_rect = SpriteAreaF;

                }
            }

        }
コード例 #24
0
ファイル: Scene.cs プロジェクト: wshanshan/DDD
 public virtual void OnRender(Canvas canvas)
 {
 }
コード例 #25
0
ファイル: MappableObject.cs プロジェクト: wshanshan/DDD
 public virtual void DrawSpecial(Microsoft.DirectX.Direct3D.Font font, RectangleF overlay_rect, Rectangle text_rect, Canvas canvas)
 {
 }
コード例 #26
0
ファイル: MapPlayfieldRender.cs プロジェクト: wshanshan/DDD
        public override void OnRender(Canvas canvas)
        {

            if (Map != null)
            {
                Map.Draw(canvas);
            }

            DrawActiveZones(canvas);

            DDDObjects.Scale = Scale;
            if (!ScaleUnitWithMap)
            {
                DDDObjects.MinScale = 1;
            }
            else
            {
                DDDObjects.MinScale = .5f;
            }

            DDDObjects.MapPosition(Map.Position.X, Map.Position.Y);


            lock (this)
            {
                DDDObjects selected_target = GetSelectedTarget();
                DDDObjects selected_asset = GetSelectedObject();

                //draw range rings
                foreach (string obj_name in OrderedPlayfieldObjects)
                {
                    DDDObjects obj = (DDDObjects)GetMappableObject(obj_name);
                    if (obj != null)
                    {
                        obj.DrawRangeRings(canvas);
                    }
                }

                foreach (string obj_name in OrderedPlayfieldObjects)
                {
                    DDDObjects obj = (DDDObjects)GetMappableObject(obj_name);
                    if (obj != null)
                    {
                        if (obj == selected_asset)
                        { //display mouseover info

                            float xpos = UTM_Mapping.HorizontalPixelsToMeters((obj.ScreenCoordinates.X - Map.Position.X) / Scale);
                            float ypos = UTM_Mapping.VerticalPixelsToMeters((obj.ScreenCoordinates.Y - Map.Position.Y ) / Scale);
                            //float xpos = UTM_Mapping.HorizontalPixelsToMeters((obj.ScreenCoordinates.X + (obj.SpriteArea.Width / 2)) - Map.Position.X);
                            //float ypos = UTM_Mapping.VerticalPixelsToMeters((obj.ScreenCoordinates.Y + (obj.SpriteArea.Height / 2) - (Scale * 50)) - Map.Position.Y);

                            //Console.WriteLine("x: {0}; y: {1}", xpos, ypos);
                           // Console.WriteLine("x: {0}; y: {1}", xpos, ypos + (obj.SpriteArea.Height / 2) / Scale);

                            DDD_Global.Instance.SetRangeFinderDistance(xpos, ypos);
                            //get distance string 
                            string distanceFromSelected = DDD_Global.Instance.RangeFinderDistanceString;
                            int distance = -1;
                            int intensity = -1;
                            if (distanceFromSelected.Trim() != "")
                            {
                                distance = (int)Math.Round(Convert.ToDouble(distanceFromSelected));
                                intensity = obj.GetCapabilityRangeRingIntensity(obj.CurrentlySelectedCapability, true, distance);
                                if (intensity > 0)
                                {
                                    DDD_Global.Instance.RangeFinderIntensityString = String.Format("{0}", intensity);
                                }
                                else
                                {
                                    DDD_Global.Instance.RangeFinderIntensityString = string.Empty;
                                }
                            }
                            //check if a capability is selected, if so get ranges, and then use disance to calculate intensity.
                        }

                       // obj.DrawRangeRings(canvas); //moved above
                        obj.DrawUnmanagedAssetLabel = DrawUnmanagedAssetLabels;
                        obj.SetDiffuseColor();
                        if (obj.IsPathCalculatorRunning())
                        {
                            if (!obj.IsWeapon)
                            {
                                obj.HeadingColor = Color.DodgerBlue;
                            }
                            else
                            {
                                obj.HeadingColor = Color.Red;
                            }
                            obj.DrawHeading(canvas);
                        }
                        if ((obj != selected_asset) && (obj != selected_target))
                        {
                            obj.TextColor = Color.White;
                            obj.BorderColor = Color.Black;
                            obj.Draw(canvas, Fonts["Small"]);
                            obj.DrawSpecial(canvas, Fonts["Small"]);
                        }
                    }

                }


                //Render selected objects last.
                if (selected_target != null)
                {
                    //selected_asset.DiffuseColor = Color.Yellow;
                    selected_target.TextColor = Color.Yellow;
                    selected_target.BorderColor = Color.Yellow;
                    selected_target.Draw(canvas, Fonts["Small"]);
                    selected_target.DrawSpecial(canvas, Fonts["Small"]);
                }
                if (selected_asset != null)
                {
                    //selected_asset.DiffuseColor = Color.Yellow;
                    selected_asset.TextColor = Color.Yellow;
                    selected_asset.BorderColor = Color.Yellow;
                    selected_asset.Draw(canvas, Fonts["Small"]);
                    selected_asset.DrawSpecial(canvas, Fonts["Small"]);
                }

            }



            if (DrawDistanceLine)
            {
                canvas.DrawLine(Color.Lime, 1, LineStartLocation.X, LineStartLocation.Y, LineEndLocation.X, LineEndLocation.Y);
                double distance = Math.Sqrt(Math.Pow((LineEndLocation.X - LineStartLocation.X), 2) + Math.Pow((LineEndLocation.Y - LineStartLocation.Y), 2));
                Fonts["Small"].DrawText(null, 
                    string.Format("{0} m", Math.Round(UTM_Mapping.HorizontalPixelsToMeters((float)(distance/Scale)))), 
                    LineEndLocation.X+12, LineEndLocation.Y - 12, Color.Lime);
            }

        }
コード例 #27
0
        public void DrawWhiteboardRoomObjects(WhiteboardRoom wbRoom, Canvas canvas)
        {
            if (wbRoom == null)
            {
                return;
            }

            // Draw all whiteboard commands
            Array drawingCommands = wbRoom.GetCurrentDrawingCommands();

            foreach (object obj in drawingCommands)
            {
                if (obj is LineObject)
                {
                    LineObject line = (LineObject)obj;
                    LocationValue start = new LocationValue();
                    LocationValue end = new LocationValue();
                    int drawPointSize = (int)(line.Width * _playfield.Scale);

                    if ((drawPointSize == 0) && (line.Width > 0))
                    {
                        drawPointSize = 1;
                    }

                    if ((line.Mode == DrawModes.Line) || (line.Mode == DrawModes.Circle) ||
                        (line.Mode == DrawModes.Arrow))
                    {
                        start.X = line.Start.X * _playfield.Scale + Map.Position.X;
                        start.Y = line.Start.Y * _playfield.Scale + Map.Position.Y;

                        end.X = line.End.X * _playfield.Scale + Map.Position.X;
                        end.Y = line.End.Y * _playfield.Scale + Map.Position.Y;

                        if (line.Mode == DrawModes.Line)
                        {
                            if ((line.Text != null) && (line.Text.Length > 0))
                            {
                                int lineTextSize = (int) ((LineTextSize / line.OriginalScale) * _playfield.Scale);

                                DrawShortenedLine(canvas, line.Color, drawPointSize, (float)start.X, (float)start.Y,
                                    (float)end.X, (float)end.Y, (float) (_playfield.Scale / line.OriginalScale));

                                if (lineTextSize > MaxFontSize)
                                {
                                    lineTextSize = MaxFontSize;
                                }
                                if (lineTextSize < 1)
                                {
                                    lineTextSize = 1;
                                }
                                if (wbFonts[lineTextSize] == null)
                                {
                                    wbFonts[lineTextSize] = canvas.CreateFont(new System.Drawing.Font("Arial", lineTextSize, FontStyle.Bold, GraphicsUnit.Pixel));
                                }
                                DrawCenteredText(wbFonts[lineTextSize], line.Text, (int)end.X, (int)end.Y, line.Color);
                            }
                            else
                            {
                                canvas.DrawLine(line.Color, drawPointSize, (float)start.X, (float)start.Y,
                                    (float)end.X, (float)end.Y);
                            }
                        }
                        else if (line.Mode == DrawModes.Circle)
                        {
                            canvas.DrawCircle(line.Color, drawPointSize, (float)start.X, (float)start.Y,
                                (float)end.X, (float)end.Y);
                        }
                        else if (line.Mode == DrawModes.Arrow)
                        {
                            canvas.DrawArrow(line.Color, drawPointSize, (float)start.X, (float)start.Y,
                                (float)end.X, (float)end.Y);
                        }
                    }
                    else if ((line.Mode == DrawModes.Text) && (line.Text != null) &&
                        (line.Text.Length > 0))
                    {
                        start.X = line.Start.X * _playfield.Scale + Map.Position.X;
                        start.Y = line.Start.Y * _playfield.Scale + Map.Position.Y;

                        if (drawPointSize > MaxFontSize)
                        {
                            drawPointSize = MaxFontSize;
                        }
                        if (wbFonts[drawPointSize] == null)
                        {
                            wbFonts[drawPointSize] = canvas.CreateFont(new System.Drawing.Font("Arial", drawPointSize, FontStyle.Bold, GraphicsUnit.Pixel));
                        }
                        DrawCenteredText(wbFonts[drawPointSize], line.Text, (int)start.X, (int)start.Y, line.Color);

                        // Update the bounding box if needed
                        if ((line.BoundingPolygon == null) || (wbRoom == WBRoom))
                        {
                            RectangleF textRect;
                            Polygon textPoly;
                            float width;
                            float height;
                            PointF boundStart = new PointF();

                            textRect = wbFonts[drawPointSize].MeasureString(null, line.Text, DrawTextFormat.None, line.Color);

                            width = textRect.Right / _playfield.Scale;
                            if ((width * line.OriginalScale) < 5)
                            {
                                width = 5 / (float) line.OriginalScale;
                            }
                            height = textRect.Bottom / _playfield.Scale;
                            if ((height * line.OriginalScale) < 5)
                            {
                                height = 5 / (float) line.OriginalScale;
                            }
                            boundStart.X = (float)line.Start.X - (width / 2);
                            boundStart.Y = (float)line.Start.Y - (height / 2);

                            textPoly = new Polygon();
                            textPoly.Points.Add(new Vector(boundStart.X, boundStart.Y));
                            textPoly.Points.Add(new Vector(boundStart.X + width, boundStart.Y));
                            textPoly.Points.Add(new Vector(boundStart.X + width, boundStart.Y + height));
                            textPoly.Points.Add(new Vector(boundStart.X, boundStart.Y + height));
                            textPoly.Offset(0, 0);
                            textPoly.BuildEdges();

                            line.BoundingPolygon = textPoly;
                        }
                    }

                    // Draw Bounding rectable if object is selected
                    if ((line.ObjectSelected) && (line.BoundingPolygon != null) && (line.BoundingPolygon.Points.Count >= 2))
                    {
                        LocationValue boundStart = new LocationValue();
                        LocationValue boundEnd = new LocationValue();
                        Vector prevPoint = line.BoundingPolygon.Points[line.BoundingPolygon.Points.Count - 1]; 
                        foreach (Vector curPoint in line.BoundingPolygon.Points)
                        {
                            boundStart.X = prevPoint.X * _playfield.Scale + Map.Position.X;
                            boundStart.Y = prevPoint.Y * _playfield.Scale + Map.Position.Y;

                            boundEnd.X = curPoint.X * _playfield.Scale + Map.Position.X;
                            boundEnd.Y = curPoint.Y * _playfield.Scale + Map.Position.Y;

                            canvas.DrawLine(Color.Black.ToArgb(), 1, (float)boundStart.X, (float)boundStart.Y,
                                (float)boundEnd.X, (float)boundEnd.Y);

                            prevPoint = curPoint;
                        }
                    }
                }
            }
        }
コード例 #28
0
ファイル: GameFramework.cs プロジェクト: wshanshan/DDD
        /// <summary>
        /// Starts the Game Framework, registers a form and a gamecontroller.
        /// The form is required to intercept keyboard and mouse input.
        /// The GameController initializes scenes and feeds them to the GameController.
        /// </summary>
        /// <param name="form"></param>
        /// <param name="game_control"></param>
        public void Run(Form form, IGameControl game_control)
        {
            if (form == null)
            {
                throw new ApplicationException("Must supply a windows Form.");
            }
            _main_window = form;
            if (game_control == null)
            {
                throw new ApplicationException("Game Control is uninitialized.");
            }
            _CANVAS_ = new Canvas();
            QueryPerformanceFrequency(ref _ticks_per_second);

            _game_control = game_control;
            _CANVAS_.TargetControl = _game_control.GetTargetControl();

            _game_control.InitializeCanvasOptions(_CANVAS_.Options);
            _CANVAS_.InitializeCanvas();

            _AvailableScenes_ = _game_control.InitializeScenes(this);
            _AvailableScenes_[CURRENT_SCENE].Initialize(this);
            _game_control.SceneChanged(CURRENT_SCENE);

            Idle = new EventHandler(GameLoop);
            Application.Idle += Idle;

        }
コード例 #29
0
ファイル: WinForm_Splash.cs プロジェクト: wshanshan/DDD
        public override void OnRender(Canvas canvas)
        {
            _background.X = 0;
            _background.Y = 0;
            _background.Width = canvas.Size.Width;
            _background.Height = canvas.Size.Height;

            bounding_rect = font_large.MeasureString(null, Message, DrawTextFormat.NoClip, Color.Yellow);
            bounding_rect.X = (_background.Width - bounding_rect.Width) / 2;
            bounding_rect.Y = (int)(_background.Height - (2 * bounding_rect.Height));

            canvas.DrawFillRect(_background, _background_color_material);
            canvas.DrawRect(_background, Color.White);

            font_large.DrawText(null, Message, bounding_rect, DrawTextFormat.None, MsgColor);

            base.OnRender(canvas);
        }
コード例 #30
0
ファイル: HeadsUpDisplay.cs プロジェクト: wshanshan/DDD
        public override void OnRender(Canvas canvas)
        {
            Rectangle PlayfieldRect = PlayfieldPanel.ClientArea;
            Rectangle SpriteRect = Rectangle.Empty;
            if (Map != null)
            {
                SpriteRect = Map.ToRectangle();
            }

            switch (SCROLL)
            {
                case ScrollState.LEFT:
                    SpriteRect.X = (int)(SpriteRect.X + 10);
                    if (SpriteRect.Contains(PlayfieldRect))
                    {
                        MapScene.Pan(10, 0);
                    }
                    break;
                case ScrollState.RIGHT:
                    SpriteRect.X = (int)(SpriteRect.X - 10);
                    if (SpriteRect.Contains(PlayfieldRect))
                    {
                        MapScene.Pan(-10, 0);
                    }
                    break;
                case ScrollState.UP:
                    SpriteRect.Y = (int)(SpriteRect.Y + 10);
                    if (SpriteRect.Contains(PlayfieldRect))
                    {
                        MapScene.Pan(0, 10);
                    }
                    break;
                case ScrollState.DOWN:
                    SpriteRect.Y = (int)(SpriteRect.Y - 10);
                    if (SpriteRect.Contains(PlayfieldRect))
                    {
                        MapScene.Pan(0, -10);
                    }
                    break;
            }


            canvas.DrawFillRect(background, background_material);
            canvas.DrawFillRect(frame, frame_color_material);
            canvas.DrawRect(frame, border_color);
            canvas.DrawRect(PlayfieldPanel.ClientArea, Color.Green);
            canvas.DrawFillRect(score, score_color_material);
            canvas.DrawFillRect(information_rect, score_color_material);
            
            canvas.DrawFillTri(left_arrow, background_material, DIRECTION.LEFT);
            canvas.DrawFillTri(right_arrow, background_material, DIRECTION.RIGHT);
            canvas.DrawFillTri(up_arrow, background_material, DIRECTION.UP);
            canvas.DrawFillTri(down_arrow, background_material, DIRECTION.DOWN);

            if (MapScene.SelectionCount() == 0)
            {
                Mode = MenuMode.DEFAULT;
            }
            switch (Mode)
            {
                case MenuMode.DEFAULT:
                    DrawMoveMode(canvas);
                    break;
                case MenuMode.ATTACK:
                    DrawAttackMode(canvas);
                    break;
                case MenuMode.SUBPLATFORM:
                    DrawSubPMode(canvas);
                    break;
            }

            Fonts["Large"].DrawText(null, ScoreHeader, score, DrawTextFormat.VerticalCenter, Color.Yellow);
            if (!IsPaused)
            {
                Fonts["Large"].DrawText(null, Time, time_rect, DrawTextFormat.VerticalCenter, Color.Yellow);
            }
            else
            {
                Fonts["Large"].DrawText(null, "Paused", time_rect, DrawTextFormat.VerticalCenter, Color.Yellow);
            }


            base.OnRender(canvas);

        }