Ejemplo n.º 1
0
        public void Draw()
        {
            if ((_isShiftPressed || _isCtrlPressed) && _myClipboard.Count > 0)
            {
                double opacity = GetPastingBallsOpacity();

                if (opacity > 0d)
                {
                    #region Draw Pasting Balls

                    Ball tempBall = null;

                    foreach (BallBlip blip in _myClipboard)
                    {
                        // Clone the ball
                        tempBall = blip.Ball.CloneBall();

                        // Figure out where to place the pasted object
                        MyVector newPosition = tempBall.Position - _clipboardPositionCenter;
                        newPosition.Add(_curMousePoint);
                        tempBall.Position.StoreNewValues(newPosition);

                        // Draw it
                        if (tempBall is SolidBall)
                        {
                            _renderer.DrawSolidBall((SolidBall)tempBall, ObjectRenderer.DrawMode.Building, blip.CollisionStyle, false, opacity);
                        }
                        else
                        {
                            _renderer.DrawBall(tempBall, ObjectRenderer.DrawMode.Building, blip.CollisionStyle, false, opacity);
                        }
                    }

                    #endregion
                }
            }

            if (_isMouseDown == MouseButtonDown.Left && _mode == SelectionMode.Rectangle)
            {
                #region Draw Rectangle

                MyVector topLeft, bottomRight;
                GetProperCorners(out topLeft, out bottomRight, _mouseDownPoint, _curMousePoint);

                _picturebox.DrawRectangle(Color.Silver, DashStyle.Dash, 1d, topLeft, bottomRight);

                #endregion
            }
            else if (_isMouseDown == MouseButtonDown.Right)
            {
                // Draw Velocity
                _picturebox.DrawLine(Color.Chartreuse, 12d, _mouseDownPoint, _curMousePoint);
            }

            //TODO:  draw the angular velocity
        }
Ejemplo n.º 2
0
        public void Draw()
        {
            if (!(_active && _cursorInMap))
            {
                return;
            }

            if (_accelLines.Count > 0)
            {
                for (int lineCntr = 0; lineCntr < _accelLines.Count; lineCntr++)
                {
                    _picturebox.DrawLine(_accelColors[lineCntr], 1, _curMousePoint, _accelLines[lineCntr].Position);
                }
            }

            _picturebox.DrawCircle(Color.Silver, 15, _curMousePoint, _cursorBlip.Ball.Radius);
        }
Ejemplo n.º 3
0
        public void Draw()
        {
            if (_type == ShipTypeQual.None)
            {
                return;
            }

            // Fill Circle
            _picturebox.FillCircle(Color.FromArgb(100, Color.LimeGreen), _ship.Sphere.Position, _ship.Sphere.Radius);

            // Draw direction facing
            MyVector dirFacing = _ship.Sphere.DirectionFacing.Standard.Clone();

            dirFacing.BecomeUnitVector();
            dirFacing.Multiply(_ship.Sphere.Radius);
            dirFacing.Add(_ship.Sphere.Position);

            _picturebox.DrawLine(Color.White, 4, _ship.Sphere.Position, dirFacing);

            // Draw an edge
            _picturebox.DrawCircle(Color.Black, 25d, _ship.Sphere.Position, _ship.Sphere.Radius);

            #region Thrust Lines

            foreach (MyVector[] thrustPair in _thrustLines)
            {
                MyVector thrustStart = _ship.Ball.Rotation.GetRotatedVector(thrustPair[0], true);
                thrustStart.Add(_ship.Ball.Position);

                MyVector thrustStop = thrustPair[1] * -250d;
                thrustStop.Add(thrustPair[0]);
                thrustStop = _ship.Ball.Rotation.GetRotatedVector(thrustStop, true);
                thrustStop.Add(_ship.Ball.Position);

                _picturebox.DrawLine(Color.Coral, 40d, thrustStart, thrustStop);
            }

            #endregion
            #region Tractor Effect

            if (_isQPressed || _isQLocked || _isEPressed || _isELocked)
            {
                foreach (TractorBeamCone tractor in _tractorBeams)
                {
                    // Figure out the cone tip location
                    MyVector tractorStart = _ship.Ball.Rotation.GetRotatedVector(tractor.Offset, true);
                    tractorStart.Add(_ship.Ball.Position);

                    // Figure out how bright to draw it
                    int alpha = 0;
                    if (_powerLevel == 1)
                    {
                        alpha = 15;
                    }
                    else if (_powerLevel == 2)
                    {
                        alpha = 30;
                    }
                    else if (_powerLevel == 3)
                    {
                        alpha = 60;
                    }
                    else //if (_powerLevel == 4)
                    {
                        alpha = 128;
                    }

                    // Draw Cone
                    if ((_isQPressed || _isQLocked) && (_isEPressed || _isELocked))
                    {
                        _picturebox.FillPie(Color.FromArgb(alpha, Color.White), tractorStart, tractor.MaxDistance, _ship.Ball.DirectionFacing.Standard, tractor.SweepAngle);
                    }
                    else if (_isQPressed || _isQLocked)
                    {
                        _picturebox.FillPie(Color.FromArgb(alpha, Color.Pink), tractorStart, tractor.MaxDistance, _ship.Ball.DirectionFacing.Standard, tractor.SweepAngle);
                    }
                    else if (_isEPressed || _isELocked)
                    {
                        _picturebox.FillPie(Color.FromArgb(alpha, Color.LightSkyBlue), tractorStart, tractor.MaxDistance, _ship.Ball.DirectionFacing.Standard, tractor.SweepAngle);
                    }
                }
            }

            #endregion
            #region Gun Effect



            #endregion

            #region Thrusters

            if (_type == ShipTypeQual.Ball)
            {
                DrawAttatchment(new MyVector(0, 0, 0), AttatchementType.Thruster);
            }
            else if (_type == ShipTypeQual.SolidBall)
            {
                DrawAttatchment(_thrusterOffset_BottomRight, AttatchementType.Thruster);
                DrawAttatchment(_thrusterOffset_BottomLeft, AttatchementType.Thruster);
                DrawAttatchment(_thrusterOffset_TopRight, AttatchementType.Thruster);
                DrawAttatchment(_thrusterOffset_TopLeft, AttatchementType.Thruster);
            }

            #endregion
            #region Gun

            DrawAttatchment(_cannon.Barrels[0].Offset, AttatchementType.Cannon);

            foreach (ProjectileWeapon weapon in _machineGuns)
            {
                DrawAttatchment(weapon.Barrels[0].Offset, AttatchementType.MachineGun);
            }

            #endregion
            #region Tractor Beam

            // This needs to go after thrusters and guns, because the tractor is smaller, and the ball has everything at zero
            foreach (TractorBeamCone tractor in _tractorBeams)
            {
                DrawAttatchment(tractor.Offset, AttatchementType.Tractor);
            }

            #endregion
        }
Ejemplo n.º 4
0
        /// <summary>
        /// The opacity passed in will be applied after figuring out the opacity of mode (if mode says 128, and opacity is .5, then
        /// the final opacity is 64)
        /// </summary>
        public void DrawSolidBall(SolidBall ball, DrawMode mode, CollisionStyle collisionStyle, bool drawRed, double opacity)
        {
            Color color;

            #region Figure out the color

            if (drawRed)
            {
                color = REDCOLOR;
            }
            else
            {
                color = Color.RoyalBlue;
            }

            #endregion

            int finalOpacity;
            #region Figure out the opacity

            switch (mode)
            {
            case DrawMode.Building:
                finalOpacity = BUILDINGBALLFILLOPACTIY;
                break;

            case DrawMode.Selected:
            case DrawMode.Standard:
                finalOpacity = STANDARDBALLFILLOPACTIY;
                break;

            default:
                throw new ApplicationException("Unknown DrawMode: " + mode.ToString());
            }

            finalOpacity = Convert.ToInt32(finalOpacity * opacity);
            if (finalOpacity < 0)
            {
                finalOpacity = 0;
            }
            else if (finalOpacity > 255)
            {
                finalOpacity = 255;
            }

            #endregion

            MyVector dirFacing;
            #region Figure out direction facing

            dirFacing = ball.DirectionFacing.Standard.Clone();
            dirFacing.BecomeUnitVector();
            dirFacing.Multiply(ball.Radius);
            dirFacing.Add(ball.Position);

            #endregion

            // Collision Style
            DrawCollisionStyle(ball.Position, ball.Radius, collisionStyle);

            // Fill the circle
            using (Brush brush = new SolidBrush(Color.FromArgb(finalOpacity, color)))
            {
                _viewer.FillCircle(brush, ball.Position, ball.Radius);
            }

            // Draw direction facing
            _viewer.DrawLine(Color.FromArgb(finalOpacity, Color.White), 2d, ball.Position, dirFacing);

            #region Draw the edge

            switch (mode)
            {
            case DrawMode.Building:
                _viewer.DrawCircle(Color.FromArgb(finalOpacity, _buildingPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius);
                break;

            case DrawMode.Standard:
                _viewer.DrawCircle(Color.FromArgb(finalOpacity, _standardPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius);
                break;

            case DrawMode.Selected:
                _viewer.DrawCircle_Selected(ball.Position, ball.Radius);
                break;
            }

            #endregion

            //TODO:  Show Stats
        }