Specialized shape representing a rectangle
Наследование: Shape
Пример #1
0
        public Rowboat(Game game)
            : base(game, game.GraphicsMode == Game.GRAPHICSMODE_NORMAL ? Graphics.GetAnimatedSprite(game, "assets/sprites/rowboat.xml") : Graphics.GetAnimatedSprite(game, "assets/sprites/blueprint/rowboat.xml"))
        {
            Collision = new RectangleShape(new Vector2f(82f, 38f));
            Collision.Position = new Vector2f(-41f, -19f);

            Model.Stop();

            HealthMax = 8000;
            Health = HealthMax;

            SpeedMax = 50.0f + Math.Min(0.5f * Game.AIManager.Difficulty, 25.0f);
            Acc = 200.0f;

            // Add Infantry Passengers
            AddInfantryman(new Vector2f(0, -10));
            AddInfantryman(new Vector2f(0, 10));

            AddInfantryman(new Vector2f(25, -10));
            AddInfantryman(new Vector2f(25, 10));

            AddInfantryman(new Vector2f(-25, -10));
            AddInfantryman(new Vector2f(-25, 10));

            SetAI(new RowboatAI(Game));
        }
        public override void Draw(RenderTarget rt)
        {
            RectangleShape overylay = new RectangleShape(new Vector2f(GameOptions.Width, GameOptions.Height))
            {
                FillColor = new Color(0, 0, 0, 128)
            };

            rt.Draw(overylay);

            RectangleShape window = new RectangleShape(new Vector2f(GameOptions.Width * (1.0f - PaddingHorizontal * 2.0f), GameOptions.Height * (1.0f - PaddingVertical * 2.0f)))
            {
                Position = new Vector2f(GameOptions.Width * PaddingHorizontal, GameOptions.Height * PaddingVertical),
                FillColor = Color.White,
                OutlineColor = Color.Black,
                OutlineThickness = 2.0f
            };

            rt.Draw(window);

            Text labelSettings = new Text("Join by IP", Assets.LoadFont(Program.DefaultFont))
            {
                Position = new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height * PaddingVertical + 48.0f),
                Color = Color.Black,
                CharacterSize = 32
            };

            labelSettings.Center();
            labelSettings.Round();
            rt.Draw(labelSettings);

            base.Draw(rt);
        }
Пример #3
0
        public override void loadContent()
        {
            float logoScale;

            _logoTexture = ResourceManager.getResource<Texture>("logo_1");
            _logoShape = new RectangleShape();
            _logoShape.Texture = _logoTexture;
            _logoShape.Size = new Vector2f(_logoTexture.Size.X, _logoTexture.Size.Y);
            logoScale = Game.window.GetView().Size.X / (float)_logoTexture.Size.X;
            _logoShape.Scale = new Vector2f(logoScale, logoScale);

            _font = ResourceManager.getResource<Font>("immortal_font");
            _options = new List<Text>();
            _options.Add(new Text("New Game", _font, 48));
            _options.Add(new Text("Continue", _font, 48));
            _options.Add(new Text("Options", _font, 48));
            _options.Add(new Text("Exit", _font, 48));

            for (int i = 0; i < _options.Count; i++)
            {
                Text text = _options[i];

                text.Position = new Vector2f(128, i * 48 + _logoShape.Size.Y * _logoShape.Scale.Y + 64);
            }
        }
Пример #4
0
        public PauseState(StateStack stack, Context context)
            : base(stack, context)
        {
            RenderWindow window = mContext.window;

            mBackgroundSprite = new Sprite();
            mPausedText = new Text();
            mInstructionText = new Text();

            mPausedText.Font = mContext.fonts.get(FontID.Main);
            mPausedText.DisplayedString = "Game Paused";
            mPausedText.CharacterSize = 70;
            mPausedText.centerOrigin();
            mPausedText.Position = new Vector2f(0, 0);

            mInstructionText.Font = mContext.fonts.get(FontID.Main);
            mInstructionText.DisplayedString = "(Press Backspace to return to main menu)";
            mInstructionText.centerOrigin();
            mInstructionText.Position = new Vector2f(0, 0);

            backgroundShape = new RectangleShape();
            backgroundShape.FillColor = new Color(0, 0, 0, 150);
            backgroundShape.Position = window.GetView().Center;
            backgroundShape.centerOrigin();
            backgroundShape.Size = window.GetView().Size;
        }
Пример #5
0
        public ButtonControl(Font font, uint size, Texture button, Texture hover, Texture press)
        {
            left = new RectangleShape();
            middle = new RectangleShape();
            right = new RectangleShape();

            left.Texture = button;
            middle.Texture = button;
            right.Texture = button;

            left.TextureRect = new IntRect(0, 0, (int)button.Size.X / 2 - 1, (int)button.Size.Y);
            middle.TextureRect = new IntRect((int)button.Size.X / 2 - 1, 0, 2, (int)button.Size.Y);
            right.TextureRect = new IntRect((int)button.Size.X / 2 + 1, 0, (int)button.Size.X / 2, (int)button.Size.Y);

            text = new TextControl(font, size) { TextAlignment = Alignment.MiddleCenter, Bold = true };
            text.BackgroundColor = Color.Transparent;

            IsHovered = false;
            IsPressed = false;
            ClickYOffset = 4.0f;

            buttonTexture = button;
            hoverTexture = hover;
            pressedTexture = press;
        }
        public override void Draw(RenderTarget rt)
        {
            RectangleShape bgOverlay = new RectangleShape(new Vector2f(GameOptions.Width, GameOptions.Height)) { FillColor = Color.Black };
            rt.Draw(bgOverlay);

            Text title = new Text("Game Over", Assets.LoadFont(Program.DefaultFont))
            {
                Position = new Vector2f(GameOptions.Width / 2.0f, 48.0f),
                CharacterSize = 48,
                Color = Color.White
            };

            title.Center();
            title.Round();
            rt.Draw(title);

            Text winnerTitle = new Text(GetWinnerText(), Assets.LoadFont(Program.DefaultFont))
            {
                Position = new Vector2f(GameOptions.Width / 2.0f, GameOptions.Height / 2.0f),
                CharacterSize = 48,
                Color = Color.White
            };

            winnerTitle.Center();
            winnerTitle.Round();
            rt.Draw(winnerTitle);

            base.Draw(rt);
        }
Пример #7
0
 public Tile(Color color, Vector2f position, bool walkable, Vector2f size)
 {
     shape = new RectangleShape(size);
     shape.FillColor = color;
     shape.Position = position;
     Walkable = walkable;
 }
Пример #8
0
        public Ship(Game game)
            : base(game)
        {
            if (Game.GraphicsMode == Game.GRAPHICSMODE_NORMAL)
            {
                Model = Graphics.GetAnimatedSprite(game, "assets/sprites/ship.xml");
            }
            else
            {
                Model = Graphics.GetSprite("assets/sprites/blueprint/ship.png");
                Model.Scale = new Vector2f(0.5f, 0.5f);
                Model.Origin = new Vector2f(265, 244);
            }
            AddChild(Model);

            Collision = new RectangleShape(new Vector2f(265, 105));
            Collision.Position = new Vector2f(-132.5f, -52.5f);

            SpeedMax = 50.0f + Math.Min(0.5f * Game.AIManager.Difficulty, 25.0f);
            Acc = 200.0f;

            AmountOfInfantry = Utils.RandomInt(12, 18);

            SetAI(new ShipAI(Game));
        }
Пример #9
0
        public void NewGame()
        {
            while (Window.IsOpen)
            {
                Window.DispatchEvents();
                Window.Clear();

                var x = Window.Size.X; var y = Window.Size.Y;
                var line = new SFML.Graphics.RectangleShape(new SFML.System.Vector2f(16, y));
                line.Position = new SFML.System.Vector2f(x / 3, 0);
                Window.Draw(line);

                line = new SFML.Graphics.RectangleShape(new SFML.System.Vector2f(x, 16));
                line.Position = new SFML.System.Vector2f(0, y / 3);
                Window.Draw(line);

                line = new SFML.Graphics.RectangleShape(new SFML.System.Vector2f(16, y));
                line.Position = new SFML.System.Vector2f(x * 2 / 3, 0);
                Window.Draw(line);

                line = new SFML.Graphics.RectangleShape(new SFML.System.Vector2f(x, 16));
                line.Position = new SFML.System.Vector2f(0, y * 2 / 3);
                Window.Draw(line);

                Window.Display();
            }
        }
Пример #10
0
        /// <summary>Checks collision between Circle and Rotated Rectangle.</summary>
        /// <param name="rectAngle">In Degrees.</param>
        public static bool CircleRectangleCollision(Vector2f circleCenter, float circleRadius, RectangleShape rect, float rectAngle = 0, Vector2f rectOffset = default(Vector2f))
        {
            Vector2f rectPos = new Vector2f(rect.Position.X + rectOffset.X, rect.Position.Y + rectOffset.Y);
            Vector2f rectCenter = new Vector2f(rectPos.X + (rect.Size.X / 2), rectPos.Y + (rect.Size.Y / 2));

            // Rotate circle's center point back

            Vector2f unrotatedCircle = new Vector2f();
            unrotatedCircle.X = (float)Math.Cos(rectAngle) * (circleCenter.X - rectCenter.X) - (float)Math.Sin(rectAngle) * (circleCenter.Y - rectCenter.Y) + rectCenter.X;
            unrotatedCircle.Y = (float)Math.Sin(rectAngle) * (circleCenter.X - rectCenter.X) + (float)Math.Cos(rectAngle) * (circleCenter.Y - rectCenter.Y) + rectCenter.Y;

            // Closest point in the rectangle to the center of circle rotated backwards(unrotated)
            Vector2f closest = new Vector2f();

            // Find the unrotated closest x point from center of unrotated circle
            if (unrotatedCircle.X < rectPos.X)
                closest.X = rectPos.X;
            else if (unrotatedCircle.X > rectPos.X + rect.Size.X)
                closest.X = rectPos.X + rect.Size.X;
            else
                closest.X = unrotatedCircle.X;

            // Find the unrotated closest y point from center of unrotated circle
            if (unrotatedCircle.Y < rectPos.Y)
                closest.Y = rectPos.Y;
            else if (unrotatedCircle.Y > rectPos.Y + rect.Size.Y)
                closest.Y = rectPos.Y + rect.Size.Y;
            else
                closest.Y = unrotatedCircle.Y;

            // Determine collision
            return Distance(unrotatedCircle, closest) < circleRadius;
        }
Пример #11
0
        public Menu()
            : base()
        {
            hoverCursor = Content.GetTexture("cursorHover.png");
            defaultCursor = Content.GetTexture("cursorPointer.png");
            currentCursor = defaultCursor;
            char1 = new Animation(Content.GetTexture("idle.png"), 4, 0, 0, true);
            char2 = new Animation(Content.GetTexture("char2_idle.png"), 4, 0, 0, true);
            shader = new RenderStates(new Shader(null, "Content/bgPrlx.frag"));

            rectConnect = new RectangleShape()
            {
                Size = new Vector2f(150, 30),
                Position = new Vector2f(-25, 70)
            };
            rectIP = new RectangleShape()
            {
                Size = new Vector2f(150, 20),
                Position = new Vector2f(-25, 40)
            };
            rectUsername = new RectangleShape()
            {
                Size = new Vector2f(150, 20),
                Position = new Vector2f(-25, 10)
            };

            MainGame.window.TextEntered += TextEnteredEvent;
        }
Пример #12
0
        public void DrawRectangle(int x1, int y1, int x2, int y2, Color color, Color color2, int thickness)
        {
            if (!IsObjectOnScreen(x1, y1, x2 - x1, y2 - y1))
            {
                return;
            }

            var zoom = GetZoom();

            int real_x1 = (int)(x1 * zoom);
            int real_x2 = (int)(x2 * zoom);
            int real_y1 = (int)(y1 * zoom);
            int real_y2 = (int)(y2 * zoom);

            SFML.System.Vector2f position = new SFML.System.Vector2f(real_x1, real_y1);
            SFML.System.Vector2f size     = new SFML.System.Vector2f(real_x2 - real_x1, real_y2 - real_y1);

            SFML.Graphics.RectangleShape rect = new SFML.Graphics.RectangleShape();
            rect.OutlineThickness = thickness;
            rect.OutlineColor     = new SFML.Graphics.Color(color2.R, color2.G, color2.B, color2.A);
            rect.FillColor        = new SFML.Graphics.Color(color.R, color.G, color.B, color.A);
            rect.Position         = position;
            rect.Size             = size;
            RenderWindow.Draw(rect);
        }
Пример #13
0
        public override void Draw(RenderTarget target, Vector2f position)
        {
            _icon.Position = position;
            target.Draw(_icon);

            if (_amount == 0)
            {
                var darken = new RectangleShape(new Vector2f(Hud.IconSize - Hud.IconBorderTwice, Hud.IconSize - Hud.IconBorderTwice));
                darken.Origin = new Vector2f(Hud.IconSizeHalf - Hud.IconBorder, Hud.IconSizeHalf - Hud.IconBorder);
                darken.FillColor = new Color(0, 0, 0, 200);
                darken.Position = position;
                target.Draw(darken);
            }

            if (_time > 0)
            {
                var per = _time / BuildTime;
                var box = new RectangleShape(new Vector2f(per * (Hud.IconSize - Hud.IconBorderTwice), 8));
                box.FillColor = new Color(0, 180, 0, 128);
                box.Position = position - new Vector2f(Hud.IconSizeHalf - Hud.IconBorder, Hud.IconSizeHalf - Hud.IconBorder);
                target.Draw(box);
            }

            _amountText.DisplayedString = _amount.ToString("G");
            _amountText.Position = position + new Vector2f(Hud.IconSizeHalf - Hud.Padding, Hud.IconSizeHalf - Hud.Padding);

            var bounds = _amountText.GetLocalBounds();
            _amountText.Origin = new Vector2f(bounds.Width + bounds.Left, bounds.Height + bounds.Top);

            target.Draw(_amountText);
        }
Пример #14
0
        public WorldView(IWorld world)
        {
            _background = new Sfg.RectangleShape(new Sfs.Vector2f(300f, 480f))
            {
                FillColor        = Sfg.Color.Black,
                OutlineThickness = 20f,
                OutlineColor     = new Sfg.Color(212, 175, 55)
            };
            _views   = new List <Sfg.RectangleShape>();
            Position = new Sfs.Vector2f(-100, -100);
            for (var y = 0; y < World.WorldBounds.Y; y++)
            {
                for (var x = 0; x < World.WorldBounds.X; x++)
                {
                    if (!world.Matrix[y, x])
                    {
                        continue;
                    }

                    var position = new Sfs.Vector2f(x * 30, y * 30);
                    var view     = new Sfg.RectangleShape(new Sfs.Vector2f(28f, 28f))
                    {
                        FillColor        = Sfg.Color.White,
                        Position         = position,
                        OutlineThickness = 2f,
                        OutlineColor     = Sfg.Color.Black
                    };
                    _views.Add(view);
                }
            }
        }
Пример #15
0
        public Hud(GameBase state)
        {
            _state = state;

            _selected = new Sprite(Assets.LoadTexture("wep_selected.png")).Center();

            _statusBack = new RectangleShape(new Vector2f(BarWidth + Padding * 2, BarHeight * 2 + Padding * 3));
            _statusBack.Position = new Vector2f(Padding, Padding);
            _statusBack.FillColor = new Color(0, 0, 0);
            _statusBack.OutlineThickness = 2;
            _statusBack.OutlineColor = new Color(38, 38, 38);

            _health = new RectangleShape(new Vector2f(BarWidth, BarHeight));
            _health.Position = _statusBack.Position + new Vector2f(Padding, Padding);
            _health.FillColor = new Color(0, 120, 0);

            _healthText = new Text("", Program.Font, (int)(BarHeight - Padding));
            _healthText.Position = _health.Position + new Vector2f(BarWidth / 2, BarHeight / 2);
            _healthText.Color = new Color(225, 225, 225);

            _energy = new RectangleShape(new Vector2f(BarWidth, BarHeight));
            _energy.Position = _health.Position + new Vector2f(0, BarHeight + Padding);
            _energy.FillColor = new Color(30, 30, 180);

            _energyText = new Text("", Program.Font, (int)(BarHeight - Padding));
            _energyText.Position = _energy.Position + new Vector2f(BarWidth / 2, BarHeight / 2);
            _energyText.Color = new Color(225, 225, 225);
        }
Пример #16
0
        public Frame(RectangleShape borderRect, Color fillColor)
        {
            BorderRect = borderRect;
            BorderRect.FillColor = fillColor;

            BoundingRect = borderRect.GetGlobalBounds();
        }
Пример #17
0
        public BigLabeledButtonComponent(Screen screen, Texture buttonTexture, Vector2f position, string text, Color buttonColor, Action onClick)
            : base(screen)
        {
            _buttonTexture = buttonTexture;
            _position = position;
            _buttonColor = buttonColor;
            _selectedColor = new Color(
                (byte)Math.Min(255, (int)_buttonColor.R + 50),
                (byte)Math.Min(255, (int)_buttonColor.G + 50),
                (byte)Math.Min(255, (int)_buttonColor.B + 50),
                255);
            _onClick = onClick;
            _font = ResourceManager.getResource<Font>("immortal_font");

            // Initialize button shape
            _buttonShape = new RectangleShape();
            _buttonShape.Texture = _buttonTexture;
            _buttonShape.Position = position;
            _buttonShape.Size = new Vector2f(_buttonShape.Texture.Size.X, _buttonShape.Texture.Size.Y);
            _buttonShape.FillColor = _buttonColor;

            // Initialize text
            _firstLetter = new Text(text.Substring(0, 1), _font, 72);
            _firstLetter.Position = position + new Vector2f(30, 0);
            _firstLetter.Color = Color.White;
            _firstLetterShadow = new Text(_firstLetter.DisplayedString, _font, 72);
            _firstLetterShadow.Position = _firstLetter.Position + new Vector2f(3, 3);
            _firstLetterShadow.Color = Color.Black;
            _word = new Text(text.Substring(1, text.Length - 1), _font, 48);
            _word.Position = _firstLetter.Position + new Vector2f(_firstLetter.GetLocalBounds().Width + 4, 13);
            _word.Color = Color.White;
            _wordShadow = new Text(_word.DisplayedString, _font, 48);
            _wordShadow.Position = _word.Position + new Vector2f(3, 3);
            _wordShadow.Color = Color.Black;
        }
Пример #18
0
 public void InitBg()
 {
     bgRect           = new RectangleShape(new SFML.System.Vector2f(480, 270));
     bgRect.Origin    = new SFML.System.Vector2f(bgRect.Size.X / 2, bgRect.Size.Y / 2);
     bgRect.Position  = new SFML.System.Vector2f(1920 / 2, 1080 / 2);
     bgRect.FillColor = new Color(0, 0, 0, 128);
 }
Пример #19
0
 public TileRenderer(Tile data)
 {
     this.data = data;
     rectangleShape = new RectangleShape();
     rectangleShape.Size = this.data.Size;
     rectangleShape.FillColor = data.FillColor;
 }
Пример #20
0
        public ClassSelectorComponent(Screen screen, Texture upArrowTexture, Texture downArrowTexture, Texture classSelectorTexture, List<Texture> classTextures, Vector2f position)
            : base(screen)
        {
            _position = position;
            _classTextures = classTextures;

            _upArrow = new RectangleShape();
            _upArrow.Position = position + new Vector2f(0f, -42f);
            _upArrow.Origin = new Vector2f(8f, 8f);
            _upArrow.Texture = upArrowTexture;
            _upArrow.Size = new Vector2f(16f, 16f);

            _classSelector = new RectangleShape();
            _classSelector.Position = position;
            _classSelector.Origin = new Vector2f(32f, 32f);
            _classSelector.Texture = classSelectorTexture;
            _classSelector.Size = new Vector2f(64f, 64f);

            _classIcon = new RectangleShape();
            _classIcon.Position = position;
            _classIcon.Origin = new Vector2f(32f, 32f);
            _classIcon.Texture = _classTextures[(int)_selectedClass];
            _classIcon.Size = new Vector2f(64f, 64f);

            _downArrow = new RectangleShape();
            _downArrow.Position = position + new Vector2f(0f, 42f);
            _downArrow.Origin = new Vector2f(8f, 8f);
            _downArrow.Texture = downArrowTexture;
            _downArrow.Size = new Vector2f(16f, 16f);
        }
Пример #21
0
        public override void Draw(RenderTarget rt)
        {
            RectangleShape checkbox = new RectangleShape(Size)
            {
                Position = Position,
                FillColor = Color.Black,
            };

            rt.Draw(checkbox);

            if (mouseIn)
            {
                RectangleShape checkboxHover = new RectangleShape(new Vector2f(48.0f - 8.0f, 48.0f - 8.0f))
                {
                    Position = Position + new Vector2f(4.0f, 4.0f),
                    FillColor = Color.Black,
                    OutlineColor = Color.White,
                    OutlineThickness = 2f
                };

                rt.Draw(checkboxHover);
            }

            Text labelText = new Text(Label, Assets.LoadFont(Program.DefaultFont))
            {
                Position = Position + new Vector2f(48.0f + 16.0f, 24.0f + 2.0f),
                CharacterSize = 32,
                Color = Color.Black
            };

            labelText.Center(false);
            labelText.Round();
            rt.Draw(labelText);

            if (Value)
            {
                RectangleShape x1 = new RectangleShape(new Vector2f(48.0f, 3.0f))
                {
                    Position = Position + new Vector2f(24.0f, 24.0f),
                    Origin = new Vector2f(24.0f, 2.0f),
                    FillColor = Color.White,
                    Rotation = -45.0f
                };

                rt.Draw(x1);

                RectangleShape x2 = new RectangleShape(new Vector2f(48.0f, 3.0f))
                {
                    Position = Position + new Vector2f(24.0f, 24.0f),
                    Origin = new Vector2f(24.0f, 2.0f),
                    FillColor = Color.White,
                    Rotation = 45.0f
                };

                rt.Draw(x2);
            }

            base.Draw(rt);
        }
Пример #22
0
        public Rectangle(float width, float height)
            : base(width * height)
        {
            rect = new RectangleShape(new Vector2f(width, height));
            rect.FillColor = Color.Red;

            Origin = rect.Size / 2f;
        }
Пример #23
0
 public UnitRenderer(Unit data)
 {
     this.data = data;
     rectangleShape = new RectangleShape(data.Size);
     rectangleShape.Scale = data.Scale;
     rectangleShape.FillColor = data.FillColor;
     rectangleShape.Position = data.Position;
 }
Пример #24
0
        public Script(Vector2f position, ScriptDef scriptDef)
        {
            RectShape = new RectangleShape { Position = position };

            ScriptDef = scriptDef;

            LoadState(ScriptDef.sStartState);
        }
Пример #25
0
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Copy constructor
 /// </summary>
 ///
 /// <param name="copy">Instance to copy</param>
 ///
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 public Label(Label copy)
     : base(copy)
 {
     m_LoadedConfigFile = copy.m_LoadedConfigFile;
     m_Background       = new RectangleShape(copy.m_Background);
     m_Text             = new Text(copy.m_Text);
     m_AutoSize         = copy.m_AutoSize;
 }
Пример #26
0
 public Cursor()
     : base(5)
 {
     Crosshair = new RectangleShape(new Vector2f(10, 10));
     Crosshair.Texture = Game.Assets.Textures["Crosshair"];
     Crosshair.Origin = Crosshair.Size * 0.5f;
     Crosshair.FillColor = CursorColor;
 }
Пример #27
0
 public SelectedCharacterComponent(Screen screen, Texture texture)
     : base(screen)
 {
     _texture = texture;
     _shape = new RectangleShape(new Vector2f(_texture.Size.X, _texture.Size.Y));
     _shape.Texture = _texture;
     _shape.Origin = new Vector2f(_texture.Size.X, _texture.Size.Y) / 2f;
 }
Пример #28
0
        public override void loadContent()
        {
            float logoScale;
            CharacterClass[] characterClasses = (CharacterClass[])Enum.GetValues(typeof(CharacterClass));

            _logoTexture = ResourceManager.getResource<Texture>("logo_1");
            _logoShape = new RectangleShape();
            _logoShape.Texture = _logoTexture;
            _logoShape.Size = new Vector2f(_logoTexture.Size.X, _logoTexture.Size.Y);
            logoScale = Game.window.GetView().Size.X / (float)_logoTexture.Size.X;
            _logoShape.Scale = new Vector2f(logoScale, logoScale);

            _classTextures = new Dictionary<CharacterClass, Texture>();
            for (int i = 0; i < characterClasses.Length; i++)
            {
                CharacterClass characterClass = characterClasses[i];

                _classTextures.Add(characterClass, new Texture("resources/ui/class_icons/" + characterClass.ToString().ToLower() + ".png"));
            }

            _allPlayerData = PlayerDataManager.getAllPlayerData();
            _shapes = new List<RectangleShape>();
            _labels = new List<Text>();
            _font = ResourceManager.getResource<Font>("gooddog_font");
            _characterIconRows = new List<List<RectangleShape>>();
            foreach (XElement playerData in _allPlayerData)
            {
                RectangleShape shape = new RectangleShape();
                string text = "player_" + playerData.Attribute("uid").Value;
                Text label = new Text(text, _font, 24);
                List<RectangleShape> characterIcons = new List<RectangleShape>();

                shape.Position = new Vector2f(128, (float)_logoShape.Texture.Size.Y * _logoShape.Scale.Y + 64 + _shapes.Count * 64);
                shape.Size = new Vector2f(340, 48);
                shape.FillColor = Color.Blue;

                label.Position = shape.Position + new Vector2f(24f, 8f);
                label.Color = Color.White;

                _shapes.Add(shape);
                _labels.Add(label);

                foreach (XElement characterData in playerData.Elements("Character"))
                {
                    CharacterClass characterClass = (CharacterClass)Enum.Parse(typeof(CharacterClass), characterData.Attribute("class").Value);
                    RectangleShape rectangleShape = new RectangleShape();

                    rectangleShape.Texture = _classTextures[characterClass];
                    rectangleShape.Size = new Vector2f(rectangleShape.Texture.Size.X, rectangleShape.Texture.Size.Y);
                    rectangleShape.Scale = new Vector2f(0.5f, 0.5f);
                    rectangleShape.Position = label.Position + new Vector2f(128 + 48 * characterIcons.Count, 0);

                    characterIcons.Add(rectangleShape);
                }

                _characterIconRows.Add(characterIcons);
            }
        }
Пример #29
0
        public UnitPictureBoxRenderer(UnitPictureBox data)
        {
            this.data = data;
            frame = new RectangleShape(data.Scale);
            frame.Position = data.Position;
            frame.FillColor = data.FillColor;

            curentPicture = new Sprite(new Texture(128, 128));
        }
Пример #30
0
 public ContextMenu()
 {
     options = new List<FastText>();
     clickActions = new List<Action>();
     Position = new Vector2f(0, 0);
     isVisible = false;
     shape = new RectangleShape();
     shape.FillColor = Colors.Gray;
 }
Пример #31
0
 public override void Remove()
 {
     base.Remove();
     if (shpBackground != null)
     {
         shpBackground.Dispose();
         shpBackground = null;
     }
 }
Пример #32
0
 public Entity(Texture tex)
 {
     texture = tex;
     rect = new RectangleShape();
     tex.Smooth = false;
     rect.TextureRect = new IntRect(0, 0, 16, 16);
     rect.Size = new Vector2f(32, 32);
     rect.Origin = new Vector2f(16, 16);
 }
Пример #33
0
        public override void Draw(RenderTarget rt)
        {
            var shape = new RectangleShape(Size);
            shape.FillColor = new Color(255, 255, 255, 128);
            shape.Position = Position;

            rt.Draw(shape);
            rt.Draw(text);
        }
Пример #34
0
 public GameplayStateView(GameplayState gameplayState)
 {
     _gameplayState = gameplayState;
     _background    = new Sfg.RectangleShape(new Sfs.Vector2f(Game.Resolution.X, Game.Resolution.Y))
     {
         FillColor = new Sfg.Color(25, 25, 112),
         Position  = new Sfs.Vector2f(-680 / 2f, -320 / 2f)
     };
     _score = new Sfg.Text(0.ToString(), new Sfg.Font(FontFilePath), CharacterSize)
     {
         Position = new Sfs.Vector2f(400, 0)
     };
 }
Пример #35
0
        public void DrawTexture(SFML.Graphics.Texture image, int x, int y, int rect_x, int rect_y, int rect_width, int rect_height, int width, int height, bool selected, int Transparency, bool fliph = false, bool flipv = false, int rotation = 0, Color?color = null)
        {
            if (!IsObjectOnScreen(x, y, width, height) || image == null)
            {
                return;
            }

            var zoom = GetZoom();

            int real_x = (int)(x * zoom);
            int real_y = (int)(y * zoom);

            SFML.System.Vector2f size     = new SFML.System.Vector2f(rect_width, rect_height);
            SFML.System.Vector2f center   = new SFML.System.Vector2f(size.X / 2, size.Y / 2);
            SFML.System.Vector2f position = new SFML.System.Vector2f(real_x + center.X, real_y + center.Y);


            var textureRect = new IntRect(rect_x, rect_y, width, height);



            if (fliph || flipv)
            {
                if (fliph)
                {
                    var temp = textureRect.Left;
                    textureRect.Left  = temp + textureRect.Width;
                    textureRect.Width = -textureRect.Width;
                }
                if (flipv)
                {
                    var temp = textureRect.Top;
                    textureRect.Top    = temp + textureRect.Height;
                    textureRect.Height = -textureRect.Height;
                }
            }



            SFML.Graphics.RectangleShape rect = new SFML.Graphics.RectangleShape();
            rect.Position    = position;
            rect.Origin      = center;
            rect.Rotation    = rotation;
            rect.Size        = size;
            rect.Texture     = image;
            rect.FillColor   = GetTransparency(color, Transparency);
            rect.TextureRect = textureRect;
            RenderWindow.Draw(rect);
        }
Пример #36
0
 ////////////////////////////////////////////////////////////
 /// <summary>
 /// Construct the shape from another shape
 /// </summary>
 /// <param name="copy">Shape to copy</param>
 ////////////////////////////////////////////////////////////
 public RectangleShape(RectangleShape copy) :
     base(copy)
 {
     Size = copy.Size;
 }
Пример #37
0
        protected override void UpdateDrawable()
        {
            base.UpdateDrawable();

            if (isCircle)
            {
                var circle = new SFML.Graphics.CircleShape(radius);
                circle.OutlineThickness = OutlineThickness;
                circle.OutlineColor     = OutlineColor.SFMLColor;
                circle.FillColor        = Color.SFMLColor;
                circle.SetPointCount((uint)CirclePointCount);
                SFMLDrawable = circle;
                Width        = (int)circle.GetLocalBounds().Width;
                Height       = (int)circle.GetLocalBounds().Height;
            }
            else
            {
                if (isShape)
                {
                    var rect = new SFML.Graphics.RectangleShape(new Vector2f(rectWidth, rectHeight));
                    rect.OutlineColor     = OutlineColor.SFMLColor;
                    rect.OutlineThickness = OutlineThickness;
                    rect.FillColor        = Color.SFMLColor;
                    SFMLDrawable          = rect;
                    Width  = (int)rect.GetLocalBounds().Width;
                    Height = (int)rect.GetLocalBounds().Height;
                }
                else
                {
                    SFMLVertices.Clear();

                    float x1, y1, x2, y2, u1, v1, u2, v2, cx1, cy1, cx2, cy2;

                    cx1 = ClippingRegion.Left;
                    cy1 = ClippingRegion.Top;
                    cx2 = ClippingRegion.Right;
                    cy2 = ClippingRegion.Bottom;

                    x1 = Util.Max(0, cx1);
                    u1 = TextureLeft + x1;

                    if (FlippedX)
                    {
                        u1 = TextureRegion.Width - u1 + TextureLeft + TextureRegion.Left;
                    }

                    y1 = Util.Max(0, cy1);
                    v1 = TextureTop + y1;

                    if (FlippedY)
                    {
                        v1 = TextureRegion.Height - v1 + TextureTop + TextureRegion.Top;
                    }

                    x2 = Util.Min(TextureRegion.Right, cx2);
                    u2 = TextureLeft + x2;

                    if (FlippedX)
                    {
                        u2 = TextureRegion.Width - u2 + TextureLeft + TextureRegion.Left;
                    }

                    y2 = Util.Min(TextureRegion.Bottom, cy2);
                    v2 = TextureTop + y2;

                    if (FlippedY)
                    {
                        v2 = TextureRegion.Height - v2 + TextureTop + TextureRegion.Top;
                    }

                    SFMLVertices.Append(x1, y1, Color, u1, v1);
                    SFMLVertices.Append(x1, y2, Color, u1, v2);
                    SFMLVertices.Append(x2, y2, Color, u2, v2);
                    SFMLVertices.Append(x2, y1, Color, u2, v1);
                }
            }
        }