Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public bool Initialize(GameMain gameMain, out string reason)
        {
            _gameMain = gameMain;

            _energyX = (_gameMain.ScreenSize.X / 2) - 190;
            _shipStatsBackground = new BBStretchableImage();
            _miniMapBackground = new BBStretchableImage();
            if (!_shipStatsBackground.Initialize((_gameMain.ScreenSize.X / 2) - 200, -20, 400, 90, StretchableImageType.ThinBorderBG, _gameMain.Random, out reason))
            {
                return false;
            }
            if (!_miniMapBackground.Initialize(_gameMain.ScreenSize.X - 250, _gameMain.ScreenSize.Y - 250, 300, 300, StretchableImageType.ThinBorderBG, _gameMain.Random, out reason))
            {
                return false;
            }

            _bankAmount = new BBLabel();
            _energyAmount = new BBLabel();

            if (!_bankAmount.Initialize(_energyX, 40, string.Empty, Color.White, out reason))
            {
                return false;
            }
            if (!_energyAmount.Initialize(_energyX + 380, 40, string.Empty, Color.White, out reason))
            {
                return false;
            }
            _energyAmount.SetAlignment(true);

            _horizontalEnergyBar = SpriteManager.GetSprite("ScrollHorizontalBar", gameMain.Random);
            if (_horizontalEnergyBar == null)
            {
                reason = "ScrollHorizontalBar sprite not found";
                return false;
            }

            /*_debuggingText = new BBTextBox();
            if (!_debuggingText.Initialize(0, 0, 300, 300, true, false, "DebugText", gameMain.Random, out reason))
            {
                return false;
            }*/

            _miniMapTarget = new RenderImage("MiniMapRender", 230, 230, ImageBufferFormats.BufferRGB888A8);
            _miniMapTarget.BlendingMode = BlendingModes.Modulated;

            _dot = SpriteManager.GetSprite("BackgroundStar", _gameMain.Random);
            if (_dot == null)
            {
                reason = "Star sprite doesn't exist.";
                return false;
            }
            _delay = 0;
            return true;
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public bool Initialize(GameMain gameMain, out string reason)
        {
            _gameMain = gameMain;
            _title = SpriteManager.GetSprite("Title", _gameMain.Random);
            if (_title == null)
            {
                reason = "Title Sprite not found";
                return false;
            }

            _singlePlayerButton = new BBButton();
            _multiPlayerButton = new BBButton();
            _exitButton = new BBButton();

            _hostOrConnectButton = new BBButton();
            _cancelButton = new BBButton();
            _ipAddressTextBox = new BBSingleLineTextBox();
            _playerNameTextBox = new BBSingleLineTextBox();
            _debugText = new BBLabel();

            _showingMultiplayerOptions = false;

            int x = _gameMain.ScreenSize.X / 2 - 130;
            int y = _gameMain.ScreenSize.Y / 2 + 50;

            if (!_singlePlayerButton.Initialize("MainButtonBG", "MainButtonFG", "Single Player", "LargeComputerFont", ButtonTextAlignment.CENTER, x, y + 50, 260, 40, _gameMain.Random, out reason))
            {
                return false;
            }
            if (!_multiPlayerButton.Initialize("MainButtonBG", "MainButtonFG", "MultiPlayer", "LargeComputerFont", ButtonTextAlignment.CENTER, x, y + 100, 260, 40, _gameMain.Random, out reason))
            {
                return false;
            }
            if (!_exitButton.Initialize("MainButtonBG", "MainButtonFG", "Exit", "LargeComputerFont", ButtonTextAlignment.CENTER, x, y + 200, 260, 40, _gameMain.Random, out reason))
            {
                return false;
            }

            if (!_playerNameTextBox.Initialize("Player Name", x, y, 260, 40, false, _gameMain.Random, out reason))
            {
                return false;
            }
            if (!_ipAddressTextBox.Initialize(string.Empty, x - 150, y + 50, 260, 40, false, _gameMain.Random, out reason))
            {
                return false;
            }
            if (!_hostOrConnectButton.Initialize("MainButtonBG", "MainButtonFG", "Host", "LargeComputerFont", ButtonTextAlignment.CENTER, x + 150, y + 50, 260, 40, _gameMain.Random, out reason))
            {
                return false;
            }
            if (!_cancelButton.Initialize("MainButtonBG", "MainButtonFG", "Back", "LargeComputerFont", ButtonTextAlignment.CENTER, x, y + 100, 260, 40, _gameMain.Random, out reason))
            {
                return false;
            }
            if (!_debugText.Initialize(10, _gameMain.ScreenSize.Y - 30, string.Empty, Color.White, out reason))
            {
                return false;
            }
            _singlePlayerButton.SetTextColor(Color.Gold, Color.Black);
            _multiPlayerButton.SetTextColor(Color.Gold, Color.Black);
            _exitButton.SetTextColor(Color.Gold, Color.Black);
            _hostOrConnectButton.SetTextColor(Color.Gold, Color.Black);
            _cancelButton.SetTextColor(Color.Gold, Color.Black);

            _gameMain.LevelNumber = 100;
            _gameMain.SetupLevel();
            _debugText.SetText("Num of Asteroids: " + _gameMain.AsteroidManager.Asteroids.Count);

            reason = null;
            return true;
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        public bool Initialize(GameMain gameMain, out string reason)
        {
            int x = (gameMain.ScreenSize.X / 2) - 300;
            int y = (gameMain.ScreenSize.Y / 2) - 300;

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

            x += 20;
            y += 20;

            _leftButton = new BBButton();
            _rightButton = new BBButton();
            _upButton = new BBButton();
            _downButton = new BBButton();
            _colorLabels = new BBLabel[3];
            _colorSliders = new BBScrollBar[3];
            _shipCostLabel = new BBLabel();
            _bankLabel = new BBLabel();
            _shipStatsBackground = new BBStretchableImage();
            _shipStatsTextBox = new BBTextBox();
            _selectShipButton = new BBButton();

            if (!_leftButton.Initialize("ScrollLeftBGButton", "ScrollLeftFGButton", string.Empty, ButtonTextAlignment.CENTER, x + 5, y + 141, 16, 16, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_rightButton.Initialize("ScrollRightBGButton", "ScrollRightFGButton", string.Empty, ButtonTextAlignment.CENTER, x + 277, y + 141, 16, 16, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_upButton.Initialize("ScrollUpBGButton", "ScrollUpFGButton", string.Empty, ButtonTextAlignment.CENTER, x + 141, y + 5, 16, 16, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_downButton.Initialize("ScrollDownBGButton", "ScrollDownFGButton", string.Empty, ButtonTextAlignment.CENTER, x + 141, y + 277, 16, 16, gameMain.Random, out reason))
            {
                return false;
            }

            if (!_shipCostLabel.Initialize(x + 133, y + 310, "Ship Cost:", Color.Green, out reason))
            {
                return false;
            }

            for (int i = 0; i < 3; i++)
            {
                _colorLabels[i] = new BBLabel();
                _colorSliders[i] = new BBScrollBar();
                if (!_colorLabels[i].Initialize(x + 5, y + 340 + (i * 50), string.Empty, Color.White, out reason))
                {
                    return false;
                }
                if (!_colorSliders[i].Initialize(x + 5, y + 365 + (i * 50), 288, 1, 256, true, true, gameMain.Random, out reason))
                {
                    return false;
                }
                _colorSliders[i].TopIndex = 255;
            }
            _colorLabels[0].SetColor(Color.Red, Color.Empty);
            _colorLabels[1].SetColor(Color.Green, Color.Empty);
            _colorLabels[2].SetColor(Color.Blue, Color.Empty);

            if (!_shipStatsBackground.Initialize(x + 300, y + 5, 250, 500, StretchableImageType.ThinBorderBG, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_shipStatsTextBox.Initialize(x + 305, y + 10, 240, 490, false, false, "ShipStatsTextBox", gameMain.Random, out reason))
            {
                return false;
            }
            if (!_bankLabel.Initialize(x + 300, y + 510, "Bank:", Color.White, out reason))
            {
                return false;
            }
            if (!_selectShipButton.Initialize("ConfirmBG", "ConfirmFG", string.Empty, ButtonTextAlignment.CENTER, x + 485, y + 530, 75, 35, _gameMain.Random, out reason))
            {
                return false;
            }

            RefreshColorValues();
            _size = 1;
            _style = 1;
            _angle = 0;

            _shipSprite = SpriteManager.GetShipSprite(_size, _style, _gameMain.Random);

            return true;
        }
Ejemplo n.º 10
0
 private void RefreshShipSprite()
 {
     _shipSprite = SpriteManager.GetShipSprite(_size, _style, _gameMain.Random);
 }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
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();
     }
 }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
        //Used when other non-combat screens are open, to fill in the blank areas
        public void DrawGalaxy()
        {
            Empire            currentEmpire      = _gameMain.EmpireManager.CurrentEmpire;
            StarSystem        selectedSystem     = currentEmpire.SelectedSystem;
            FleetGroup        selectedFleetGroup = currentEmpire.SelectedFleetGroup;
            List <StarSystem> systems            = _gameMain.Galaxy.GetAllStars();
            bool displayName = _camera.ZoomDistance > 0.8f;

            if (_showingFuelRange)
            {
                // TODO: Optimize this by going through an empire's owned systems, instead of all stars
                float scale         = (currentEmpire.TechnologyManager.FuelRange / 3.0f) * _camera.ZoomDistance;
                float extendedScale = ((currentEmpire.TechnologyManager.FuelRange + 3) / 3.0f) * _camera.ZoomDistance;
                _backBuffer.Clear(Color.Black);
                _oldTarget = GorgonLibrary.Gorgon.CurrentRenderTarget;
                GorgonLibrary.Gorgon.CurrentRenderTarget = _backBuffer;
                List <StarSystem> ownedSystems = new List <StarSystem>();
                foreach (StarSystem system in systems)
                {
                    if (system.Planets[0].Owner == currentEmpire)
                    {
                        _fuelCircle.Draw((system.X - _camera.CameraX) * _camera.ZoomDistance, (system.Y - _camera.CameraY) * _camera.ZoomDistance, extendedScale, extendedScale, Color.LimeGreen);
                        ownedSystems.Add(system);
                    }
                }
                GorgonLibrary.Gorgon.CurrentRenderTarget = _oldTarget;
                _backBuffer.Blit(0, 0, _gameMain.ScreenWidth, _gameMain.ScreenHeight, Color.FromArgb(75, Color.White), BlitterSizeMode.Crop);
                _backBuffer.Clear(Color.Black);
                GorgonLibrary.Gorgon.CurrentRenderTarget = _backBuffer;
                foreach (StarSystem system in ownedSystems)
                {
                    _fuelCircle.Draw((system.X - _camera.CameraX) * _camera.ZoomDistance, (system.Y - _camera.CameraY) * _camera.ZoomDistance, scale, scale, Color.LimeGreen);
                }
                GorgonLibrary.Gorgon.CurrentRenderTarget = _oldTarget;
                _backBuffer.Blit(0, 0, _gameMain.ScreenWidth, _gameMain.ScreenHeight, Color.FromArgb(75, Color.White), BlitterSizeMode.Crop);
            }
            else if (_showingRadarRange)
            {
                // TODO: Optimize this by going through an empire's owned systems, instead of all stars
                float planetScale = (currentEmpire.TechnologyManager.PlanetRadarRange / 3.0f) * _camera.ZoomDistance;
                float fleetScale  = (currentEmpire.TechnologyManager.FleetRadarRange / 3.0f) * _camera.ZoomDistance;
                _backBuffer.Clear(Color.Black);
                _oldTarget = GorgonLibrary.Gorgon.CurrentRenderTarget;
                GorgonLibrary.Gorgon.CurrentRenderTarget = _backBuffer;
                foreach (StarSystem system in systems)
                {
                    if (system.Planets[0].Owner == currentEmpire)
                    {
                        _fuelCircle.Draw((system.X - _camera.CameraX) * _camera.ZoomDistance, (system.Y - _camera.CameraY) * _camera.ZoomDistance, planetScale, planetScale, Color.Tomato);
                    }
                }
                if (currentEmpire.TechnologyManager.FleetRadarRange > 0)
                {
                    foreach (var fleet in currentEmpire.FleetManager.GetFleets())
                    {
                        _fuelCircle.Draw((fleet.GalaxyX - _camera.CameraX) * _camera.ZoomDistance, (fleet.GalaxyY - _camera.CameraY) * _camera.ZoomDistance, fleetScale, fleetScale, Color.Tomato);
                    }
                }
                GorgonLibrary.Gorgon.CurrentRenderTarget = _oldTarget;
                _backBuffer.Blit(0, 0, _gameMain.ScreenWidth, _gameMain.ScreenHeight, Color.FromArgb(75, Color.White), BlitterSizeMode.Crop);
            }

            if (selectedSystem != null)
            {
                if (selectedSystem.Planets[0].TransferSystem.Key.StarSystem != selectedSystem)
                {
                    _pathSprite.Draw((selectedSystem.X - _camera.CameraX) * _camera.ZoomDistance, (selectedSystem.Y - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance * (selectedSystem.Planets[0].TransferSystem.Key.Length / _pathSprite.Width), _camera.ZoomDistance, Color.Green, selectedSystem.Planets[0].TransferSystem.Key.Angle);
                }
                if (selectedSystem.Planets[0].RelocateToSystem != null)
                {
                    _pathSprite.Draw((selectedSystem.X - _camera.CameraX) * _camera.ZoomDistance, (selectedSystem.Y - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance * (selectedSystem.Planets[0].RelocateToSystem.Length / _pathSprite.Width), _camera.ZoomDistance, Color.Blue, selectedSystem.Planets[0].RelocateToSystem.Angle);
                }
                if (_systemView.IsTransferring && _systemView.TransferSystem != null)
                {
                    _pathSprite.Draw((selectedSystem.X - _camera.CameraX) * _camera.ZoomDistance, (selectedSystem.Y - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance * (_systemView.TransferSystem.Length / _pathSprite.Width), _camera.ZoomDistance, _systemView.TransferSystem.IsValid ? Color.LightGreen : Color.Red, _systemView.TransferSystem.Angle);
                }
                if (_systemView.IsRelocating && _systemView.RelocateSystem != null)
                {
                    _pathSprite.Draw((selectedSystem.X - _camera.CameraX) * _camera.ZoomDistance, (selectedSystem.Y - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance * (_systemView.RelocateSystem.Length / _pathSprite.Width), _camera.ZoomDistance, _systemView.RelocateSystem.IsValid ? Color.LightSkyBlue : Color.Red, _systemView.RelocateSystem.Angle);
                }
            }

            foreach (StarSystem system in systems)
            {
                GorgonLibrary.Gorgon.CurrentShader = _gameMain.StarShader;
                if (_showingOwners)
                {
                    var darkGray = new [] { 0.25f, 0.25f, 0.25f, 1 };
                    if (system.IsThisSystemExploredByEmpire(currentEmpire))
                    {
                        _gameMain.StarShader.Parameters["StarColor"].SetValue(system.Planets[0].Owner == null
                                                                                                              ? darkGray
                                                                                                              : system.Planets[0].Owner.ConvertedColor);
                    }
                    else
                    {
                        _gameMain.StarShader.Parameters["StarColor"].SetValue(darkGray);
                    }
                }
                else
                {
                    _gameMain.StarShader.Parameters["StarColor"].SetValue(system.StarColor);
                }
                system.Sprite.Draw((int)((system.X - _camera.CameraX) * _camera.ZoomDistance), (int)((system.Y - _camera.CameraY) * _camera.ZoomDistance), _camera.ZoomDistance, _camera.ZoomDistance);
                GorgonLibrary.Gorgon.CurrentShader = null;

                if (system == currentEmpire.SelectedSystem)
                {
                    _selectionSprites[0].Draw(((system.X - 16) - _camera.CameraX) * _camera.ZoomDistance, ((system.Y - 16) - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance, _camera.ZoomDistance, Color.Green);
                    _selectionSprites[1].Draw(((system.X) - _camera.CameraX) * _camera.ZoomDistance, ((system.Y - 16) - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance, _camera.ZoomDistance, Color.Green);
                    _selectionSprites[2].Draw(((system.X - 16) - _camera.CameraX) * _camera.ZoomDistance, ((system.Y) - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance, _camera.ZoomDistance, Color.Green);
                    _selectionSprites[3].Draw(((system.X) - _camera.CameraX) * _camera.ZoomDistance, ((system.Y) - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance, _camera.ZoomDistance, Color.Green);
                }

                if (displayName && (_gameMain.EmpireManager.CurrentEmpire.ContactManager.IsContacted(system.DominantEmpire) || system.IsThisSystemExploredByEmpire(_gameMain.EmpireManager.CurrentEmpire)))
                {
                    float x = (system.X - _camera.CameraX) * _camera.ZoomDistance;
                    x -= (system.StarName.GetWidth() / 2);
                    float y = ((system.Y + (system.Size * 16)) - _camera.CameraY) * _camera.ZoomDistance;
                    system.StarName.MoveTo((int)x, (int)y);
                    if (system.DominantEmpire != null)
                    {
                        // TODO: Optimize this by moving the text sprite and color shader to StarSystem, where it's updated when ownership changes
                        float percentage = 1.0f;
                        _oldTarget       = GorgonLibrary.Gorgon.CurrentRenderTarget;
                        _starName.Width  = (int)system.StarName.GetWidth();
                        _starName.Height = (int)system.StarName.GetHeight();
                        GorgonLibrary.Gorgon.CurrentRenderTarget = _starName;
                        system.StarName.MoveTo(0, 0);
                        system.StarName.Draw();
                        GorgonLibrary.Gorgon.CurrentRenderTarget = _oldTarget;
                        //GorgonLibrary.Gorgon.CurrentShader = _gameMain.NameShader;
                        foreach (Empire empire in system.EmpiresWithPlanetsInThisSystem)
                        {
                            /*_gameMain.NameShader.Parameters["EmpireColor"].SetValue(empire.ConvertedColor);
                             * _gameMain.NameShader.Parameters["startPos"].SetValue(percentage);
                             * _gameMain.NameShader.Parameters["endPos"].SetValue(percentage + system.OwnerPercentage[empire]);*/
                            _starName.Blit(x, y, _starName.Width * percentage, _starName.Height, empire.EmpireColor, GorgonLibrary.Graphics.BlitterSizeMode.Crop);
                            percentage -= system.OwnerPercentage[empire];
                        }
                        //GorgonLibrary.Gorgon.CurrentShader = null;
                    }
                    else
                    {
                        system.StarName.Draw();
                    }
                }
            }

            if (selectedFleetGroup != null && selectedFleetGroup.SelectedFleet.TravelNodes != null)
            {
                if (selectedFleetGroup.SelectedFleet.Empire == currentEmpire)
                {
                    for (int i = 0; i < selectedFleetGroup.SelectedFleet.TravelNodes.Count; i++)
                    {
                        if (i == 0)
                        {
                            var travelNode = selectedFleetGroup.FleetToSplit.TravelNodes[0];
                            if (selectedFleetGroup.SelectedFleet.AdjacentSystem != null)
                            {
                                //Haven't left yet, so calculate custom path from left side of star
                                float x      = travelNode.StarSystem.X - (selectedFleetGroup.FleetToSplit.GalaxyX - 32);
                                float y      = travelNode.StarSystem.Y - selectedFleetGroup.FleetToSplit.GalaxyY;
                                float length = (float)Math.Sqrt((x * x) + (y * y));
                                float angle  = (float)(Math.Atan2(y, x) * (180 / Math.PI));
                                _pathSprite.Draw((selectedFleetGroup.SelectedFleet.GalaxyX - _camera.CameraX - 32) * _camera.ZoomDistance, (selectedFleetGroup.SelectedFleet.GalaxyY - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance * (length / _pathSprite.Width), _camera.ZoomDistance, Color.Green, angle);
                            }
                            else
                            {
                                _pathSprite.Draw((selectedFleetGroup.SelectedFleet.GalaxyX - _camera.CameraX) * _camera.ZoomDistance, (selectedFleetGroup.SelectedFleet.GalaxyY - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance * (travelNode.Length / _pathSprite.Width), _camera.ZoomDistance, Color.Green, travelNode.Angle);
                            }
                            if (selectedFleetGroup.SelectedFleet.TravelNodes.Count == 1)
                            {
                                //Only one node, so draw ETA at this star
                                DrawETA(travelNode, false);
                            }
                        }
                        else
                        {
                            _pathSprite.Draw((selectedFleetGroup.SelectedFleet.TravelNodes[i - 1].StarSystem.X - _camera.CameraX) * _camera.ZoomDistance, (selectedFleetGroup.SelectedFleet.TravelNodes[i - 1].StarSystem.Y - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance * (selectedFleetGroup.SelectedFleet.TravelNodes[i].Length / _pathSprite.Width), _camera.ZoomDistance, Color.Green, selectedFleetGroup.SelectedFleet.TravelNodes[i].Angle);
                            if (i == selectedFleetGroup.SelectedFleet.TravelNodes.Count - 1)
                            {
                                //Last node, so draw ETA here
                                DrawETA(selectedFleetGroup.FleetToSplit.TravelNodes[i], false);
                            }
                        }
                    }
                }
                else if (currentEmpire.TechnologyManager.ShowEnemyETA && selectedFleetGroup.SelectedFleet.TravelNodes.Count > 0)
                {
                    _pathSprite.Draw((selectedFleetGroup.SelectedFleet.GalaxyX - _camera.CameraX) * _camera.ZoomDistance, (selectedFleetGroup.SelectedFleet.GalaxyY - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance * (selectedFleetGroup.SelectedFleet.TravelNodes[0].Length / _pathSprite.Width), _camera.ZoomDistance, Color.Red, selectedFleetGroup.SelectedFleet.TravelNodes[0].Angle);
                    //Player do not know if there's other stops, so draw ETA for first one
                    DrawETA(selectedFleetGroup.FleetToSplit.TravelNodes[0], false);
                }
            }

            if (selectedFleetGroup != null && selectedFleetGroup.FleetToSplit.TentativeNodes != null)
            {
                for (int i = 0; i < selectedFleetGroup.FleetToSplit.TentativeNodes.Count; i++)
                {
                    if (i == 0)
                    {
                        var travelNode = selectedFleetGroup.FleetToSplit.TentativeNodes[0];
                        if (selectedFleetGroup.FleetToSplit.AdjacentSystem != null && selectedFleetGroup.FleetToSplit.TravelNodes != null)
                        {
                            //Haven't left yet, so calculate custom path from left side of star
                            float x      = travelNode.StarSystem.X - (selectedFleetGroup.FleetToSplit.GalaxyX - 32);
                            float y      = travelNode.StarSystem.Y - selectedFleetGroup.FleetToSplit.GalaxyY;
                            float length = (float)Math.Sqrt((x * x) + (y * y));
                            float angle  = (float)(Math.Atan2(y, x) * (180 / Math.PI));
                            _pathSprite.Draw((selectedFleetGroup.FleetToSplit.GalaxyX - _camera.CameraX - 32) * _camera.ZoomDistance, (selectedFleetGroup.FleetToSplit.GalaxyY - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance * (length / _pathSprite.Width), _camera.ZoomDistance, travelNode.IsValid ? Color.LightGreen : Color.Red, angle);
                        }
                        else if (selectedFleetGroup.FleetToSplit.AdjacentSystem != null)
                        {
                            //Haven't left, and not on enroute already, so calculate path from right side of star
                            float x      = travelNode.StarSystem.X - (selectedFleetGroup.FleetToSplit.GalaxyX + 32);
                            float y      = travelNode.StarSystem.Y - selectedFleetGroup.FleetToSplit.GalaxyY;
                            float length = (float)Math.Sqrt((x * x) + (y * y));
                            float angle  = (float)(Math.Atan2(y, x) * (180 / Math.PI));
                            _pathSprite.Draw((selectedFleetGroup.FleetToSplit.GalaxyX - _camera.CameraX + 32) * _camera.ZoomDistance, (selectedFleetGroup.FleetToSplit.GalaxyY - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance * (length / _pathSprite.Width), _camera.ZoomDistance, travelNode.IsValid ? Color.LightGreen : Color.Red, angle);
                        }
                        else
                        {
                            _pathSprite.Draw((selectedFleetGroup.FleetToSplit.GalaxyX - _camera.CameraX) * _camera.ZoomDistance, (selectedFleetGroup.FleetToSplit.GalaxyY - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance * (selectedFleetGroup.FleetToSplit.TentativeNodes[0].Length / _pathSprite.Width), _camera.ZoomDistance, Color.LightGreen, selectedFleetGroup.FleetToSplit.TentativeNodes[0].Angle);
                        }
                        if (selectedFleetGroup.FleetToSplit.TentativeNodes.Count == 1)
                        {
                            //Only one node, so draw ETA at this star
                            DrawETA(travelNode, true);
                        }
                    }
                    else
                    {
                        _pathSprite.Draw((selectedFleetGroup.FleetToSplit.TentativeNodes[i - 1].StarSystem.X - _camera.CameraX) * _camera.ZoomDistance, (selectedFleetGroup.FleetToSplit.TentativeNodes[i - 1].StarSystem.Y - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance * (selectedFleetGroup.FleetToSplit.TentativeNodes[i].Length / _pathSprite.Width), _camera.ZoomDistance, selectedFleetGroup.FleetToSplit.TentativeNodes[i].IsValid ? Color.LightGreen : Color.Red, selectedFleetGroup.FleetToSplit.TentativeNodes[i].Angle);
                        if (i == selectedFleetGroup.FleetToSplit.TentativeNodes.Count - 1)
                        {
                            //Last node, so draw ETA here
                            DrawETA(selectedFleetGroup.FleetToSplit.TentativeNodes[i], true);
                        }
                    }
                }
            }

            foreach (Fleet fleet in _gameMain.EmpireManager.GetFleetsWithinArea(_camera.CameraX, _camera.CameraY, _gameMain.ScreenWidth / _camera.ZoomDistance, _gameMain.ScreenHeight / _camera.ZoomDistance))
            {
                BBSprite fleetIcon = fleet.Ships.Count > 0 ? fleet.Empire.EmpireRace.FleetIcon : fleet.Empire.EmpireRace.TransportIcon;
                if (fleet.AdjacentSystem != null)
                {
                    if (fleet.TravelNodes != null && fleet.TravelNodes.Count > 0)
                    {
                        //Adjacent to a system, but is heading to another system
                        if (selectedFleetGroup != null && selectedFleetGroup.Fleets.Contains(fleet))
                        {
                            _selectionSprites[0].Draw(((fleet.GalaxyX - 48) - _camera.CameraX) * _camera.ZoomDistance, ((fleet.GalaxyY - 16) - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance, _camera.ZoomDistance, Color.Green);
                            _selectionSprites[1].Draw(((fleet.GalaxyX - 32) - _camera.CameraX) * _camera.ZoomDistance, ((fleet.GalaxyY - 16) - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance, _camera.ZoomDistance, Color.Green);
                            _selectionSprites[2].Draw(((fleet.GalaxyX - 48) - _camera.CameraX) * _camera.ZoomDistance, ((fleet.GalaxyY) - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance, _camera.ZoomDistance, Color.Green);
                            _selectionSprites[3].Draw(((fleet.GalaxyX - 32) - _camera.CameraX) * _camera.ZoomDistance, ((fleet.GalaxyY) - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance, _camera.ZoomDistance, Color.Green);
                        }
                        fleetIcon.Draw((int)(((fleet.GalaxyX - 32) - _camera.CameraX) * _camera.ZoomDistance), (int)((fleet.GalaxyY - _camera.CameraY) * _camera.ZoomDistance), _camera.ZoomDistance, _camera.ZoomDistance, fleet.Empire.EmpireColor);
                    }
                    else
                    {
                        //Adjacent to a system, just chilling
                        if (selectedFleetGroup != null && selectedFleetGroup.Fleets.Contains(fleet))
                        {
                            _selectionSprites[0].Draw(((fleet.GalaxyX + 16) - _camera.CameraX) * _camera.ZoomDistance, ((fleet.GalaxyY - 16) - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance, _camera.ZoomDistance, Color.Green);
                            _selectionSprites[1].Draw(((fleet.GalaxyX + 32) - _camera.CameraX) * _camera.ZoomDistance, ((fleet.GalaxyY - 16) - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance, _camera.ZoomDistance, Color.Green);
                            _selectionSprites[2].Draw(((fleet.GalaxyX + 16) - _camera.CameraX) * _camera.ZoomDistance, ((fleet.GalaxyY) - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance, _camera.ZoomDistance, Color.Green);
                            _selectionSprites[3].Draw(((fleet.GalaxyX + 32) - _camera.CameraX) * _camera.ZoomDistance, ((fleet.GalaxyY) - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance, _camera.ZoomDistance, Color.Green);
                        }
                        fleetIcon.Draw((int)(((fleet.GalaxyX + 32) - _camera.CameraX) * _camera.ZoomDistance), (int)((fleet.GalaxyY - _camera.CameraY) * _camera.ZoomDistance), _camera.ZoomDistance, _camera.ZoomDistance, fleet.Empire.EmpireColor);
                    }
                }
                else
                {
                    //Fleet is enroute, no moving of icon needed
                    if (selectedFleetGroup != null && selectedFleetGroup.Fleets.Contains(fleet))
                    {
                        _selectionSprites[0].Draw(((fleet.GalaxyX - 16) - _camera.CameraX) * _camera.ZoomDistance, ((fleet.GalaxyY - 16) - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance, _camera.ZoomDistance, Color.Green);
                        _selectionSprites[1].Draw(((fleet.GalaxyX) - _camera.CameraX) * _camera.ZoomDistance, ((fleet.GalaxyY - 16) - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance, _camera.ZoomDistance, Color.Green);
                        _selectionSprites[2].Draw(((fleet.GalaxyX - 16) - _camera.CameraX) * _camera.ZoomDistance, ((fleet.GalaxyY) - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance, _camera.ZoomDistance, Color.Green);
                        _selectionSprites[3].Draw(((fleet.GalaxyX) - _camera.CameraX) * _camera.ZoomDistance, ((fleet.GalaxyY) - _camera.CameraY) * _camera.ZoomDistance, _camera.ZoomDistance, _camera.ZoomDistance, Color.Green);
                    }
                    fleetIcon.Draw((int)((fleet.GalaxyX - _camera.CameraX) * _camera.ZoomDistance), (int)((fleet.GalaxyY - _camera.CameraY) * _camera.ZoomDistance), _camera.ZoomDistance, _camera.ZoomDistance, fleet.Empire.EmpireColor);
                }
            }
        }
Ejemplo n.º 15
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);
 }