Example #1
0
        public void DrawrobotNames(SpriteBatch spriteBatch, WorldObjectRobot robot, GraphicsDevice graphicsDevice, ArcBallCamera camera, Matrix projection)
        {
            GameObjectRobot gameObjectRobot = (GameObjectRobot)robot.GameObject;
            Vector3         screenSpace     = graphicsDevice.Viewport.Project(Vector3.Zero,
                                                                              projection,
                                                                              camera.ViewMatrix,
                                                                              Matrix.CreateTranslation(robot.PositionX, robot.PositionY, robot.PositionZ));

            // Get 2D coordinates from screenspace vector
            Vector2 textPosition;

            textPosition.X = screenSpace.X;
            textPosition.Y = screenSpace.Y;

            // Center the text
            Vector2 stringCenter = FontSmall.MeasureString(gameObjectRobot.FullName) * 0.5f;

            // Calculate position
            textPosition.X = (int)(textPosition.X - stringCenter.X);
            //textPosition.Y = (int)(textPosition.Y - stringCenter.Y);
            textPosition.Y = (int)(textPosition.Y + stringCenter.Y);

            // Skip if out of screen
            if (textPosition.X < 0 || textPosition.X > graphicsDevice.Viewport.Width)
            {
                return;
            }
            if (textPosition.Y < 0 || textPosition.Y > graphicsDevice.Viewport.Height)
            {
                return;
            }

            // Draw the text
            spriteBatch.DrawString(FontSmall, gameObjectRobot.FullName, textPosition, Color.White);
        }
Example #2
0
        public void DrawrobotNames(SpriteBatch spriteBatch, GameObjectRobot robot, Vector2 camera)
        {
            Vector2 fontOriginRobotName = FontSmall.MeasureString(robot.FullName) / 2;

            fontOriginRobotName.X = (float)Math.Ceiling(fontOriginRobotName.X);             // Move to full pixel
            fontOriginRobotName.Y = (float)Math.Ceiling(fontOriginRobotName.Y);
            spriteBatch.DrawString(FontSmall, robot.FullName,
                                   new Vector2((int)(camera.X + robot.PositionX), (int)(camera.Y + robot.PositionY - robot.Radius)),
                                   Color.White, 0, fontOriginRobotName, 1.0f, SpriteEffects.None, 0.5f);
        }
 public void Add(RadioButton r)
 {
     r.Position = new Vector2(Position.X, Position.Y + (RadioButtons.Count + 1) * FontSmall.MeasureString("M").Y + 7);
     Console.WriteLine(r.Position.ToString());
     RadioButtons.Add(r);
 }
        public RadioGroup(string text, bool outline, Vector2 position, List <RadioButton> radioButtons)
        {
            RadioButtons = new List <RadioButton>();

            Position = position;

            Text    = text;
            Outline = outline;

            foreach (RadioButton r in radioButtons)
            {
                r.Position = new Vector2(Position.X, Position.Y + (RadioButtons.Count + 1) * FontSmall.MeasureString("M").Y + 7);
                r.Parent   = this;

                RadioButtons.Add(r);
            }
        }
Example #5
0
        public void DrawGUI(SpriteBatch sb)
        {
            int padding = 10, height = padding * 5, offset = 3;

            sb.Draw(Spritesheet, Camera.Position + new Vector2(padding - 7, padding - 3), new Rectangle(new Point((SpritesheetSize.X - 3) * Cell, 0), new Point(3 * Cell, 2 * Cell)), Color, 0, Vector2.Zero, 4, SpriteEffects.None, GUILayer);
            sb.Draw(Spritesheet, Camera.Position + new Vector2(padding - 7, padding - 3), new Rectangle(new Point((SpritesheetSize.X - 3) * Cell, 4 * Cell), new Point(3 * Cell, 2 * Cell)), Color.White, 0, Vector2.Zero, 4, SpriteEffects.None, GUILayer);

            //ExitButton.Position = new Vector2(Graphics.PreferredBackBufferWidth - padding - ExitButton.Background.Width, height + padding);
            ExitButton.Draw(sb);

            //STATS
            StatList.StatList.ForEach(x => x.Draw(sb));

            //TIMER
            sb.DrawString(FontSmall, ((int)(TurnTime - Time)).ToString(), Camera.Position + new Vector2(Graphics.PreferredBackBufferWidth - padding - FontSmall.MeasureString(((int)(TurnTime - Time)).ToString()).X - offset * 2, padding + offset), Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, GUILayer);

            //ADD CARD BUTTON
            AddCardButton.Draw(sb);

            //CARDS
            Cards.ForEach(x => x.Draw(sb));

            if (HoveringCard != null)
            {
                HoveringCard.Draw(sb);
            }
        }