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

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

public Initialize ( GameMain gameMain, string identifier, string &reason ) : bool
gameMain GameMain
identifier string
reason string
Результат bool
        public bool Initialize(GameMain gameMain, string identifier, out string reason)
        {
            _isExplored = false;
            _isOwnedSystem = false;
            if (!base.Initialize(gameMain.ScreenWidth - 300, gameMain.ScreenHeight / 2 - 240, 300, 480, StretchableImageType.ThinBorderBG, gameMain, true, gameMain.Random, out reason))
            {
                return false;
            }
            _infrastructureIcon = SpriteManager.GetSprite("InfrastructureIcon", gameMain.Random);
            _defenseIcon = SpriteManager.GetSprite("MilitaryIcon", gameMain.Random);
            _researchIcon = SpriteManager.GetSprite("ResearchIcon", gameMain.Random);
            _environmentIcon = SpriteManager.GetSprite("EnvironmentIcon", gameMain.Random);
            _constructionIcon = SpriteManager.GetSprite("ConstructionIcon", gameMain.Random);

            if (_infrastructureIcon == null || _defenseIcon == null || _researchIcon == null || _environmentIcon == null || _constructionIcon == null)
            {
                reason = "One or more of the following sprites does not exist: InfrastructureIcon, MilitaryIcon, ResearchIcon, EnvironmentIcon, and/or ConstructionIcon";
                return false;
            }

            _name = new BBSingleLineTextBox();
            if (!_name.Initialize(string.Empty, _xPos + 10, _yPos + 15, 280, 35, false, gameMain.Random, out reason))
            {
                return false;
            }
            _generalPurposeBackground = new BBStretchableImage();
            _infrastructureBackground = new BBStretchableImage();
            _researchBackground = new BBStretchableImage();
            _environmentBackground = new BBStretchableImage();
            _defenseBackground = new BBStretchableImage();
            _constructionProjectButton = new BBStretchButton();
            _popLabel = new BBLabel();
            _terrainLabel = new BBLabel();
            _productionLabel = new BBLabel();

            _infrastructureLabel = new BBLabel();
            _researchLabel = new BBLabel();
            _environmentLabel = new BBLabel();
            _defenseLabel = new BBLabel();
            _constructionLabel = new BBLabel();

            _generalPurposeText = new BBTextBox();
            _transferLabel = new BBLabel();

            _infrastructureSlider = new BBScrollBar();
            _researchSlider = new BBScrollBar();
            _environmentSlider = new BBScrollBar();
            _defenseSlider = new BBScrollBar();
            _constructionSlider = new BBScrollBar();
            _popTransferSlider = new BBScrollBar();

            _infrastructureLockButton = new BBButton();
            _researchLockButton = new BBButton();
            _environmentLockButton = new BBButton();
            _defenseLockButton = new BBButton();
            _constructionLockButton = new BBButton();

            _relocateToButton = new BBButton();
            _transferToButton = new BBButton();

            if (!_generalPurposeBackground.Initialize(_xPos + 10, _yPos + 130, 280, 300, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_generalPurposeText.Initialize(_xPos + 20, _yPos + 140, 260, 260, true, false, "PlanetUIText" + identifier, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_infrastructureBackground.Initialize(_xPos + 10, _yPos + 130, 280, 60, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_researchBackground.Initialize(_xPos + 10, _yPos + 190, 280, 60, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_environmentBackground.Initialize(_xPos + 10, _yPos + 250, 280, 60, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_defenseBackground.Initialize(_xPos + 10, _yPos + 310, 280, 60, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_constructionProjectButton.Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 10, _yPos + 370, 280, 60, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_terrainLabel.Initialize(_xPos + 55, _yPos + 60, string.Empty, System.Drawing.Color.White, out reason))
            {
                return false;
            }
            if (!_popLabel.Initialize(_xPos + 55, _yPos + 80, string.Empty, System.Drawing.Color.White, out reason))
            {
                return false;
            }
            if (!_productionLabel.Initialize(_xPos + 55, _yPos + 100, string.Empty, System.Drawing.Color.White, out reason))
            {
                return false;
            }

            if (!_infrastructureLabel.Initialize(_xPos + 65, _yPos + 140, string.Empty, System.Drawing.Color.White, out reason))
            {
                return false;
            }
            if (!_infrastructureSlider.Initialize(_xPos + 65, _yPos + 160, 200, 0, 100, true, true, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_infrastructureLockButton.Initialize("LockBG", "LockFG", string.Empty, ButtonTextAlignment.CENTER, _xPos + 267, _yPos + 160, 16, 16, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_researchLabel.Initialize(_xPos + 65, _yPos + 200, string.Empty, System.Drawing.Color.White, out reason))
            {
                return false;
            }
            if (!_researchSlider.Initialize(_xPos + 65, _yPos + 220, 200, 0, 100, true, true, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_researchLockButton.Initialize("LockBG", "LockFG", string.Empty, ButtonTextAlignment.CENTER, _xPos + 267, _yPos + 220, 16, 16, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_environmentLabel.Initialize(_xPos + 65, _yPos + 260, string.Empty, System.Drawing.Color.White, out reason))
            {
                return false;
            }
            if (!_environmentSlider.Initialize(_xPos + 65, _yPos + 280, 200, 0, 100, true, true, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_environmentLockButton.Initialize("LockBG", "LockFG", string.Empty, ButtonTextAlignment.CENTER, _xPos + 267, _yPos + 280, 16, 16, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_defenseLabel.Initialize(_xPos + 65, _yPos + 320, string.Empty, System.Drawing.Color.White, out reason))
            {
                return false;
            }
            if (!_defenseSlider.Initialize(_xPos + 65, _yPos + 340, 200, 0, 100, true, true, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_defenseLockButton.Initialize("LockBG", "LockFG", string.Empty, ButtonTextAlignment.CENTER, _xPos + 267, _yPos + 340, 16, 16, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_constructionLabel.Initialize(_xPos + 65, _yPos + 380, string.Empty, System.Drawing.Color.White, out reason))
            {
                return false;
            }
            if (!_constructionSlider.Initialize(_xPos + 65, _yPos + 400, 200, 0, 100, true, true, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_constructionLockButton.Initialize("LockBG", "LockFG", string.Empty, ButtonTextAlignment.CENTER, _xPos + 267, _yPos + 400, 16, 16, gameMain.Random, out reason))
            {
                return false;
            }

            if (!_transferLabel.Initialize(_xPos + 20, _yPos + 370, string.Empty, System.Drawing.Color.White, out reason))
            {
                return false;
            }
            if (!_popTransferSlider.Initialize(_xPos + 20, _yPos + 400, 260, 0, 1, true, true, gameMain.Random, out reason))
            {
                return false;
            }

            if (!_relocateToButton.Initialize("RelocateToBG", "RelocateToFG", string.Empty, ButtonTextAlignment.CENTER, _xPos + 130, _yPos + 435, 75, 35, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_relocateToButton.SetToolTip("RelocateToolTip" + identifier, "Set a friendly system as the destination of newly built ships", gameMain.ScreenWidth, gameMain.ScreenHeight, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_transferToButton.Initialize("TransferToBG", "TransferToFG", string.Empty, ButtonTextAlignment.CENTER, _xPos + 215, _yPos + 435, 75, 35, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_transferToButton.SetToolTip("TransferToToolTip" + identifier, "Send up to half of the population to another occupied system", gameMain.ScreenWidth, gameMain.ScreenHeight, gameMain.Random, out reason))
            {
                return false;
            }

            reason = null;
            return true;
        }

Usage Example

        public bool Initialize(GameMain gameMain, out string reason)
        {
            _gameMain = gameMain;
            _camera   = new Camera(gameMain.Galaxy.GalaxySize * 60, gameMain.Galaxy.GalaxySize * 60, gameMain.ScreenWidth, gameMain.ScreenHeight);
            _camera.CenterCamera(_camera.Width / 2, _camera.Height / 2, _camera.MaxZoom);

            _updateStep = 0;

            _exploredSystemsThisTurn   = new Dictionary <Empire, List <StarSystem> >();
            _colonizableFleetsThisTurn = new Dictionary <Empire, List <Fleet> >();
            _newResearchTopicsNeeded   = new Dictionary <Empire, List <TechField> >();

            _systemInfoWindow = new SystemInfoWindow();
            if (!_systemInfoWindow.Initialize(gameMain, out reason))
            {
                return(false);
            }

            _systemView = new SystemView();
            if (!_systemView.Initialize(gameMain, "ProcessingScreen", out reason))
            {
                return(false);
            }

            _colonizeScreen = new ColonizeScreen();
            if (!_colonizeScreen.Initialize(gameMain, out reason))
            {
                return(false);
            }

            _researchPrompt = new ResearchPrompt();
            if (!_researchPrompt.Initialize(gameMain, out reason))
            {
                return(false);
            }

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

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