public bool Initialize(GameMain gameMain, out string reason)
        {
            _gameMain = gameMain;

            if (!base.Initialize((gameMain.ScreenWidth / 2) - 320, (gameMain.ScreenHeight / 2) - 320, 640, 640, StretchableImageType.MediumBorder, gameMain, false, gameMain.Random, out reason))
            {
                return false;
            }
            _randomSprite = SpriteManager.GetSprite("RandomRace", gameMain.Random);
            if (_randomSprite == null)
            {
                reason = "RandomRace sprite does not exist.";
                return false;
            }

            _raceButtons = new BBStretchButton[15];
            _raceScrollBar = new BBScrollBar();
            _raceBackground = new BBStretchableImage();
            _raceDescription = new BBTextBox();
            _okButton = new BBStretchButton();
            _raceManager = gameMain.RaceManager;

            for (int i = 0; i < _raceButtons.Length; i++)
            {
                _raceButtons[i] = new BBStretchButton();
                if (!_raceButtons[i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 10, _yPos + 10 + (i * 40), 280, 40, gameMain.Random, out reason))
                {
                    return false;
                }
            }
            //Add 1 for the random race option
            int scrollValue = (_raceManager.Races.Count + 1) < _raceButtons.Length ? _raceButtons.Length : (_raceManager.Races.Count + 1);
            if (!_raceScrollBar.Initialize(_xPos + 290, _yPos + 10, 600, _raceButtons.Length, scrollValue, false, false, gameMain.Random, out reason))
            {
                return false;
            }
            _maxVisible = (_raceManager.Races.Count + 1) > _raceButtons.Length ? _raceButtons.Length : (_raceManager.Races.Count + 1);
            if (_raceManager.Races.Count < 15)
            {
                _raceScrollBar.SetEnabledState(false);
            }
            if (!_raceBackground.Initialize(_xPos + 310, _yPos + 10, 310, 550, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_raceDescription.Initialize(_xPos + 315, _yPos + 325, 300, 215, true, true, "RaceSelectionDescriptionTextBox", gameMain.Random, out reason))
            {
                return false;
            }
            if (!_okButton.Initialize("Select Race", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 310, _yPos + 570, 310, 40, gameMain.Random, out reason))
            {
                return false;
            }
            RefreshRaceLabels();
            RefreshRaceDescription();
            reason = null;
            return true;
        }
Beispiel #2
0
        public bool Initalize(int screenWidth, int screenHeight, DirectoryInfo dataSet, bool showTutorial, Form parentForm, out string reason)
        {
            _parentForm = parentForm;

            Random = new Random();

            MousePos = new Point();

            ScreenWidth = screenWidth;
            ScreenHeight = screenHeight;
            GameDataSet = dataSet;

            Galaxy = new Galaxy();
            EmpireManager = new EmpireManager(this);

            ShipShader = GorgonLibrary.Graphics.FXShader.FromFile("ColorShader.fx", GorgonLibrary.Graphics.ShaderCompileOptions.OptimizationLevel3);
            StarShader = GorgonLibrary.Graphics.FXShader.FromFile("StarShader.fx", GorgonLibrary.Graphics.ShaderCompileOptions.OptimizationLevel3);

            if (!SpriteManager.Initialize(GameDataSet, out reason))
            {
                return false;
            }
            if (!FontManager.Initialize(GameDataSet, out reason))
            {
                return false;
            }
            RaceManager = new RaceManager();
            if (!RaceManager.Initialize(GameDataSet, Random, out reason))
            {
                return false;
            }
            AIManager = new AIManager();
            if (!AIManager.Initialize(GameDataSet, out reason))
            {
                return false;
            }
            MasterTechnologyManager = new MasterTechnologyManager();
            if (!MasterTechnologyManager.Initialize(this, out reason))
            {
                return false;
            }
            _mainGameMenu = new MainGameMenu();
            if (!_mainGameMenu.Initialize(this, out reason))
            {
                return false;
            }

            _screenInterface = _mainGameMenu;
            _currentScreen = Screen.MainMenu;

            _situationReport = new SituationReport(this);

            Cursor = SpriteManager.GetSprite("Cursor", Random);
            if (Cursor == null)
            {
                reason = "Cursor is not defined in sprites.xml";
                return false;
            }

            reason = string.Empty;
            return true;
        }