Ejemplo n.º 1
0
        protected void InitializeBorderObjects()
        {
            _topLeftUiObject.Position = Position;
            Vector2 nextTopRowPosition = Position;

            nextTopRowPosition = new Vector2(nextTopRowPosition.X + _topLeftSprite.Width, nextTopRowPosition.Y);
            for (int i = 0; i < _frameWidth - 2; i++)
            {
                UiObject uiObject = new UiObject(_horizontalSprite, nextTopRowPosition, _rotate90CW);
                _topUiObjectRow.Add(uiObject);
                nextTopRowPosition = new Vector2(uiObject.Position.X + uiObject.Sprite.Width, uiObject.Position.Y);
            }

            _topRightUiObject.Position = nextTopRowPosition;
            Vector2 nextRightColumnPosition = new Vector2(nextTopRowPosition.X, nextTopRowPosition.Y + _topRightSprite.Height);

            for (int i = 0; i < _frameHeight - 2; i++)
            {
                UiObject uiObject = new UiObject(_verticalSprite, nextRightColumnPosition, 0f);
                this._rightUiObjectColumn.Add(uiObject);
                nextRightColumnPosition = new Vector2(uiObject.Position.X, uiObject.Position.Y + _verticalSprite.Height);
            }

            _bottomRightUiObject.Position = nextRightColumnPosition;
            Vector2 nextBottomRowPosition = new Vector2(nextRightColumnPosition.X - _bottomRightSprite.Width, nextRightColumnPosition.Y);

            for (int i = 0; i < _frameWidth - 2; i++)
            {
                UiObject uiObject = new UiObject(_horizontalSprite, nextBottomRowPosition, _rotate90CW);
                this._bottomUiObjectRow.Add(uiObject);
                nextBottomRowPosition = new Vector2(uiObject.Position.X - _horizontalSprite.Width, uiObject.Position.Y);
            }

            _bottomLeftUiObject.Position = nextBottomRowPosition;
            Vector2 nextLeftColumnPosition = new Vector2(nextBottomRowPosition.X, nextBottomRowPosition.Y - _bottomLeftSprite.Height);

            for (int i = 0; i < _frameHeight - 2; i++)
            {
                UiObject uiObject = new UiObject(_verticalSprite, nextLeftColumnPosition, 0f);
                this._leftUiObjectColumn.Add(uiObject);
                nextLeftColumnPosition = new Vector2(uiObject.Position.X, uiObject.Position.Y - _verticalSprite.Height);
            }
        }
Ejemplo n.º 2
0
        public UiFrame(GraphicsDeviceManager graphics, Vector2 position, int width, int height, Sprite horizontalSprite, Sprite verticalSprite, Sprite topLeftSprite, Sprite topRightSprite, Sprite bottomRightSprite, Sprite bottomLeftSprite, Color backgroundColor)
        {
            _graphics          = graphics;
            _frameWidth        = width;
            _frameHeight       = height;
            _horizontalSprite  = horizontalSprite;
            _verticalSprite    = verticalSprite;
            _topLeftSprite     = topLeftSprite;
            _topRightSprite    = topRightSprite;
            _bottomLeftSprite  = bottomLeftSprite;
            _bottomRightSprite = bottomRightSprite;
            _backgroundColor   = backgroundColor;

            Position = position;

            _topLeftUiObject     = new UiObject(_topLeftSprite, Position, 0f);
            _topRightUiObject    = new UiObject(_topRightSprite, Position, 0f);
            _bottomRightUiObject = new UiObject(_bottomRightSprite, Position, 0f);
            _bottomLeftUiObject  = new UiObject(_bottomLeftSprite, Position, 0f);

            ActualWidth += _topLeftSprite.Width;
            for (int i = 0; i < _frameWidth - 2; i++)
            {
                ActualWidth += _horizontalSprite.Width;
            }
            ActualWidth += _topRightSprite.Width;

            ActualHeight += _topLeftSprite.Height;
            for (int i = 0; i < _frameHeight - 2; i++)
            {
                ActualHeight += _verticalSprite.Height;
            }
            ActualHeight += _bottomLeftSprite.Height;

            _startScreenBackgroundPosition = Position;

            //ActualWidth = ActualWidth - (_topLeftSprite.Width);
            //ActualHeight = ActualHeight - (_topLeftSprite.Height * 2);
        }