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

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

public Initialize ( GameMain gameMain, string &reason ) : bool
gameMain GameMain
reason string
Результат bool
        public bool Initialize(GameMain gameMain, out string reason)
        {
            this.gameMain = gameMain;
            /*x = (gameMain.ScreenWidth / 2) - 400;
            y = (gameMain.ScreenHeight / 2) - 300;
            empireButtons = new Button[4];
            spyEffortScrollbars = new ScrollBar[4];
            spyDefenseScrollbars = new ScrollBar[4];
            for (int i = 0; i < empireButtons.Length; i++)
            {
                empireButtons[i] = new Button(SpriteName.NormalBackgroundButton, SpriteName.NormalForegroundButton, string.Empty, x, y + (150 * i), 384, 150);
                spyEffortScrollbars[i] = new ScrollBar(x + 145, y + 45 + (150 * i), 16, 174, 1, 101, true, true, SpriteName.ScrollLeftBackgroundButton, SpriteName.ScrollLeftForegroundButton,
                    SpriteName.ScrollRightBackgroundButton, SpriteName.ScrollRightForegroundButton, SpriteName.SliderHorizontalBackgroundButton, SpriteName.SliderHorizontalForegroundButton,
                    SpriteName.SliderHorizontalBar, SpriteName.SliderHighlightedHorizontalBar);
                spyDefenseScrollbars[i] = new ScrollBar(x + 145, y + 85 + (150 * i), 16, 174, 1, 101, true, true, SpriteName.ScrollLeftBackgroundButton, SpriteName.ScrollLeftForegroundButton,
                    SpriteName.ScrollRightBackgroundButton, SpriteName.ScrollRightForegroundButton, SpriteName.SliderHorizontalBackgroundButton, SpriteName.SliderHorizontalForegroundButton,
                    SpriteName.SliderHorizontalBar, SpriteName.SliderHighlightedHorizontalBar);
            }
            empireScrollBar = new ScrollBar(x + 384, y, 16, 568, 4, 10, false, false, SpriteName.ScrollUpBackgroundButton, SpriteName.ScrollUpForegroundButton, SpriteName.ScrollDownBackgroundButton,
                SpriteName.ScrollDownForegroundButton, SpriteName.ScrollVerticalBackgroundButton, SpriteName.ScrollVerticalForegroundButton, SpriteName.ScrollVerticalBar, SpriteName.ScrollVerticalBar);

            incomingMessages = new Button[4];
            for (int i = 0; i < incomingMessages.Length; i++)
            {
                incomingMessages[i] = new Button(SpriteName.IncomingMessageBackground, SpriteName.IncomingMessageForeground, string.Empty, x + 98, y + 98 + (150 * i), 40, 40);
            }
            IncomingMessageTextBox = new Label(x + 405, y + 320);

            messageOptions = new Button[10];
            messageOptions[TRADE] = new Button(SpriteName.MiniBackgroundButton, SpriteName.MiniForegroundButton, "Trade", x + 405, y + 320, 190, 25);
            messageOptions[RESEARCH] = new Button(SpriteName.MiniBackgroundButton, SpriteName.MiniForegroundButton, "Research", x + 605, y + 320, 190, 25);
            messageOptions[ALLY] = new Button(SpriteName.MiniBackgroundButton, SpriteName.MiniForegroundButton, "Ally", x + 405, y + 350, 190, 25);
            messageOptions[UNALLY] = new Button(SpriteName.MiniBackgroundButton, SpriteName.MiniForegroundButton, "Unally", x + 605, y + 350, 190, 25);
            messageOptions[HARASS] = new Button(SpriteName.MiniBackgroundButton, SpriteName.MiniForegroundButton, "Harass Selected Empire", x + 405, y + 410, 190, 25);
            messageOptions[RECONCILE] = new Button(SpriteName.MiniBackgroundButton, SpriteName.MiniForegroundButton, "Reconcile Selected Empire", x + 605, y + 410, 190, 25);
            messageOptions[WAR] = new Button(SpriteName.MiniBackgroundButton, SpriteName.MiniForegroundButton, "War", x + 505, y + 500, 190, 25);
            messageOptions[SEND] = new Button(SpriteName.MiniBackgroundButton, SpriteName.MiniForegroundButton, "Send Message", x + 505, y + 570, 190, 25);
            messageOptions[ACCEPT] = new Button(SpriteName.MiniBackgroundButton, SpriteName.MiniForegroundButton, "Accept", x + 405, y + 570, 190, 25);
            messageOptions[REJECT] = new Button(SpriteName.MiniBackgroundButton, SpriteName.MiniForegroundButton, "Decline", x + 605, y + 570, 190, 25);
            whichContactSelected = -1;
            isViewingReceivedMessage = false;

            spriteNames = new List<SpriteName>();
            spriteNames.Add(SpriteName.MiniBackgroundButton);
            spriteNames.Add(SpriteName.MiniForegroundButton);
            spriteNames.Add(SpriteName.ScrollUpBackgroundButton);
            spriteNames.Add(SpriteName.ScrollUpForegroundButton);
            spriteNames.Add(SpriteName.ScrollVerticalBar);
            spriteNames.Add(SpriteName.ScrollDownBackgroundButton);
            spriteNames.Add(SpriteName.ScrollDownForegroundButton);
            spriteNames.Add(SpriteName.ScrollVerticalBackgroundButton);
            spriteNames.Add(SpriteName.ScrollVerticalForegroundButton);
            whichMessageToSend = -1;*/

            reason = null;
            return true;
        }

Usage Example

Пример #1
0
 public void ChangeToScreen(Screen whichScreen)
 {
     switch (whichScreen)
     {
         case Screen.MainMenu:
             if (_mainGameMenu == null)
             {
                 _mainGameMenu = new MainGameMenu();
                 string reason;
                 if (!_mainGameMenu.Initialize(this, out reason))
                 {
                     MessageBox.Show("Exception in loading Main Menu. Reason: " + reason);
                     _parentForm.Close();
                 }
             }
             _screenInterface = _mainGameMenu;
             break;
         case Screen.NewGame:
             if (_newGame == null)
             {
                 _newGame = new NewGame();
                 string reason;
                 if (!_newGame.Initialize(this, out reason))
                 {
                     MessageBox.Show("Exception in loading New Game Menu. Reason: " + reason);
                     _parentForm.Close();
                 }
             }
             _screenInterface = _newGame;
             break;
         case Screen.Galaxy:
             if (_galaxyScreen == null)
             {
                 _galaxyScreen = new GalaxyScreen();
                 string reason;
                 if (!_galaxyScreen.Initialize(this, out reason))
                 {
                     MessageBox.Show("Exception in loading Galaxy Screen. Reason: " + reason);
                     _parentForm.Close();
                 }
             }
             _galaxyScreen.CenterScreen();
             _screenInterface = _galaxyScreen;
             break;
         case Screen.Diplomacy:
             if (_diplomacyScreen == null)
             {
                 _diplomacyScreen = new DiplomacyScreen();
                 string reason;
                 if (!_diplomacyScreen.Initialize(this, out reason))
                 {
                     MessageBox.Show("Exception in loading Diplomacy Screen. Reason: " + reason);
                     _parentForm.Close();
                 }
             }
             _diplomacyScreen.SetupScreen();
             _screenInterface = _diplomacyScreen;
             break;
         case Screen.FleetList:
             if (_fleetListScreen == null)
             {
                 _fleetListScreen = new FleetListScreen();
                 string reason;
                 if (!_fleetListScreen.Initialize(this, out reason))
                 {
                     MessageBox.Show("Exception in loading Fleet List Screen. Reason: " + reason);
                     _parentForm.Close();
                 }
             }
             _fleetListScreen.LoadScreen();
             _screenInterface = _fleetListScreen;
             break;
         case Screen.ProcessTurn:
             EmpireManager.CurrentEmpire.ClearTurnData();
             if (_processingTurnScreen == null)
             {
                 _processingTurnScreen = new ProcessingTurnScreen();
                 string reason;
                 if (!_processingTurnScreen.Initialize(this, out reason))
                 {
                     MessageBox.Show("Exception in loading Processing Turn Screen. Reason: " + reason);
                     _parentForm.Close();
                 }
             }
             if (!EmpireManager.ProcessNextEmpire())
             {
                 _situationReport.Refresh();
                 ChangeToScreen(Screen.Galaxy);
                 break;
             }
             _screenInterface = _processingTurnScreen;
             break;
         case Screen.Battle:
             /*if (_spaceCombat == null)
             {
                 _spaceCombat = new SpaceCombat();
                 _spaceCombat.Initialize(this);
             }
             _spaceCombat.SetupScreen();
             _screenInterface = _spaceCombat;*/
             break;
     }
     _currentScreen = whichScreen;
 }