Beyond_Beyaan.BBUniStretchableImage.Initialize C# (CSharp) Метод

Initialize() публичный Метод

public Initialize ( int x, int y, int width, int height, int mainLength, int stretchLength, bool isHorizontal, List sections, Random r, string &reason ) : bool
x int
y int
width int
height int
mainLength int
stretchLength int
isHorizontal bool
sections List
r System.Random
reason string
Результат bool
        public bool Initialize(int x, int y, int width, int height, int mainLength, int stretchLength, bool isHorizontal, List<string> sections, Random r, out string reason)
        {
            this.x = x;
            this.y = y;
            this.width = width;
            this.height = height;
            this.mainLength = mainLength;
            this.stretchLength = stretchLength;
            this.sections = new List<BBSprite>();
            foreach (string spriteName in sections)
            {
                BBSprite sprite = SpriteManager.GetSprite(spriteName, r);
                if (sprite == null)
                {
                    reason = string.Format("Can't find sprite \"{0}\".", spriteName);
                    return false;
                }
                this.sections.Add(sprite);
            }
            this.isHorizontal = isHorizontal;
            if (isHorizontal)
            {
                stretchAmount = (width - (mainLength * 2));
            }
            else
            {
                stretchAmount = (height - (mainLength * 2));
            }

            if (stretchAmount < 0)
            {
                stretchAmount = 0;
            }

            reason = null;
            return true;
        }

Usage Example

Пример #1
0
        public bool Initialize(List<string> backgroundSections, List<string> foregroundSections, bool isHorizontal, string buttonText, ButtonTextAlignment alignment, int xPos, int yPos, int width, int height, int fixedSize, int variableSize, Random r, out string reason)
        {
            _xPos = xPos;
            _yPos = yPos;
            _width = width;
            _height = height;
            _fixedSize = fixedSize;
            _variableSize = variableSize;
            _alignment = alignment;

            backgroundImage = new BBUniStretchableImage();
            foregroundImage = new BBUniStretchableImage();

            if (!backgroundImage.Initialize(xPos, yPos, width, height, fixedSize, variableSize, isHorizontal, backgroundSections, r, out reason))
            {
                return false;
            }
            if (!foregroundImage.Initialize(xPos, yPos, width, height, fixedSize, variableSize, isHorizontal, foregroundSections, r, out reason))
            {
                return false;
            }

            _label = new BBLabel();
            if (!_label.Initialize(0, 0, buttonText, Color.White, out reason))
            {
                return false;
            }

            Reset();

            reason = null;
            return true;
        }