Beispiel #1
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
        }
Beispiel #2
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 DrawBall(Ball ball, DrawMode mode, CollisionStyle collisionStyle, bool drawRed, double opacity)
        {
            Color color;

            #region Figure out the color

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

            #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

            // 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);
            }

            #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
        }