Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        public bool Initialize(FileInfo file, Random r, out string reason)
        {
            XDocument doc  = XDocument.Load(file.FullName);
            XElement  root = doc.Element("Race");

            SetBaseDefaults();

            RaceName         = root.Attribute("name").Value;
            SingularRaceName = root.Attribute("singularName").Value;
            RaceDescription  = root.Attribute("raceDescription").Value;
            NeutralAvatar    = SpriteManager.GetSprite(root.Attribute("neutralPortrait").Value, r);
            HappyAvatar      = SpriteManager.GetSprite(root.Attribute("happyPortrait").Value, r);
            AngryAvatar      = SpriteManager.GetSprite(root.Attribute("angryPortrait").Value, r);
            MiniAvatar       = SpriteManager.GetSprite(root.Attribute("thumbnail").Value, r);
            GroundTroop      = SpriteManager.GetSprite(root.Attribute("groundTroop").Value, r);
            DyingTroop       = SpriteManager.GetSprite(root.Attribute("dyingTroop").Value, r);
            FleetIcon        = SpriteManager.GetSprite(root.Attribute("fleetIcon").Value, r);
            TransportIcon    = SpriteManager.GetSprite(root.Attribute("transportIcon").Value, r);
            City             = SpriteManager.GetSprite(root.Attribute("city").Value, r);
            LandingShip      = SpriteManager.GetSprite(root.Attribute("landingShip").Value, r);

            XElement shipTypes = root.Element("ShipTypes");

            if (shipTypes == null)
            {
                reason = "ShipTypes not found in " + RaceName + " race";
                return(false);
            }

            ShipTypes = new List <RaceShipType>();
            foreach (XElement shipType in shipTypes.Elements())
            {
                RaceShipType newType = new RaceShipType();
                newType.TypeName = shipType.Attribute("name").Value;
                newType.Space    = int.Parse(shipType.Attribute("space").Value);
                newType.Width    = int.Parse(shipType.Attribute("width").Value);
                newType.Height   = int.Parse(shipType.Attribute("height").Value);
                newType.Bodies   = new List <BBSprite>();
                foreach (XElement body in shipType.Elements())
                {
                    newType.Bodies.Add(SpriteManager.GetSprite(body.Attribute("sprite").Value, r));
                }
                ShipTypes.Add(newType);
            }
            //Order ships based on space
            ShipTypes.Sort((a, b) => { return(a.Space.CompareTo(b.Space)); });

            reason = null;
            return(true);
        }
Exemplo n.º 3
0
        public bool Initialize(GameMain gameMain, out string reason)
        {
            this._gameMain = gameMain;

            _buttons = new BBButton[4];

            _x = (gameMain.ScreenWidth / 2) - 130;
            _y = (gameMain.ScreenHeight / 2);

            for (int i = 0; i < _buttons.Length; i++)
            {
                _buttons[i] = new BBButton();
            }

            if (!_buttons[0].Initialize("MainButtonBG", "MainButtonFG", "Continue", "LargeComputerFont", ButtonTextAlignment.CENTER, _x, _y, 260, 40, gameMain.Random, out reason, 20, -1))
            {
                return false;
            }
            if (!_buttons[1].Initialize("MainButtonBG", "MainButtonFG", "New Game", "LargeComputerFont", ButtonTextAlignment.CENTER, _x, _y + 50, 260, 40, gameMain.Random, out reason, 20, -1))
            {
                return false;
            }
            if (!_buttons[2].Initialize("MainButtonBG", "MainButtonFG", "Load Game", "LargeComputerFont", ButtonTextAlignment.CENTER, _x, _y + 100, 260, 40, gameMain.Random, out reason, 20, -1))
            {
                return false;
            }
            if (!_buttons[3].Initialize("MainButtonBG", "MainButtonFG", "Exit", "LargeComputerFont", ButtonTextAlignment.CENTER, _x, _y + 150, 260, 40, gameMain.Random, out reason, 20, -1))
            {
                return false;
            }
            for (int i = 0; i < _buttons.Length; i++)
            {
                _buttons[i].SetTextColor(System.Drawing.Color.Gold, System.Drawing.Color.Black);
            }

            _versionLabel = new BBLabel();
            if (!_versionLabel.Initialize(10, _gameMain.ScreenHeight - 30, "Version 0.59", System.Drawing.Color.White, out reason))
            {
                return false;
            }

            _background = SpriteManager.GetSprite("MainBackground", gameMain.Random);
            _planet = SpriteManager.GetSprite("MainPlanetBackground", gameMain.Random);
            _title = SpriteManager.GetSprite("Title", gameMain.Random);

            _x = (gameMain.ScreenWidth / 2) - 512;
            _y = (gameMain.ScreenHeight / 2) - 300;

            _files = Utility.GetSaveGames(gameMain.GameDataSet.FullName);
            if (_files.Count == 0)
            {
                _buttons[0].Active = false; //Disabled Continue and Load buttons since there's no games to load
                _buttons[2].Active = false;
            }

            _loadBackground = new BBStretchableImage();
            if (!_loadBackground.Initialize((gameMain.ScreenWidth / 2) - 225, (gameMain.ScreenHeight / 2) - 175, 450, 350, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return false;
            }
            _saveGameButtons = new BBInvisibleStretchButton[10];
            for (int i = 0; i < _saveGameButtons.Length; i++)
            {
                _saveGameButtons[i] = new BBInvisibleStretchButton();
                if (!_saveGameButtons[i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, (gameMain.ScreenWidth / 2) - 220, (gameMain.ScreenHeight / 2) - 160 + (i * 32), 420, 32, gameMain.Random, out reason))
                {
                    return false;
                }
            }
            _scrollBar = new BBScrollBar();
            if (!_scrollBar.Initialize((gameMain.ScreenWidth / 2) + 200, (gameMain.ScreenHeight / 2) - 160, 320, 10, 10, false, false, gameMain.Random, out reason))
            {
                return false;
            }

            _maxVisible = _files.Count > _saveGameButtons.Length ? _saveGameButtons.Length : _files.Count;
            if (_maxVisible < _saveGameButtons.Length)
            {
                //Disable the scrollbar
                _scrollBar.SetEnabledState(false);
            }
            else
            {
                _scrollBar.SetEnabledState(true);
                _scrollBar.SetAmountOfItems(_files.Count);
            }

            RefreshSaves();

            _showingLoadMenu = false;

            reason = null;
            return true;
        }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
0
 public override bool MouseUp(int x, int y)
 {
     if (!_colonizing)
     {
         for (int i = 0; i < _maxShips; i++)
         {
             if (_shipButtons[i].MouseUp(x, y))
             {
                 foreach (var button in _shipButtons)
                 {
                     button.Selected = false;
                 }
                 _shipButtons[i].Selected = true;
             }
         }
         if (_cancelButton.MouseUp(x, y))
         {
             if (Completed != null)
             {
                 Completed();
             }
         }
         if (_colonizeButton.MouseDown(x, y))
         {
             int whichShip = 0;
             for (int i = 0; i < _maxShips; i++)
             {
                 if (_shipButtons[i].Selected)
                 {
                     whichShip = i;
                     break;
                 }
             }
             var ship = _colonyShips[whichShip];
             _colonizingFleet.ColonizePlanet(ship);
             _nameTextBox.SetText(_starSystem.Name);
             //Select the textbox so it'd capture the keypresses
             _nameTextBox.MouseDown(_gameMain.ScreenWidth / 2, _gameMain.ScreenHeight / 2);
             _nameTextBox.MouseUp(_gameMain.ScreenWidth / 2, _gameMain.ScreenHeight / 2);
             _landingShipPos = _gameMain.ScreenHeight / 2 - 300;
             _groundView = _starSystem.Planets[0].GroundSprite;
             _landingShip = _colonizingFleet.Empire.EmpireRace.LandingShip;
             _showingText = false;
             _colonizing = true;
         }
     }
     else
     {
         if (!_showingText)
         {
             _showingText = true;
             _landingShipPos = _gameMain.ScreenHeight / 2 + 50;
         }
         else
         {
             if (!_nameTextBox.MouseUp(x, y) && !string.IsNullOrEmpty(_nameTextBox.Text))
             {
                 _starSystem.Name = _nameTextBox.Text;
                 _colonizing = false;
                 _showingText = false;
                 //Done
                 if (Completed != null)
                 {
                     Completed();
                 }
             }
         }
     }
     return false;
 }
Exemplo n.º 8
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;
        }
Exemplo n.º 9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="items"></param>
        /// <param name="xPos"></param>
        /// <param name="yPos"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="maxVisible"></param>
        /// <param name="r"></param>
        /// <param name="reason"></param>
        public bool Initialize(List<string> items, int xPos, int yPos, int width, int height, int maxVisible, Random r, out string reason)
        {
            _items = items;
            _xPos = xPos;
            _yPos = yPos;
            _width = width;
            _height = height;

            _selectedIndex = 0;
            Dropped = false;
            _downArrowSprite = SpriteManager.GetSprite("ScrollDownBGButton", r);

            if (items.Count < maxVisible)
            {
                _haveScroll = false;
                maxVisible = items.Count;
            }
            else if (items.Count > maxVisible)
            {
                _haveScroll = true;
            }

            Enabled = true;

            _buttons = new List<BBInvisibleStretchButton>();
            _dropBackground = new BBStretchableImage();
            _scrollBar = new BBScrollBar();

            for (int i = 0; i <= maxVisible; i++)
            {
                BBInvisibleStretchButton button = new BBInvisibleStretchButton();
                if (!button.Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos, _yPos + (i * height), _width, _height, r, out reason))
                {
                    return false;
                }
                _buttons.Add(button);
            }
            if (!_dropBackground.Initialize(_xPos, _yPos, width, height, StretchableImageType.ThinBorderBG, r, out reason))
            {
                return false;
            }
            if (!_scrollBar.Initialize(_xPos + _width, _yPos + _height, maxVisible * _height, maxVisible, items.Count, false, false, r, out reason))
            {
                return false;
            }
            RefreshSelection();
            RefreshLabels();
            return true;
        }
Exemplo n.º 10
0
        public bool Initialize(int xPos, int yPos, int length, int amountOfVisibleItems, int amountOfItems, bool isHorizontal, bool isSlider, Random r, out string reason)
        {
            _xPos = xPos;
            _yPos = yPos;
            _scroll = new BBUniStretchButton();

            _amountOfItems = amountOfItems;
            _amountVisible = amountOfVisibleItems;
            _isSlider = isSlider;
            _isHorizontal = isHorizontal;

            _scrollBarLength = length;

            if (!isSlider)
            {
                _scrollButtonLength = (int)(((float)amountOfVisibleItems / amountOfItems) * _scrollBarLength);
                if (!isHorizontal)
                {
                    if (!_scroll.Initialize(new List<string> { "TinyScrollVerticalBGButton1", "TinyScrollVerticalBGButton2", "TinyScrollVerticalBGButton3" },
                                           new List<string> { "TinyScrollVerticalFGButton1", "TinyScrollVerticalFGButton2", "TinyScrollVerticalFGButton3" },
                                           isHorizontal, "", ButtonTextAlignment.LEFT, xPos, yPos, 5, _scrollButtonLength, 3, 1, r, out reason))
                    {
                        return false;
                    }
                    _scrollBar = SpriteManager.GetSprite("TinyScrollVerticalBar", r);
                    if (_scrollBar == null)
                    {
                        reason = "\"TinyScrollVerticalBar\" sprite does not exist";
                        return false;
                    }
                }
                else
                {
                    if (!_scroll.Initialize(new List<string> { "TinyScrollHorizontalBGButton1", "TinyScrollHorizontalBGButton2", "TinyScrollHorizontalBGButton3" },
                                           new List<string> { "TinyScrollHorizontalFGButton1", "TinyScrollHorizontalFGButton2", "TinyScrollHorizontalFGButton3" },
                                           isHorizontal, "", ButtonTextAlignment.LEFT, xPos, yPos, _scrollButtonLength, 5, 3, 1, r, out reason))
                    {
                        return false;
                    }
                    _scrollBar = SpriteManager.GetSprite("TinyScrollHorizontalBar", r);
                    if (_scrollBar == null)
                    {
                        reason = "\"TinyScrollHorizontalBar\" sprite does not exist";
                        return false;
                    }
                }
            }
            else
            {
                _scrollButtonLength = 16;
                if (!_scroll.Initialize(new List<string> { "TinySliderHorizontalBGButton1", "TinySliderHorizontalBGButton2", "TinySliderHorizontalBGButton3" },
                                       new List<string> { "TinySliderHorizontalFGButton1", "TinySliderHorizontalFGButton2", "TinySliderHorizontalFGButton3" },
                                       true, "", ButtonTextAlignment.LEFT, xPos, yPos, _scrollButtonLength, 5, 3, 1, r, out reason))
                {
                    return false;
                }
                _scrollBar = SpriteManager.GetSprite("TinySliderBGBar", r);
                if (_scrollBar == null)
                {
                    reason = "\"TinySliderBGBar\" sprite does not exist";
                    return false;
                }
                _highlightedScrollBar = SpriteManager.GetSprite("TinySliderFGBar", r);
                if (_highlightedScrollBar == null)
                {
                    reason = "\"SliderFGBar\" sprite does not exist";
                    return false;
                }
            }

            _topIndex = 0;
            _scrollPos = 0; //relative to the scrollbar itself
            _scrollSelected = false;
            _isEnabled = true;
            reason = null;
            return true;
        }
Exemplo n.º 11
0
        public bool Initialize(string backgroundSprite, string foregroundSprite, string buttonText, string font, ButtonTextAlignment alignment, int xPos, int yPos, int width, int height, Random r, out string reason, int xTextOffset = 0, int yTextOffset = 0)
        {
            _backgroundSprite = SpriteManager.GetSprite(backgroundSprite, r);
            _foregroundSprite = SpriteManager.GetSprite(foregroundSprite, r);
            if (backgroundSprite == null || foregroundSprite == null)
            {
                reason = string.Format("One of those sprites does not exist in sprites.xml: \"{0}\" or \"{1}\"", backgroundSprite, foregroundSprite);
                return false;
            }
            _xPos = xPos;
            _yPos = yPos;
            _width = width;
            _height = height;
            _xTextOffset = xTextOffset;
            _yTextOffset = yTextOffset;
            _alignment = alignment;

            _label = new BBLabel();
            if (string.IsNullOrEmpty(font))
            {
                if (!_label.Initialize(0, 0, buttonText, Color.White, out reason))
                {
                    return false;
                }
            }
            else
            {
                if (!_label.Initialize(0, 0, buttonText, Color.White, font, out reason))
                {
                    return false;
                }
            }
            SetText(buttonText);

            Reset();
            reason = null;
            return true;
        }
Exemplo n.º 12
0
        public bool Initialize(int xPos, int yPos, int length, int amountOfVisibleItems, int amountOfItems, bool isHorizontal, bool isSlider, Random r, out string reason)
        {
            this.xPos = xPos;
            this.yPos = yPos;
            Up = new BBButton();
            Down = new BBButton();
            Scroll = new BBUniStretchButton();

            this.amountOfItems = amountOfItems;
            this.amountVisible = amountOfVisibleItems;
            this.isSlider = isSlider;
            this.isHorizontal = isHorizontal;

            scrollBarLength = length - 32;

            if (!isSlider)
            {
                scrollButtonLength = (int)(((float)amountOfVisibleItems / amountOfItems) * scrollBarLength);
                if (!isHorizontal)
                {
                    if (!Up.Initialize("ScrollUpBGButton", "ScrollUpFGButton", "", ButtonTextAlignment.CENTER, xPos, yPos, 16, 16, r, out reason))
                    {
                        return false;
                    }
                    if (!Down.Initialize("ScrollDownBGButton", "ScrollDownFGButton", "", ButtonTextAlignment.CENTER, xPos, yPos + length - 16, 16, 16, r, out reason))
                    {
                        return false;
                    }
                    if (!Scroll.Initialize(new List<string> { "ScrollVerticalBGButton1", "ScrollVerticalBGButton2", "ScrollVerticalBGButton3" },
                                           new List<string> { "ScrollVerticalFGButton1", "ScrollVerticalFGButton2", "ScrollVerticalFGButton3" },
                                           false, "", ButtonTextAlignment.LEFT, xPos, yPos + 16, 16, 7, 2, scrollButtonLength, r, out reason))
                    {
                        return false;
                    }
                    scrollBar = SpriteManager.GetSprite("ScrollVerticalBar", r);
                    if (scrollBar == null)
                    {
                        reason = "\"ScrollVerticalBar\" sprite does not exist";
                        return false;
                    }
                }
                else
                {
                    if (!Up.Initialize("ScrollLeftBGButton", "ScrollLeftFGButton", "", ButtonTextAlignment.CENTER, xPos, yPos, 16, 16, r, out reason))
                    {
                        return false;
                    }
                    if (!Down.Initialize("ScrollRightBGButton", "ScrollRightFGButton", "", ButtonTextAlignment.CENTER, xPos + length - 16, yPos, 16, 16, r, out reason))
                    {
                        return false;
                    }
                    if (!Scroll.Initialize(new List<string> { "ScrollHorizontalBGButton1", "ScrollHorizontalBGButton2", "ScrollHorizontalBGButton3" },
                                           new List<string> { "ScrollHorizontalFGButton1", "ScrollHorizontalFGButton2", "ScrollHorizontalFGButton3" },
                                           false, "", ButtonTextAlignment.LEFT, xPos + 16, yPos, 16, 7, 2, scrollButtonLength, r, out reason))
                    {
                        return false;
                    }
                    scrollBar = SpriteManager.GetSprite("ScrollHorizontalBar", r);
                    if (scrollBar == null)
                    {
                        reason = "\"ScrollHorizontalBar\" sprite does not exist";
                        return false;
                    }
                }
            }
            else
            {
                scrollButtonLength = 16;
                if (!Up.Initialize("ScrollLeftBGButton", "ScrollLeftFGButton", "", ButtonTextAlignment.CENTER, xPos, yPos, 16, 16, r, out reason))
                {
                    return false;
                }
                if (!Down.Initialize("ScrollRightBGButton", "ScrollRightFGButton", "", ButtonTextAlignment.CENTER, xPos + length - 16, yPos, 16, 16, r, out reason))
                {
                    return false;
                }
                if (!Scroll.Initialize(new List<string> { "SliderHorizontalBGButton1", "SliderHorizontalBGButton2", "SliderHorizontalBGButton3" },
                                       new List<string> { "SliderHorizontalFGButton1", "SliderHorizontalFGButton2", "SliderHorizontalFGButton3" },
                                       true, "", ButtonTextAlignment.LEFT, xPos + 16, yPos, 16, 7, 2, scrollButtonLength, r, out reason))
                {
                    return false;
                }
                scrollBar = SpriteManager.GetSprite("SliderBGBar", r);
                if (scrollBar == null)
                {
                    reason = "\"SliderBGBar\" sprite does not exist";
                    return false;
                }
                highlightedScrollBar = SpriteManager.GetSprite("SliderFGBar", r);
                if (highlightedScrollBar == null)
                {
                    reason = "\"SliderFGBar\" sprite does not exist";
                    return false;
                }
            }

            topIndex = 0;
            scrollPos = 0; //relative to the scrollbar itself
            scrollSelected = false;
            isEnabled = true;
            reason = null;
            return true;
        }
Exemplo n.º 13
0
 public override bool MouseHover(int x, int y, float frameDeltaTime)
 {
     bool result = false;
     _previousFleet.MouseHover(x, y, frameDeltaTime);
     _nextFleet.MouseHover(x, y, frameDeltaTime);
     bool withinX = (x >= _xPos + 10 && x < _xPos + 290);
     bool showingPreview = false;
     for (int i = 0; i < _maxVisible; i++)
     {
         if (_shipSliders[i].MouseHover(x, y, frameDeltaTime))
         {
             result = true;
             if (!_isTransports)
             {
                 Ship ship = _selectedFleet.OrderedShips[i];
                 _selectedFleetGroup.FleetToSplit.Ships[ship] = _shipSliders[i].TopIndex;
                 _shipLabels[i].SetText(_shipSliders[i].TopIndex + " x " + ship.Name);
             }
         }
         int tempY = _yPos + 55 + (i * 55);
         if (!_isTransports && withinX && y >= tempY && y < tempY + 55)
         {
             var ship = _selectedFleet.OrderedShips[i];
             _shipSprite = ship.Owner.EmpireRace.GetShip(ship.Size, ship.WhichStyle);
             _empireColor = ship.Owner.ConvertedColor;
             //Show ship preview for this ship
             if (_xPos > 170)
             {
                 _shipPreview.MoveTo(_xPos - 170, tempY - 62);
                 _shipPoint.X = _xPos - 85;
                 _shipPoint.Y = tempY + 23;
                 showingPreview = true;
             }
             else
             {
                 _shipPreview.MoveTo(_xPos + 300, tempY - 62);
                 _shipPoint.X = _xPos + 385;
                 _shipPoint.Y = tempY + 23;
                 showingPreview = true;
             }
         }
     }
     _showingPreview = showingPreview;
     return base.MouseHover(x, y, frameDeltaTime) || result;
 }
Exemplo n.º 14
0
 private void LoadNextTech()
 {
     //Go in order from Computer, Construction, Force Field, Planetology, Propulsion, to Weapon
     if (_availableTopics.ContainsKey(TechField.COMPUTER))
     {
         _currentTechField = TechField.COMPUTER;
         //Check to see if there's a researched item
         bool hasDiscovered = false;
         foreach (var researchedItem in _discoveredTechs)
         {
             if (_currentEmpire.TechnologyManager.ResearchedComputerTechs.Contains(researchedItem))
             {
                 _techIcon = SpriteManager.GetSprite("RandomRace", _gameMain.Random);
                 _techDescription.SetText(researchedItem.TechName + "\n\r\n\r" + researchedItem.TechDescription);
                 hasDiscovered = true;
                 break;
             }
         }
         if (!hasDiscovered)
         {
             _techIcon = SpriteManager.GetSprite("RandomRace", _gameMain.Random);
             _techDescription.SetText("Computer technologies help with increasing number of factories, better scanners, improving your attack and missile defense on ships, and spying efforts benefits from higher computer tech level.");
         }
     }
     else if (_availableTopics.ContainsKey(TechField.CONSTRUCTION))
     {
         _currentTechField = TechField.CONSTRUCTION;
         //Check to see if there's a researched item
         bool hasDiscovered = false;
         foreach (var researchedItem in _discoveredTechs)
         {
             if (_currentEmpire.TechnologyManager.ResearchedConstructionTechs.Contains(researchedItem))
             {
                 _techIcon = SpriteManager.GetSprite("RandomRace", _gameMain.Random);
                 _techDescription.SetText(researchedItem.TechName + "\n\r\n\r" + researchedItem.TechDescription);
                 hasDiscovered = true;
                 break;
             }
         }
         if (!hasDiscovered)
         {
             _techIcon = SpriteManager.GetSprite("RandomRace", _gameMain.Random);
             _techDescription.SetText("Construction technologies gives you better armor, cheaper factories, reduced pollution, and higher construction tech levels gives you more room on ships.");
         }
     }
     else if (_availableTopics.ContainsKey(TechField.FORCE_FIELD))
     {
         _currentTechField = TechField.FORCE_FIELD;
         //Check to see if there's a researched item
         bool hasDiscovered = false;
         foreach (var researchedItem in _discoveredTechs)
         {
             if (_currentEmpire.TechnologyManager.ResearchedForceFieldTechs.Contains(researchedItem))
             {
                 _techIcon = SpriteManager.GetSprite("RandomRace", _gameMain.Random);
                 _techDescription.SetText(researchedItem.TechName + "\n\r\n\r" + researchedItem.TechDescription);
                 hasDiscovered = true;
                 break;
             }
         }
         if (!hasDiscovered)
         {
             _techIcon = SpriteManager.GetSprite("RandomRace", _gameMain.Random);
             _techDescription.SetText("Force field technologies gives you better shields, as well as planetary shields and nifty special items.");
         }
     }
     else if (_availableTopics.ContainsKey(TechField.PLANETOLOGY))
     {
         _currentTechField = TechField.PLANETOLOGY;
         //Check to see if there's a researched item
         bool hasDiscovered = false;
         foreach (var researchedItem in _discoveredTechs)
         {
             if (_currentEmpire.TechnologyManager.ResearchedPlanetologyTechs.Contains(researchedItem))
             {
                 _techIcon = SpriteManager.GetSprite("RandomRace", _gameMain.Random);
                 _techDescription.SetText(researchedItem.TechName + "\n\r\n\r" + researchedItem.TechDescription);
                 hasDiscovered = true;
                 break;
             }
         }
         if (!hasDiscovered)
         {
             _techIcon = SpriteManager.GetSprite("RandomRace", _gameMain.Random);
             _techDescription.SetText("Planetology technologies gives you terraforming and bigger planets, cheaper pollution cleanup, as well as expanding the number of planets you can colonize.  Also includes biological warfare.");
         }
     }
     else if (_availableTopics.ContainsKey(TechField.PROPULSION))
     {
         _currentTechField = TechField.PROPULSION;
         //Check to see if there's a researched item
         bool hasDiscovered = false;
         foreach (var researchedItem in _discoveredTechs)
         {
             if (_currentEmpire.TechnologyManager.ResearchedPropulsionTechs.Contains(researchedItem))
             {
                 _techIcon = SpriteManager.GetSprite("RandomRace", _gameMain.Random);
                 _techDescription.SetText(researchedItem.TechName + "\n\r\n\r" + researchedItem.TechDescription);
                 hasDiscovered = true;
                 break;
             }
         }
         if (!hasDiscovered)
         {
             _techIcon = SpriteManager.GetSprite("RandomRace", _gameMain.Random);
             _techDescription.SetText("Propulsion technologies gives you faster engines, expanded range, and powerful special equipment.");
         }
     }
     else if (_availableTopics.ContainsKey(TechField.WEAPON))
     {
         _currentTechField = TechField.WEAPON;
         //Check to see if there's a researched item
         bool hasDiscovered = false;
         foreach (var researchedItem in _discoveredTechs)
         {
             if (_currentEmpire.TechnologyManager.ResearchedWeaponTechs.Contains(researchedItem))
             {
                 _techIcon = SpriteManager.GetSprite("RandomRace", _gameMain.Random);
                 _techDescription.SetText(researchedItem.TechName + "\n\r\n\r" + researchedItem.TechDescription);
                 hasDiscovered = true;
                 break;
             }
         }
         if (!hasDiscovered)
         {
             _techIcon = SpriteManager.GetSprite("RandomRace", _gameMain.Random);
             _techDescription.SetText("Weapon technologies gives you weapons. A lot of weapons.");
         }
     }
     if (_availableTopics[_currentTechField].Count > 0)
     {
         if (_availableTopics[_currentTechField].Count > _availableTechsToResearchButtons.Length)
         {
             _maxVisible = _availableTechsToResearchButtons.Length;
             _scrollBar.SetEnabledState(true);
             _scrollBar.SetAmountOfItems(_availableTopics[_currentTechField].Count);
         }
         else
         {
             _maxVisible = _availableTopics[_currentTechField].Count;
             _scrollBar.SetAmountOfItems(_availableTechsToResearchButtons.Length);
             _scrollBar.SetEnabledState(false);
         }
         RefreshTechButtons();
     }
 }
Exemplo n.º 15
0
 private void RefreshShipSprite()
 {
     var empire = _gameMain.EmpireManager.CurrentEmpire;
     //Load up the last ship design
     _shipSprite = empire.EmpireRace.GetShip(_shipDesign.Size, _shipDesign.WhichStyle);
     foreach (var button in _shipSizeButtons)
     {
         button.Selected = false;
     }
     _shipSizeButtons[_shipDesign.Size].Selected = true;
 }
Exemplo n.º 16
0
        public override bool MouseHover(int x, int y, float frameDeltaTime)
        {
            bool result = false;

            for (int i = 0; i < 6; i ++)
            {
                result = _scrapButtons[i].MouseHover(x, y, frameDeltaTime) || result;
            }
            _previewVisible = false;
            if (x >= _x && x < _x + 860)
            {
                for (int i = 0; i < _maxVisible; i++)
                {
                    if (y >= _y + (i * 100) && y < _y + ((i + 1) * 100))
                    {
                        var ship = _fleetManager.CurrentDesigns[i];
                        _shipSprite = ship.Owner.EmpireRace.GetShip(ship.Size, ship.WhichStyle);
                        _empireColor = ship.Owner.ConvertedColor;
                        _previewVisible = true;
                        _shipBackground.MoveTo(_x - 170, _y + (i * 100) - 35);
                        _shipPoint.X = _x - 85;
                        _shipPoint.Y = _y + (i * 100) + 50;
                    }
                }
            }
            return result;
        }