Beyond_Beyaan.EmpireManager.ProcessNextEmpire C# (CSharp) Метод

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

public ProcessNextEmpire ( ) : bool
Результат bool
        public bool ProcessNextEmpire()
        {
            if (empireIter + 1 == _empires.Count)
            {
                //It've reached the end
                return true;
            }
            //This will update each empire if they're AI.  If an empire is human-controlled, it stops and waits for the player to press end of turn
            for (int i = empireIter + 1; i < _empires.Count; i++)
            {
                empireIter = i;
                if (_empires[i].Type != PlayerType.HUMAN)
                {
                    _empires[i].HandleAIEmpire();
                    if (i + 1 == _empires.Count)
                    {
                        //reached end of list with CPU player as last player
                        return true;
                    }
                }
                else
                {
                    currentEmpire = _empires[i];
                    break;
                }
            }
            return false;
        }

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.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;
        }