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

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

public Initialize ( GameMain gameMain, string &reason ) : bool
gameMain GameMain
reason string
Результат bool
        public bool Initialize(GameMain gameMain, out string reason)
        {
            int x = (gameMain.ScreenWidth / 2) - 533;
            int y = (gameMain.ScreenHeight / 2) - 300;

            if (!Initialize(x, y, 1066, 600, StretchableImageType.MediumBorder, gameMain, false, gameMain.Random, out reason))
            {
                return false;
            }

            x += 20;
            y += 20;

            _columnHeaders = new BBStretchButton[8];
            for (int i = 0; i < _columnHeaders.Length; i++)
            {
                _columnHeaders[i] = new BBStretchButton();
            }
            _columnCells = new BBStretchButton[8][];
            for (int i = 0; i < _columnCells.Length; i++)
            {
                _columnCells[i] = new BBStretchButton[13];
                for (int j = 0; j < _columnCells[i].Length; j++)
                {
                    _columnCells[i][j] = new BBStretchButton();
                }
            }

            if (!_columnHeaders[0].Initialize("Planet", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonBG, x, y, 280, 30, _gameMain.Random, out reason))
            {
                return false;
            }
            for (int i = 0; i < 13; i++)
            {
                if (!_columnCells[0][i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x, y + 30 + (i * 30), 280, 30, _gameMain.Random, out reason))
                {
                    return false;
                }
            }

            x += 280;
            if (!_columnHeaders[1].Initialize("Population", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonBG, x, y, 90, 30, _gameMain.Random, out reason))
            {
                return false;
            }
            for (int i = 0; i < 13; i++)
            {
                if (!_columnCells[1][i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x, y + 30 + (i * 30), 90, 30, _gameMain.Random, out reason))
                {
                    return false;
                }
            }

            x += 90;
            if (!_columnHeaders[2].Initialize("Buildings", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonBG, x, y, 90, 30, _gameMain.Random, out reason))
            {
                return false;
            }
            for (int i = 0; i < 13; i++)
            {
                if (!_columnCells[2][i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x, y + 30 + (i * 30), 90, 30, _gameMain.Random, out reason))
                {
                    return false;
                }
            }

            x += 90;
            if (!_columnHeaders[3].Initialize("Bases", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonBG, x, y, 80, 30, _gameMain.Random, out reason))
            {
                return false;
            }
            for (int i = 0; i < 13; i++)
            {
                if (!_columnCells[3][i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x, y + 30 + (i * 30), 80, 30, _gameMain.Random, out reason))
                {
                    return false;
                }
            }

            x += 80;
            if (!_columnHeaders[4].Initialize("Waste", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonBG, x, y, 80, 30, _gameMain.Random, out reason))
            {
                return false;
            }
            for (int i = 0; i < 13; i++)
            {
                if (!_columnCells[4][i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x, y + 30 + (i * 30), 80, 30, _gameMain.Random, out reason))
                {
                    return false;
                }
            }

            x += 80;
            if (!_columnHeaders[5].Initialize("Industry", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonBG, x, y, 80, 30, _gameMain.Random, out reason))
            {
                return false;
            }
            for (int i = 0; i < 13; i++)
            {
                if (!_columnCells[5][i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x, y + 30 + (i * 30), 80, 30, _gameMain.Random, out reason))
                {
                    return false;
                }
            }

            x += 80;
            if (!_columnHeaders[6].Initialize("Constructing", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonBG, x, y, 250, 30, _gameMain.Random, out reason))
            {
                return false;
            }
            for (int i = 0; i < 13; i++)
            {
                if (!_columnCells[6][i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x, y + 30 + (i * 30), 250, 30, _gameMain.Random, out reason))
                {
                    return false;
                }
            }

            x += 250;
            if (!_columnHeaders[7].Initialize("Notes", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonBG, x, y, 60, 30, _gameMain.Random, out reason))
            {
                return false;
            }
            for (int i = 0; i < 13; i++)
            {
                if (!_columnCells[7][i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x, y + 30 + (i * 30), 60, 30, _gameMain.Random, out reason))
                {
                    return false;
                }
            }
            x += 60;
            _scrollBar = new BBScrollBar();
            if (!_scrollBar.Initialize(x, y + 30, 390, 13, 13, false, false, _gameMain.Random, out reason))
            {
                return false;
            }

            _expensesBackground = new BBStretchableImage();
            _incomeBackground = new BBStretchableImage();
            _reserves = new BBStretchableImage();

            _expenseTitle = new BBLabel();
            _incomeTitle = new BBLabel();

            _expenses = new BBStretchButton[4];
            _expenseLabels = new BBLabel[4];
            _incomes = new BBStretchButton[2];
            _incomeLabels = new BBLabel[2];
            for (int i = 0; i < 4; i++)
            {
                _expenses[i] = new BBStretchButton();
                _expenseLabels[i] = new BBLabel();
            }
            for (int i = 0; i < 2; i++)
            {
                _incomes[i] = new BBStretchButton();
                _incomeLabels[i] = new BBLabel();
            }

            x = (gameMain.ScreenWidth / 2) - 513;
            y = (gameMain.ScreenHeight / 2) + 143;

            if (!_expensesBackground.Initialize(x, y, 476, 140, StretchableImageType.ThinBorderBG, _gameMain.Random, out reason))
            {
                return false;
            }
            if (!_expenseTitle.Initialize(0, 0, "Expenses", Color.Gold, "LargeComputerFont", out reason))
            {
                return false;
            }
            _expenseTitle.MoveTo((int)(x + 238 - _expenseTitle.GetWidth() / 2), y + 5);
            if (!_expenses[0].Initialize("Ships", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 10, y + 50,  228, 40, _gameMain.Random, out reason))
            {
                return false;
            }
            _expenses[0].SetTextColor(Color.Orange, Color.Empty);
            if (!_expenseLabels[0].Initialize(x + 228, y + 65, string.Empty, Color.White, out reason))
            {
                return false;
            }
            _expenseLabels[0].SetAlignment(true);
            if (!_expenses[1].Initialize("Bases", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 10, y + 90, 228, 40, _gameMain.Random, out reason))
            {
                return false;
            }
            _expenses[1].SetTextColor(Color.Orange, Color.Empty);
            if (!_expenseLabels[1].Initialize(x + 228, y + 105, string.Empty, Color.White, out reason))
            {
                return false;
            }
            _expenseLabels[1].SetAlignment(true);
            if (!_expenses[2].Initialize("Spying", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 238, y + 50, 228, 40, _gameMain.Random, out reason))
            {
                return false;
            }
            _expenses[2].SetTextColor(Color.Orange, Color.Empty);
            if (!_expenseLabels[2].Initialize(x + 456, y + 65, string.Empty, Color.White, out reason))
            {
                return false;
            }
            _expenseLabels[2].SetAlignment(true);
            if (!_expenses[3].Initialize("Security", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 238, y + 90, 228, 40, _gameMain.Random, out reason))
            {
                return false;
            }
            _expenses[3].SetTextColor(Color.Orange, Color.Empty);
            if (!_expenseLabels[3].Initialize(x + 456, y + 105, string.Empty, Color.White, out reason))
            {
                return false;
            }
            _expenseLabels[3].SetAlignment(true);
            x += 476;

            if (!_incomeBackground.Initialize(x, y, 250, 140, StretchableImageType.ThinBorderBG, _gameMain.Random, out reason))
            {
                return false;
            }
            if (!_incomeTitle.Initialize(0, 0, "Incomes", Color.Gold, "LargeComputerFont", out reason))
            {
                return false;
            }
            if (!_incomes[0].Initialize("Planets", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 10, y + 50, 230, 40, _gameMain.Random, out reason))
            {
                return false;
            }
            _incomes[0].SetTextColor(Color.Orange, Color.Empty);
            if (!_incomeLabels[0].Initialize(x + 230, y + 65, string.Empty, Color.White, out reason))
            {
                return false;
            }
            _incomeLabels[0].SetAlignment(true);
            if (!_incomes[1].Initialize("Trade", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 10, y + 90, 230, 40, _gameMain.Random, out reason))
            {
                return false;
            }
            _incomes[1].SetTextColor(Color.Orange, Color.Empty);
            if (!_incomeLabels[1].Initialize(x + 230, y + 105, string.Empty, Color.White, out reason))
            {
                return false;
            }
            _incomeLabels[1].SetAlignment(true);
            _incomeTitle.MoveTo((int)(x + 125 - _incomeTitle.GetWidth() / 2), y + 5);
            x += 250;

            if (!_reserves.Initialize(x, y, 300, 140, StretchableImageType.ThinBorderBG, _gameMain.Random, out reason))
            {
                return false;
            }
            _reserveSlider = new BBScrollBar();
            _reservesLabel = new BBLabel();
            _reservesAmount = new BBLabel();

            _transferSlider = new BBScrollBar();
            _transferLabel = new BBLabel();
            _transferAmount = new BBLabel();
            _transferReserves = new BBStretchButton();

            if (!_reservesLabel.Initialize(x + 10, y + 10, "Reserve:", Color.Orange, out reason))
            {
                return false;
            }
            if (!_reservesAmount.Initialize(x + 280, y + 10, string.Empty, Color.White, out reason))
            {
                return false;
            }
            if (!_reserveSlider.Initialize(x + 10, y + 33, 280, 0, 20, true, true, _gameMain.Random, out reason))
            {
                return false;
            }
            if (!_transferLabel.Initialize(x + 10, y + 51, "Amount to transfer:", Color.Orange, out reason))
            {
                return false;
            }
            if (!_transferAmount.Initialize(x + 280, y + 51, string.Empty, Color.White, out reason))
            {
                return false;
            }
            if (!_transferSlider.Initialize(x + 10, y + 72, 280, 0, 200, true, true, _gameMain.Random, out reason))
            {
                return false;
            }
            if (!_transferReserves.Initialize("Transfer reserves to selected planet", ButtonTextAlignment.CENTER, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 10, y + 95, 280, 35, _gameMain.Random, out reason))
            {
                return false;
            }
            _reservesAmount.SetAlignment(true);
            _transferAmount.SetAlignment(true);

            return true;
        }

Usage Example

Пример #1
0
        public bool Initialize(GameMain gameMain, out string reason)
        {
            _gameMain = gameMain;
            _pathSprite = SpriteManager.GetSprite("Path", _gameMain.Random);
            _fuelCircle = SpriteManager.GetSprite("FuelCircle", _gameMain.Random);
            _selectionSprites = new BBSprite[4];
            _selectionSprites[0] = SpriteManager.GetSprite("SelectionTL", _gameMain.Random);
            _selectionSprites[1] = SpriteManager.GetSprite("SelectionTR", _gameMain.Random);
            _selectionSprites[2] = SpriteManager.GetSprite("SelectionBL", _gameMain.Random);
            _selectionSprites[3] = SpriteManager.GetSprite("SelectionBR", _gameMain.Random);
            _showingFuelRange = false;
            _showingRadarRange = false;
            _showingOwners = false;

            _camera = new Camera(_gameMain.Galaxy.GalaxySize * 60, _gameMain.Galaxy.GalaxySize * 60, _gameMain.ScreenWidth, _gameMain.ScreenHeight);

            _starName = new RenderImage("starNameRendered", 1, 1, ImageBufferFormats.BufferRGB888A8);
            _starName.BlendingMode = BlendingModes.Modulated;

            _backBuffer = new RenderImage("galaxyBackBuffer", _gameMain.ScreenWidth, _gameMain.ScreenHeight, ImageBufferFormats.BufferRGB888A8);
            _backBuffer.BlendingMode = BlendingModes.Modulated;

            _systemView = new SystemView();
            if (!_systemView.Initialize(_gameMain, "GalaxyScreen", out reason))
            {
                return false;
            }
            _fleetView = new FleetView();
            if (!_fleetView.Initialize(_gameMain, out reason))
            {
                return false;
            }

            _taskBar = new TaskBar();
            if (!_taskBar.Initialize(_gameMain, out reason))
            {
                return false;
            }
            _inGameMenu = new InGameMenu();
            _researchScreen = new ResearchScreen();
            _shipDesignScreen = new ShipDesignScreen();
            _planetsView = new PlanetsView();
            _fleetListScreen = new FleetListScreen();
            if (!_inGameMenu.Initialize(_gameMain, out reason))
            {
                return false;
            }
            if (!_researchScreen.Initialize(_gameMain, out reason))
            {
                return false;
            }
            if (!_shipDesignScreen.Initialize(_gameMain, out reason))
            {
                return false;
            }
            if (!_planetsView.Initialize(_gameMain, out reason))
            {
                return false;
            }
            if (!_fleetListScreen.Initialize(_gameMain, out reason))
            {
                return false;
            }
            _inGameMenu.CloseWindow = CloseWindow;
            _researchScreen.CloseWindow = CloseWindow;
            _shipDesignScreen.CloseWindow = CloseWindow;
            _planetsView.CloseWindow = CloseWindow;
            _planetsView.CenterToSystem = CenterToSystem;
            _fleetListScreen.CloseWindow = CloseWindow;
            _fleetListScreen.SelectFleet = SelectFleet;

            _taskBar.ShowGameMenu = ShowInGameMenu;
            _taskBar.ShowResearchScreen = ShowResearchScreen;
            _taskBar.ShowShipDesignScreen = ShowShipDesignScreen;
            _taskBar.ShowPlanetsScreen = ShowPlanetsView;
            _taskBar.ShowFleetOverviewScreen = ShowFleetListScreen;
            _taskBar.EndTurn = CloseWindow;

            _travelETA = new BBLabel();
            _tentativeETA = new BBLabel();

            if (!_travelETA.Initialize(0, 0, "ETA", Color.White, out reason))
            {
                return false;
            }
            if (!_tentativeETA.Initialize(0, 0, "ETA", Color.White, out reason))
            {
                return false;
            }

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