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

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

public Initialize ( GameMain gameMain, string name, string &reason ) : bool
gameMain GameMain
name string
reason string
Результат bool
        public bool Initialize(GameMain gameMain, string name, out string reason)
        {
            _x = (gameMain.ScreenWidth / 2) - 430;
            _y = (gameMain.ScreenHeight / 2) - 300;
            if (!Initialize((gameMain.ScreenWidth / 2) - 450, (gameMain.ScreenHeight / 2) - 320, 900, 640, StretchableImageType.MediumBorder, gameMain, false, gameMain.Random, out reason))
            {
                return false;
            }
            _shipBackground = new BBStretchableImage(); //Used for sprite preview
            if (!_shipBackground.Initialize(0,0, 170, 170, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return false;
            }
            _shipBackgrounds = new BBStretchableImage[6];
            _beamBackgrounds = new BBStretchableImage[6];
            _missileBackgrounds = new BBStretchableImage[6];
            _attackBackgrounds = new BBStretchableImage[6];
            _hitPointsBackgrounds = new BBStretchableImage[6];
            _shieldBackgrounds = new BBStretchableImage[6];
            _galaxySpeedBackgrounds = new BBStretchableImage[6];
            _combatSpeedBackgrounds = new BBStretchableImage[6];
            _weaponsBackgrounds = new BBStretchableImage[6];
            _specialsBackgrounds = new BBStretchableImage[6];
            _scrapButtons = new BBButton[6];
            _shipNameLabels = new BBLabel[6];
            _beamDefLabels = new BBLabel[6];
            _beamDefValueLabels = new BBLabel[6];
            _missileDefLabels = new BBLabel[6];
            _missileDefValueLabels = new BBLabel[6];
            _attackLevelLabels = new BBLabel[6];
            _attackLevelValueLabels = new BBLabel[6];
            _hitPointsLabels = new BBLabel[6];
            _hitPointsValueLabels = new BBLabel[6];
            _shieldLabels = new BBLabel[6];
            _shieldValueLabels = new BBLabel[6];
            _galaxySpeedLabels = new BBLabel[6];
            _galaxySpeedValueLabels = new BBLabel[6];
            _combatSpeedLabels = new BBLabel[6];
            _combatSpeedValueLabels = new BBLabel[6];
            _costLabels = new BBLabel[6];
            _costValueLabels = new BBLabel[6];
            _amountLabels = new BBLabel[6];
            _amountValueLabels = new BBLabel[6];
            _weaponLabels = new BBLabel[6][];
            _specialLabels = new BBLabel[6][];
            for (int i = 0; i < 6; i++)
            {
                _shipBackgrounds[i] = new BBStretchableImage();
                _scrapButtons[i] = new BBButton();
                _shipNameLabels[i] = new BBLabel();
                _beamBackgrounds[i] = new BBStretchableImage();
                _missileBackgrounds[i] = new BBStretchableImage();
                _attackBackgrounds[i] = new BBStretchableImage();
                _hitPointsBackgrounds[i] = new BBStretchableImage();
                _shieldBackgrounds[i] = new BBStretchableImage();
                _galaxySpeedBackgrounds[i] = new BBStretchableImage();
                _combatSpeedBackgrounds[i] = new BBStretchableImage();
                _weaponsBackgrounds[i] = new BBStretchableImage();
                _specialsBackgrounds[i] = new BBStretchableImage();
                _beamDefLabels[i] = new BBLabel();
                _beamDefValueLabels[i] = new BBLabel();
                _missileDefLabels[i] = new BBLabel();
                _missileDefValueLabels[i] = new BBLabel();
                _attackLevelLabels[i] = new BBLabel();
                _attackLevelValueLabels[i] = new BBLabel();
                _hitPointsLabels[i] = new BBLabel();
                _hitPointsValueLabels[i] = new BBLabel();
                _shieldLabels[i] = new BBLabel();
                _shieldValueLabels[i] = new BBLabel();
                _galaxySpeedLabels[i] = new BBLabel();
                _galaxySpeedValueLabels[i] = new BBLabel();
                _combatSpeedLabels[i] = new BBLabel();
                _combatSpeedValueLabels[i] = new BBLabel();
                _costLabels[i] = new BBLabel();
                _costValueLabels[i] = new BBLabel();
                _amountLabels[i] = new BBLabel();
                _amountValueLabels[i] = new BBLabel();
                if (!_shipBackgrounds[i].Initialize(_x, _y + (i * 100), 860, 100, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
                {
                    return false;
                }
                if (!_shipNameLabels[i].Initialize(_x + 10, _y + 10 + (i * 100), string.Empty, Color.White, out reason))
                {
                    return false;
                }
                if (!_scrapButtons[i].Initialize("ScrapShipBG", "ScrapShipFG", string.Empty, ButtonTextAlignment.LEFT, _x + 250, _y + 5 + (i * 100), 75, 35, gameMain.Random, out reason))
                {
                    return false;
                }
                if (!_scrapButtons[i].SetToolTip(name + "ScrapShipToolTip" + i, "Scrap Ship Design", gameMain.ScreenWidth, gameMain.ScreenHeight, gameMain.Random, out reason))
                {
                    return false;
                }
                if (!_beamBackgrounds[i].Initialize(_x + 5, _y + 39 + (i * 100), 160, 28, StretchableImageType.TinyButtonBG, gameMain.Random, out reason))
                {
                    return false;
                }
                if (!_beamDefLabels[i].Initialize(_x + 10, _y + 43 + (i * 100), "Beam Defense:", Color.Orange, out reason))
                {
                    return false;
                }
                if (!_beamDefValueLabels[i].Initialize(_x + 155, _y + 43 + (i * 100), string.Empty, Color.White, out reason))
                {
                    return false;
                }
                if (!_missileBackgrounds[i].Initialize(_x + 5, _y + 66 + (i * 100), 160, 28, StretchableImageType.TinyButtonBG, gameMain.Random, out reason))
                {
                    return false;
                }
                if (!_missileDefLabels[i].Initialize(_x + 10, _y + 72 + (i * 100), "Missile Defense:", Color.Orange, out reason))
                {
                    return false;
                }
                if (!_missileDefValueLabels[i].Initialize(_x + 155, _y + 72 + (i * 100), string.Empty, Color.White, out reason))
                {
                    return false;
                }
                if (!_attackBackgrounds[i].Initialize(_x + 165, _y + 39 + (i * 100), 160, 28, StretchableImageType.TinyButtonBG, gameMain.Random, out reason))
                {
                    return false;
                }
                if (!_attackLevelLabels[i].Initialize(_x + 170, _y + 43 + (i * 100), "Attack Level:", Color.Orange, out reason))
                {
                    return false;
                }
                if (!_attackLevelValueLabels[i].Initialize(_x + 315, _y + 43 + (i * 100), string.Empty, Color.White, out reason))
                {
                    return false;
                }
                if (!_hitPointsBackgrounds[i].Initialize(_x + 165, _y + 66 + (i * 100), 160, 28, StretchableImageType.TinyButtonBG, gameMain.Random, out reason))
                {
                    return false;
                }
                if (!_hitPointsLabels[i].Initialize(_x + 170, _y + 72 + (i * 100), "Hit Points:", Color.Orange, out reason))
                {
                    return false;
                }
                if (!_hitPointsValueLabels[i].Initialize(_x + 315, _y + 72 + (i * 100), string.Empty, Color.White, out reason))
                {
                    return false;
                }
                if (!_shieldBackgrounds[i].Initialize(_x + 325, _y + 5 + (i * 100), 140, 35, StretchableImageType.TinyButtonBG, gameMain.Random, out reason))
                {
                    return false;
                }
                if (!_shieldLabels[i].Initialize(_x + 330, _y + 12 + (i * 100), "Shield Level:", Color.Orange, out reason))
                {
                    return false;
                }
                if (!_shieldValueLabels[i].Initialize(_x + 455, _y + 12 + (i * 100), string.Empty, Color.White, out reason))
                {
                    return false;
                }
                if (!_galaxySpeedBackgrounds[i].Initialize(_x + 325, _y + 39 + (i * 100), 140, 28, StretchableImageType.TinyButtonBG, gameMain.Random, out reason))
                {
                    return false;
                }
                if (!_galaxySpeedLabels[i].Initialize(_x + 330, _y + 43 + (i * 100), "Galaxy Speed:", Color.Orange, out reason))
                {
                    return false;
                }
                if (!_galaxySpeedValueLabels[i].Initialize(_x + 455, _y + 43 + (i * 100), string.Empty, Color.White, out reason))
                {
                    return false;
                }
                if (!_combatSpeedBackgrounds[i].Initialize(_x + 325, _y + 66 + (i * 100), 140, 28, StretchableImageType.TinyButtonBG, gameMain.Random, out reason))
                {
                    return false;
                }
                if (!_combatSpeedLabels[i].Initialize(_x + 330, _y + 72 + (i * 100), "Combat Speed:", Color.Orange, out reason))
                {
                    return false;
                }
                if (!_combatSpeedValueLabels[i].Initialize(_x + 455, _y + 72 + (i * 100), string.Empty, Color.White, out reason))
                {
                    return false;
                }
                if (!_weaponsBackgrounds[i].Initialize(_x + 470, _y + (i * 100), 200, 100, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
                {
                    return false;
                }
                if (!_specialsBackgrounds[i].Initialize(_x + 670, _y + (i * 100), 190, 100, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
                {
                    return false;
                }
                if (!_amountLabels[i].Initialize(_x + 675, _y + (i * 100) + 63, "Amt:", Color.Orange, out reason))
                {
                    return false;
                }
                if (!_amountValueLabels[i].Initialize(_x + 755, _y + (i * 100) + 63, string.Empty, Color.White, out reason))
                {
                    return false;
                }
                if (!_costLabels[i].Initialize(_x + 760, _y + (i * 100) + 63, "Cost: ", Color.Orange, out reason))
                {
                    return false;
                }
                if (!_costValueLabels[i].Initialize(_x + 855, _y + (i * 100) + 63, string.Empty, Color.White, out reason))
                {
                    return false;
                }
                _beamDefValueLabels[i].SetAlignment(true);
                _missileDefValueLabels[i].SetAlignment(true);
                _attackLevelValueLabels[i].SetAlignment(true);
                _hitPointsValueLabels[i].SetAlignment(true);
                _shieldValueLabels[i].SetAlignment(true);
                _galaxySpeedValueLabels[i].SetAlignment(true);
                _combatSpeedValueLabels[i].SetAlignment(true);
                _costValueLabels[i].SetAlignment(true);
                _amountValueLabels[i].SetAlignment(true);
                _weaponLabels[i] = new BBLabel[4];
                for (int j = 0; j < _weaponLabels[i].Length; j++)
                {
                    _weaponLabels[i][j] = new BBLabel();
                    if (!_weaponLabels[i][j].Initialize(_x + 475, _y + 7 + (i * 100 + j * 21), string.Empty, Color.White, out reason))
                    {
                        return false;
                    }
                }
                _specialLabels[i] = new BBLabel[3];
                for (int j = 0; j < _specialLabels[i].Length; j++)
                {
                    _specialLabels[i][j] = new BBLabel();
                    if (!_specialLabels[i][j].Initialize(_x + 675, _y + 7 + (i * 100 + j * 21), string.Empty, Color.White, out reason))
                    {
                        return false;
                    }
                }
            }

            reason = null;
            return true;
        }

Usage Example

Пример #1
0
        public bool Initialize(GameMain gameMain, out string reason)
        {
            _gameMain = gameMain;

            _x = (gameMain.ScreenWidth / 2) - 500;
            _y = (gameMain.ScreenHeight / 2) - 305;
            if (!Initialize((gameMain.ScreenWidth / 2) - 520, (gameMain.ScreenHeight / 2) - 320, 1040, 640, StretchableImageType.MediumBorder, gameMain, false, gameMain.Random, out reason))
            {
                return false;
            }

            _shipNames = new BBStretchButton[6];
            for (int i = 0; i < _shipNames.Length; i++)
            {
                _shipNames[i] = new BBStretchButton();
                if (!_shipNames[i].Initialize(string.Empty, ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _x + 80 + (150 * i), _y, 150, 40, _gameMain.Random, out reason))
                {
                    return false;
                }
            }

            _planetBackgrounds = new BBStretchButton[10];
            _planetNames = new BBLabel[10];
            _statusLabels = new BBLabel[11];
            _scrollBar = new BBScrollBar();

            _statusLabels[0] = new BBLabel();
            if (!_statusLabels[0].Initialize(_x, _y + 10, "Status", Color.White, out reason))
            {
                return false;
            }

            for (int i = 0; i < 10; i++)
            {
                _planetBackgrounds[i] = new BBStretchButton();
                if (!_planetBackgrounds[i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _x, _y + 40 + (50 * i), 980, 50, _gameMain.Random, out reason))
                {
                    return false;
                }
                _planetNames[i] = new BBLabel();
                if (!_planetNames[i].Initialize(_x + 5, _y + 65 + (50 * i), string.Empty, Color.GreenYellow, out reason))
                {
                    return false;
                }
                _statusLabels[i + 1] = new BBLabel();
                if (!_statusLabels[i + 1].Initialize(_x + 5, _y + 45 + (50 * i), string.Empty, Color.Orange, out reason))
                {
                    return false;
                }
            }

            _shipAmountLabels = new BBStretchButton[10][];
            for (int i = 0; i < _shipAmountLabels.Length; i++)
            {
                _shipAmountLabels[i] = new BBStretchButton[6];
                for (int j = 0; j < 6; j++)
                {
                    _shipAmountLabels[i][j] = new BBStretchButton();
                    if (!_shipAmountLabels[i][j].Initialize(string.Empty, ButtonTextAlignment.CENTER, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, _x + 80 + (150 * j), _y + 43 + (i * 50), 150, 25, _gameMain.Random, out reason))
                    {
                        return false;
                    }
                }
            }

            if (!_scrollBar.Initialize(_x + 980, _y + 40, 500, 10, 10, false, false, _gameMain.Random, out reason))
            {
                return false;
            }

            _maintenanceCostBackground = new BBStretchableImage();
            _maintenanceLabel = new BBLabel();
            _maintenanceAmountLabel = new BBLabel();
            _scrapButtons = new BBButton[6];
            for (int i = 0; i < _scrapButtons.Length; i++)
            {
                _scrapButtons[i] = new BBButton();
                if (!_scrapButtons[i].Initialize("ScrapShipBG", "ScrapShipFG", string.Empty, ButtonTextAlignment.LEFT, _x + 112 + (150 * i), _y + 540, 75, 35, gameMain.Random, out reason))
                {
                    return false;
                }
            }

            if (!_maintenanceCostBackground.Initialize(_x + 220, _y + 577, 280, 35, StretchableImageType.TinyButtonBG, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_maintenanceLabel.Initialize(_x + 225, _y + 585, "Maintenance Cost:", Color.Orange, out reason))
            {
                return false;
            }
            if (!_maintenanceAmountLabel.Initialize(_x + 495, _y + 585, string.Empty, Color.White, out reason))
            {
                return false;
            }
            _maintenanceAmountLabel.SetAlignment(true);

            _viewSpecsButton = new BBStretchButton();
            if (!_viewSpecsButton.Initialize("View Ship Specifications", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _x + 500, _y + 577, 280, 35, gameMain.Random, out reason))
            {
                return false;
            }

            _fleetSpecsWindow = new FleetSpecsWindow();
            if (!_fleetSpecsWindow.Initialize(gameMain, "FleetList", out reason))
            {
                return false;
            }
            _fleetSpecsShowing = false;

            reason = null;
            return true;
        }
All Usage Examples Of Beyond_Beyaan.Screens.FleetSpecsWindow::Initialize