상속: WindowInterface
예제 #1
0
        public bool Initialize(GameMain gameMain, out string reason)
        {
            this._gameMain = gameMain;

            _showingSelection = false;
            _background = new BBStretchableImage();
            _playerBackground = new BBStretchableImage();
            _playerInfoBackground = new BBStretchableImage();
            _playerRaceButton = new BBStretchButton();
            _playerRaceDescription = new BBTextBox();
            _playerLabels = new BBLabel[3];
            _playerEmperorName = new BBSingleLineTextBox();
            _playerHomeworldName = new BBSingleLineTextBox();
            _AIBackground = new BBStretchableImage();
            _AIRaceButtons = new BBStretchButton[5];
            _raceSprites = new BBSprite[6];
            _playerRaces = new Race[6];
            _playerColors = new Color[6];
            _numberOfAILabel = new BBLabel();
            _numericUpDownAI = new BBNumericUpDown();
            _busyImage = new BBStretchableImage();
            _busyText = new BBLabel();
            _okButton = new BBStretchButton();
            _cancelButton = new BBStretchButton();

            _difficultyComboBox = new BBComboBox();
            _difficultyLabel = new BBLabel();

            _nebulaBackground = SpriteManager.GetSprite("TitleNebula", gameMain.Random);

            _playerColors[0] = Color.Blue;
            _playerColors[1] = Color.Red;
            _playerColors[2] = Color.Yellow;
            _playerColors[3] = Color.Green;
            _playerColors[4] = Color.Purple;
            _playerColors[5] = Color.Orange;

            _xPos = (gameMain.ScreenWidth / 2) - 440;
            _yPos = (gameMain.ScreenHeight / 2) - 340;
            if (_nebulaBackground == null)
            {
                reason = "TitleNebula sprite doesn't exist.";
                return false;
            }
            if (!_background.Initialize(_xPos, _yPos, 880, 680, StretchableImageType.MediumBorder, gameMain.Random, out reason))
            {
                return false;
            }

            if (!_playerBackground.Initialize(_xPos + 30, _yPos + 30, 820, 170, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_playerInfoBackground.Initialize(_xPos + 40, _yPos + 60, 295, 130, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_playerRaceButton.Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 340, _yPos + 40, 500, 150, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_playerRaceDescription.Initialize(_xPos + 485, _yPos + 51, 345, 130, true, true, "RaceDescriptionTextBox", gameMain.Random, out reason))
            {
                return false;
            }
            _playerLabels[0] = new BBLabel();
            if (!_playerLabels[0].Initialize(_xPos + 90, _yPos + 36, "Player Race Information", Color.White, out reason))
            {
                return false;
            }
            _playerLabels[1] = new BBLabel();
            if (!_playerLabels[1].Initialize(_xPos + 45, _yPos + 70, "Emperor Name:", Color.White, out reason))
            {
                return false;
            }
            if (!_playerEmperorName.Initialize(string.Empty, _xPos + 50, _yPos + 90, 275, 35, false, gameMain.Random, out reason))
            {
                return false;
            }
            _playerLabels[2] = new BBLabel();
            if (!_playerLabels[2].Initialize(_xPos + 45, _yPos + 125, "Homeworld Name:", Color.White, out reason))
            {
                return false;
            }
            if (!_playerHomeworldName.Initialize(string.Empty, _xPos + 50, _yPos + 145, 275, 35, false, gameMain.Random, out reason))
            {
                return false;
            }
            _playerRaceDescription.SetText("A random race will be chosen.  If the Emperor and/or Homeworld name fields are left blank, default race names for those will be used.");
            _randomRaceSprite = SpriteManager.GetSprite("RandomRace", gameMain.Random);
            if (_randomRaceSprite == null)
            {
                reason = "RandomRace sprite does not exist.";
                return false;
            }

            for (int i = 0; i < _raceSprites.Length; i++)
            {
                _raceSprites[i] = _randomRaceSprite;
            }

            if (!_AIBackground.Initialize(_xPos + 30, _yPos + 205, 820, 220, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_difficultyLabel.Initialize(_xPos + 40, _yPos + 220, "Difficulty Level:", Color.White, out reason))
            {
                return false;
            }
            List<string> difficultyItems = new List<string>
                                            {
                                                "Simple",
                                                "Easy",
                                                "Medium",
                                                "Hard",
                                                "Impossible"
                                            };
            if (!_difficultyComboBox.Initialize(difficultyItems, _xPos + 170, _yPos + 215, 200, 35, 5, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_numberOfAILabel.Initialize(_xPos + 730, _yPos + 220, "Number of Computer Players:", Color.White, out reason))
            {
                return false;
            }
            _numberOfAILabel.SetAlignment(true);
            if (!_numericUpDownAI.Initialize(_xPos + 735, _yPos + 222, 75, 1, 5, 5, gameMain.Random, out reason))
            {
                return false;
            }
            for (int i = 0; i < _AIRaceButtons.Length; i++)
            {
                _AIRaceButtons[i] = new BBStretchButton();
                if (!_AIRaceButtons[i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 40 + (i * 155), _yPos + 260, 150, 150, gameMain.Random, out reason))
                {
                    return false;
                }
            }

            _galaxyBackground = new BBStretchableImage();
            _galaxyComboBox = new BBComboBox();

            List<string> items = new List<string>();
            items.Add("Small Galaxy");
            items.Add("Medium Galaxy");
            items.Add("Large Galaxy");
            items.Add("Huge Galaxy");

            if (!_galaxyBackground.Initialize(_xPos + 30, _yPos + 430, 240, 235, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_galaxyComboBox.Initialize(items, _xPos + 30, _yPos + 430, 240, 35, 4, gameMain.Random, out reason))
            {
                return false;
            }

            _raceSelection = new RaceSelection();
            if (!_raceSelection.Initialize(gameMain, out reason))
            {
                return false;
            }
            _raceSelection.OnOkClick = OnRaceSelectionOKClick;

            _generatingGalaxy = false;
            if (!_busyImage.Initialize(gameMain.ScreenWidth / 2 - 100, gameMain.ScreenHeight / 2 - 50, 200, 100, StretchableImageType.MediumBorder, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_busyText.Initialize(gameMain.ScreenWidth / 2, gameMain.ScreenHeight / 2, "Generating Galaxy", Color.White, out reason))
            {
                return false;
            }
            if (!_okButton.Initialize("Start Game", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 660, _yPos + 610, 200, 50, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_cancelButton.Initialize("Main Menu", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 450, _yPos + 610, 200, 50, gameMain.Random, out reason))
            {
                return false;
            }

            LoadLastSettings();

            reason = null;
            return true;
        }
예제 #2
0
        public bool Initialize(GameMain gameMain, out string reason)
        {
            this._gameMain = gameMain;

            _showingSelection      = false;
            _background            = new BBStretchableImage();
            _playerBackground      = new BBStretchableImage();
            _playerInfoBackground  = new BBStretchableImage();
            _playerRaceButton      = new BBStretchButton();
            _playerRaceDescription = new BBTextBox();
            _playerLabels          = new BBLabel[3];
            _playerEmperorName     = new BBSingleLineTextBox();
            _playerHomeworldName   = new BBSingleLineTextBox();
            _AIBackground          = new BBStretchableImage();
            _AIRaceButtons         = new BBStretchButton[5];
            _raceSprites           = new BBSprite[6];
            _playerRaces           = new Race[6];
            _playerColors          = new Color[6];
            _numberOfAILabel       = new BBLabel();
            _numericUpDownAI       = new BBNumericUpDown();
            _busyImage             = new BBStretchableImage();
            _busyText     = new BBLabel();
            _okButton     = new BBStretchButton();
            _cancelButton = new BBStretchButton();

            _difficultyComboBox = new BBComboBox();
            _difficultyLabel    = new BBLabel();

            _nebulaBackground = SpriteManager.GetSprite("TitleNebula", gameMain.Random);

            _playerColors[0] = Color.Blue;
            _playerColors[1] = Color.Red;
            _playerColors[2] = Color.Yellow;
            _playerColors[3] = Color.Green;
            _playerColors[4] = Color.Purple;
            _playerColors[5] = Color.Orange;

            _xPos = (gameMain.ScreenWidth / 2) - 440;
            _yPos = (gameMain.ScreenHeight / 2) - 340;
            if (_nebulaBackground == null)
            {
                reason = "TitleNebula sprite doesn't exist.";
                return(false);
            }
            if (!_background.Initialize(_xPos, _yPos, 880, 680, StretchableImageType.MediumBorder, gameMain.Random, out reason))
            {
                return(false);
            }

            if (!_playerBackground.Initialize(_xPos + 30, _yPos + 30, 820, 170, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return(false);
            }
            if (!_playerInfoBackground.Initialize(_xPos + 40, _yPos + 60, 295, 130, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return(false);
            }
            if (!_playerRaceButton.Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 340, _yPos + 40, 500, 150, gameMain.Random, out reason))
            {
                return(false);
            }
            if (!_playerRaceDescription.Initialize(_xPos + 485, _yPos + 51, 345, 130, true, true, "RaceDescriptionTextBox", gameMain.Random, out reason))
            {
                return(false);
            }
            _playerLabels[0] = new BBLabel();
            if (!_playerLabels[0].Initialize(_xPos + 90, _yPos + 36, "Player Race Information", Color.White, out reason))
            {
                return(false);
            }
            _playerLabels[1] = new BBLabel();
            if (!_playerLabels[1].Initialize(_xPos + 45, _yPos + 70, "Emperor Name:", Color.White, out reason))
            {
                return(false);
            }
            if (!_playerEmperorName.Initialize(string.Empty, _xPos + 50, _yPos + 90, 275, 35, false, gameMain.Random, out reason))
            {
                return(false);
            }
            _playerLabels[2] = new BBLabel();
            if (!_playerLabels[2].Initialize(_xPos + 45, _yPos + 125, "Homeworld Name:", Color.White, out reason))
            {
                return(false);
            }
            if (!_playerHomeworldName.Initialize(string.Empty, _xPos + 50, _yPos + 145, 275, 35, false, gameMain.Random, out reason))
            {
                return(false);
            }
            _playerRaceDescription.SetText("A random race will be chosen.  If the Emperor and/or Homeworld name fields are left blank, default race names for those will be used.");
            _randomRaceSprite = SpriteManager.GetSprite("RandomRace", gameMain.Random);
            if (_randomRaceSprite == null)
            {
                reason = "RandomRace sprite does not exist.";
                return(false);
            }

            for (int i = 0; i < _raceSprites.Length; i++)
            {
                _raceSprites[i] = _randomRaceSprite;
            }

            if (!_AIBackground.Initialize(_xPos + 30, _yPos + 205, 820, 220, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return(false);
            }
            if (!_difficultyLabel.Initialize(_xPos + 40, _yPos + 220, "Difficulty Level:", Color.White, out reason))
            {
                return(false);
            }
            List <string> difficultyItems = new List <string>
            {
                "Simple",
                "Easy",
                "Medium",
                "Hard",
                "Impossible"
            };

            if (!_difficultyComboBox.Initialize(difficultyItems, _xPos + 170, _yPos + 215, 200, 35, 5, gameMain.Random, out reason))
            {
                return(false);
            }
            if (!_numberOfAILabel.Initialize(_xPos + 730, _yPos + 220, "Number of Computer Players:", Color.White, out reason))
            {
                return(false);
            }
            _numberOfAILabel.SetAlignment(true);
            if (!_numericUpDownAI.Initialize(_xPos + 735, _yPos + 222, 75, 1, 5, 5, gameMain.Random, out reason))
            {
                return(false);
            }
            for (int i = 0; i < _AIRaceButtons.Length; i++)
            {
                _AIRaceButtons[i] = new BBStretchButton();
                if (!_AIRaceButtons[i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 40 + (i * 155), _yPos + 260, 150, 150, gameMain.Random, out reason))
                {
                    return(false);
                }
            }

            _galaxyBackground = new BBStretchableImage();
            _galaxyComboBox   = new BBComboBox();

            List <string> items = new List <string>();

            items.Add("Small Galaxy");
            items.Add("Medium Galaxy");
            items.Add("Large Galaxy");
            items.Add("Huge Galaxy");

            if (!_galaxyBackground.Initialize(_xPos + 30, _yPos + 430, 240, 235, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return(false);
            }
            if (!_galaxyComboBox.Initialize(items, _xPos + 30, _yPos + 430, 240, 35, 4, gameMain.Random, out reason))
            {
                return(false);
            }

            _raceSelection = new RaceSelection();
            if (!_raceSelection.Initialize(gameMain, out reason))
            {
                return(false);
            }
            _raceSelection.OnOkClick = OnRaceSelectionOKClick;

            _generatingGalaxy = false;
            if (!_busyImage.Initialize(gameMain.ScreenWidth / 2 - 100, gameMain.ScreenHeight / 2 - 50, 200, 100, StretchableImageType.MediumBorder, gameMain.Random, out reason))
            {
                return(false);
            }
            if (!_busyText.Initialize(gameMain.ScreenWidth / 2, gameMain.ScreenHeight / 2, "Generating Galaxy", Color.White, out reason))
            {
                return(false);
            }
            if (!_okButton.Initialize("Start Game", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 660, _yPos + 610, 200, 50, gameMain.Random, out reason))
            {
                return(false);
            }
            if (!_cancelButton.Initialize("Main Menu", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 450, _yPos + 610, 200, 50, gameMain.Random, out reason))
            {
                return(false);
            }

            LoadLastSettings();

            reason = null;
            return(true);
        }