示例#1
0
        public StarSystem(string name, int id, int x, int y, Color color, string description, Random r)
        {
            this.Sprite = SpriteManager.GetSprite("Star", r);
            this.name = name;
            this.x = x;
            this.y = y;
            this.size = 1;
            ID = id;

            Color = color;

            exploredBy = new List<Empire>();
            planets = new List<Planet>();

            //type = StarType.NORMAL;

            string reason;
            StarName = new BBLabel();
            StarName.Initialize(0, 0, name, Color.White, out reason);
            EmpiresWithFleetAdjacentLastTurn = new List<Empire>();
            EmpiresWithFleetAdjacentThisTurn = new List<Empire>();
            EmpiresWithPlanetsInThisSystem = new List<Empire>();
            OwnerPercentage = new Dictionary<Empire, float>();
        }
        public bool Initialize(int xPos, int yPos, int width, int min, int max, int initialAmount, Random r, out string reason)
        {
            _enabled = true;
            _upButtonEnabled = true;

            _width = width;

            _upButton = new BBButton();
            _downButton = new BBButton();
            _valueLabel = new BBLabel();

            if (!_upButton.Initialize("ScrollUpBGButton", "ScrollUpFGButton", string.Empty, ButtonTextAlignment.LEFT, xPos + width - 16, yPos, 16, 16, r, out reason))
            {
                return false;
            }
            if (!_downButton.Initialize("ScrollDownBGButton", "ScrollDownFGButton", string.Empty, ButtonTextAlignment.LEFT, xPos, yPos, 16, 16, r, out reason))
            {
                return false;
            }
            if (!_valueLabel.Initialize(xPos + width - 20, yPos, string.Empty, Color.White, out reason))
            {
                return false;
            }
            _valueLabel.SetAlignment(true);

            _minimum = min;
            _maximum = max;
            Value = initialAmount;
            CheckAmount(); //Just in case

            _incrementAmount = 1;

            return true;
        }
        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;
        }
        public bool Initialize(string buttonText, ButtonTextAlignment alignment, StretchableImageType background, StretchableImageType foreground, int xPos, int yPos, int width, int height, Random r, out string reason)
        {
            _xPos = xPos;
            _yPos = yPos;
            _width = width;
            _height = height;
            _alignment = alignment;

            _backgroundImage = new BBStretchableImage();
            _foregroundImage = new BBStretchableImage();

            if (!_backgroundImage.Initialize(xPos, yPos, width, height, background, r, out reason))
            {
                return false;
            }
            if (!_foregroundImage.Initialize(xPos, yPos, width, height, foreground, r, out reason))
            {
                return false;
            }

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

            Reset();
            _timeSinceClick = 10; //10 seconds will exceed any double-click max interval
            _doubleClicked = false;

            reason = null;
            return true;
        }
        public bool Initialize(string text, int x, int y, int width, int height, bool isReadOnly, Random r, out string reason)
        {
            xPos = x;
            yPos = y;
            this.width = width;
            this.height = height;
            HighlightColor = Color.FromArgb(125, 0, 125, 125);

            //Allows us to have transparency on our highlight rectangle
            Gorgon.Screen.BlendingMode = BlendingModes.Modulated;

            background = new BBStretchableImage();
            if (!background.Initialize(x, y, width, height, StretchableImageType.TextBox, r, out reason))
            {
                return false;
            }

            Text = string.Empty;
            this.text = new BBLabel();
            if (!this.text.Initialize(x + 6, y + 7, text, Color.White, out reason))
            {
                return false;
            }
            pressed = false;
            isSelected = false;
            blink = true;
            this.isReadOnly = isReadOnly;

            reason = null;
            return true;
        }
        public bool Initialize(string backgroundSprite, string foregroundSprite, string buttonText, string font, ButtonTextAlignment alignment, int xPos, int yPos, int width, int height, Random r, out string reason, int xTextOffset = 0, int yTextOffset = 0)
        {
            _backgroundSprite = SpriteManager.GetSprite(backgroundSprite, r);
            _foregroundSprite = SpriteManager.GetSprite(foregroundSprite, r);
            if (backgroundSprite == null || foregroundSprite == null)
            {
                reason = string.Format("One of those sprites does not exist in sprites.xml: \"{0}\" or \"{1}\"", backgroundSprite, foregroundSprite);
                return false;
            }
            _xPos = xPos;
            _yPos = yPos;
            _width = width;
            _height = height;
            _xTextOffset = xTextOffset;
            _yTextOffset = yTextOffset;
            _alignment = alignment;

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

            Reset();
            reason = null;
            return true;
        }