Esempio n. 1
0
        /** <summary> Paints the control. </summary> */
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.FillRectangle(new SolidBrush(colorBackground), new Rectangle(0, 0, 10, 11));
            e.Graphics.DrawLine(new Pen(colorBorderDark), new Point(0, 0), new Point(9, 0));
            e.Graphics.DrawLine(new Pen(colorBorderDark), new Point(0, 0), new Point(0, 10));
            e.Graphics.DrawLine(new Pen(colorBorderLight), new Point(1, 10), new Point(9, 10));
            e.Graphics.DrawLine(new Pen(colorBorderLight), new Point(9, 1), new Point(9, 10));

            if (checkImage != null && checkState != CheckState.Unchecked)
            {
                ColorMap colorMap = new ColorMap();
                colorMap.OldColor = Color.Black;
                colorMap.NewColor = colorCheck;
                ImageAttributes imageAttributes = new ImageAttributes();
                imageAttributes.SetRemapTable(new ColorMap[] { colorMap });

                Point     point = Point.Empty;
                Size      size  = checkImage.Size;
                Rectangle rect  = new Rectangle(0, 0, 10, 11);
                point.X = (rect.Width - size.Width) / 2;
                point.Y = (rect.Height - size.Height) / 2;
                e.Graphics.DrawImage(checkImage,
                                     new Rectangle(point, size),
                                     0, 0, 8, 8, GraphicsUnit.Pixel,
                                     imageAttributes
                                     );
            }
            SpriteFont font = SpriteFont.FontBold;

            switch (this.fontType)
            {
            case FontType.Regular: font = SpriteFont.FontRegular; break;

            case FontType.Bold: font = SpriteFont.FontBold; break;

            case FontType.Small: font = SpriteFont.FontSmall; break;
            }
            font.Draw(e.Graphics, new Point(10 + 4, 0), Text, ForeColor, outlineColor);
        }
Esempio n. 2
0
        public override void Draw(Vector2 _mousePos)
        {
            base.Draw(_mousePos);

            font.Draw(text, anchor);
        }
Esempio n. 3
0
        public void DrawCustom(Vector2 pos)
        {
            box.SetToAnchor(Anchor.Bottom(pos - new Vector2(0, 16f)));
            box.PushIntoRectangle(viewInScreenSpace);

            boxInner.pos = box.pos + new Vector2(cornerRadius);

            boxInnerToDraw.pos    = box.pos + new Vector2(0, cornerRadius);
            boxInnerToDraw.Width  = box.Width;
            boxInnerToDraw.Height = box.Height - cornerRadius * 2f;
            boxInnerToDraw.Draw(backColor);

            boxInnerToDraw.pos    = box.pos + new Vector2(cornerRadius, 0);
            boxInnerToDraw.Width  = box.Width - cornerRadius * 2f;
            boxInnerToDraw.Height = box.Height;
            boxInnerToDraw.Draw(backColor);

            Vector2 speechStart = pos + Vector2.Normalize(boxInner.GetCenter() - pos) * 8f;

            Vector2         dist = speechStart - boxInner.GetCenter();
            CollisionResult cr   = boxInner.DistToVector(speechStart, dist);

            if (cr.distance.HasValue)
            {
                Drawer.DrawLineRelative(speechStart, -dist * cr.distance.Value, backColor, 2f);
            }

            for (int y = 0; y < 2; y++)
            {
                for (int x = 0; x < 2; x++)
                {
                    Vector2 p = box.pos + new Vector2(x * (box.Width - cornerRadius), y * (box.Height - cornerRadius));
                    corner.Draw(p, backColor, new Rectangle(x * cornerRadius, y * cornerRadius, cornerRadius, cornerRadius));
                }
            }


            Vector2 drawPos = box.pos + boxBorder;

            for (int i = 0; i < currentLine; i++)
            {
                font.Draw(lines[i], drawPos, textColor);
                drawPos += newLineSpace;
            }

            if (currentLine < lines.Count)
            {
                string  t1;
                Vector2 s;
                if (currentChar > 0)
                {
                    t1 = lines[currentLine].Remove((int)currentChar);
                    font.Draw(t1, drawPos, textColor);
                    s = font.MeasureString(t1);
                }
                else
                {
                    s   = font.MeasureString("A");
                    s.X = 0;
                    t1  = "";
                }
                string  t2 = lines[currentLine][(int)currentChar].ToString();
                Vector2 s2 = font.MeasureString(t2);
                font.Draw(t2, Anchor.Left(drawPos + s + new Vector2(0, -s2.Y) / 2f), textColor, Vector2.One * 1.5f);
            }
        }
Esempio n. 4
0
        void MonoMethods.Draw(SpriteBatch spriteBatch)
        {
            float wScale = (float)graphics.PreferredBackBufferWidth / Width;
            float hScale = (float)graphics.PreferredBackBufferHeight / Height;
            float scale  = Math.Min(wScale, hScale);

            if (Input.mbWheel != 0)
            {
                cameraZoom -= Math.Sign(Input.mbWheel);
                if (cameraZoom < 1)
                {
                    cameraZoom = 1f;
                }
            }

            scale *= cameraZoom;

            float realW = graphics.PreferredBackBufferWidth / scale;
            float realH = graphics.PreferredBackBufferHeight / scale;


            if (firstPlayerView)
            {
                if (cameraOrientation == 99)
                {
                    cameraOrientation = -bots[0].orientation - MathHelper.PiOver2;
                }
                else
                {
                    cameraOrientation += (-bots[0].orientation - MathHelper.PiOver2 - cameraOrientation) * 0.1f;// 04f;
                }
                matrix = Matrix.CreateTranslation(new Vector3(-bots[0].positionV, 0f)) * Matrix.CreateRotationZ(cameraOrientation) * Matrix.CreateTranslation(new Vector3(new Vector2(realW, realH) / 2f, 0)) * Matrix.CreateScale(scale);
            }
            else
            {
                Vector2 shift = Vector2.Zero;// new Vector2(realW, realH) / 2f;// - new Vector2(width, height) / 2f;

                if (hScale > wScale)
                {
                    shift.Y += (realH - Height) * 0.5f;
                }
                else if (wScale > hScale)
                {
                    shift.X += (realW - Width) * 0.5f;
                }

                matrix = Matrix.CreateTranslation(new Vector3(shift, 0)) * Matrix.CreateScale(scale);
            }
            //DrawM.basicEffect.SetWorldAndInvTransp(matrix);
            DrawM.basicEffect.World = matrix;
            DrawM.scale             = scale;

            spriteBatch.GraphicsDevice.Clear(new Color(128, 128, 128));
            //spriteBatch.GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, null, null, null, matrix);

            Drawer.depth = new DepthLayer(0f);

            DrawM.Vertex.DrawRectangle(new M_Rectangle(0, 0, Width, Height), Color.CornflowerBlue);


            for (int i = 0; i < goals.Count; i++)
            {
                if (i + 1 < goals.Count)
                {
                    DrawM.Vertex.DrawLine(goals[i], goals[i + 1], Color.DeepSkyBlue, 0.2f);
                }

                DrawGoal(i, goals[i], 1f);
            }

            void DrawGoal(int i, Vector2 pos, float opaque)
            {
                DrawM.Vertex.DrawCircleOutline(pos, goalRadius, Color.DeepSkyBlue, 8f);

                float angle = 0f;
                float fov   = MathHelper.TwoPi / bots.Length;

                for (int j = 0; j < bots.Length; j++)
                {
                    Color color = bots[j].goalIndex > i ? Color.Transparent : bots[j].goalIndex == i ? bots[j].GetInternalColor() : Color.DeepSkyBlue;
                    DrawM.Vertex.DrawCone(pos, goalRadius, angle, fov, color * opaque, color * opaque, 8f);
                    angle += fov;
                }
                //DrawM.Vertex.DrawCircle(goals[i], GOALRADIUS, Color.Lime, 16f);
                //font.Draw(i.ToString(), Anchor.Center(goals[i]), Color.Black, new Vector2(0.2f));
            }

            if (firstPlayerView && bots[0].goalIndex < goals.Count)
            {
                // if goal is outside of screen, show it at the border of the screen


                M_Rectangle rect   = new M_Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
                Vector2     center = new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight) / 2f;
                M_Polygon   poly   = rect.ToPolygon();
                //rect.pos -= rect.size / 2f;
                Matrix invert = Matrix.Invert(matrix);
                poly.Transform(invert);
                center = Vector2.Transform(center, invert);
                Vector2 onScreenGoalPos = goals[bots[0].goalIndex];// Vector2.Transform(goals[bots[0].goalIndex], matrix);

                //DrawM.Vertex.DrawRectangle(rect, Color.Red * 0.5f);

                if (!poly.ColVector(onScreenGoalPos))
                {
                    Vector2 dir = onScreenGoalPos - center;
                    var     cr  = poly.DistToVector(onScreenGoalPos, dir);

                    onScreenGoalPos -= dir * cr.distance.Value;// + Vector2.Normalize(dir) * 3f;

                    //if (onScreenGoalPos.X < rect.Left)
                    //    onScreenGoalPos.X = rect.Left;
                    //if (onScreenGoalPos.X > rect.Right)
                    //    onScreenGoalPos.X = rect.Right;
                    //if (onScreenGoalPos.Y < rect.Top)
                    //    onScreenGoalPos.Y = rect.Top;
                    //if (onScreenGoalPos.Y > rect.Bottom)
                    //    onScreenGoalPos.Y = rect.Bottom;

                    DrawGoal(bots[0].goalIndex, onScreenGoalPos, 0.5f);
                }

                //camera
                //bots[0].goalIndex
            }

            string text;

            for (int i = 0; i < bots.Length; i++)
            {
                if (bots[i].Alive)
                {
                    bots[i].mask.Draw(bots[i].GetInternalColor());

                    bots[i].Draw();
                }
            }

            spriteBatch.End();

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp);

            for (int i = 0; i < goals.Count; i++)
            {
                Vector2 pos = Vector2.Transform(goals[i], matrix);
                font.Draw((i + 1).ToString(), Anchor.Center(pos), Color.Black);
            }

            text = "";

            text += "time: " + Math.Floor(frame / 60f) + " s\n";

            if (gameEnd)
            {
                for (int i = 0; i < bots.Length; i++)
                {
                    text += "______________________\n";
                    text += "Bot " + i + "\n";
                    //text += "Health: " + bots[i].health + "\n";
                    text += "Time: " + bots[i].frameTime + "\n";

                    /*text += "Kills: " + bots[i].kills + "\n";
                     * text += "Damage Dealt: " + bots[i].damageDealt + "\n";*/
                }
            }

            spriteBatch.DrawString(font, text, new Vector2(16, 16), Color.White);


            spriteBatch.End();
        }