Beyond_Beyaan.Screens.NewGame.SetUpEmpiresAndStart C# (CSharp) Метод

SetUpEmpiresAndStart() приватный Метод

private SetUpEmpiresAndStart ( ) : void
Результат void
        private void SetUpEmpiresAndStart()
        {
            SaveSettings();
            List<Race> selectedRaces = new List<Race>();
            foreach (Race race in _playerRaces)
            {
                if (race != null)
                {
                    selectedRaces.Add(race);
                }
            }
            while (_playerRaces[0] == null)
            {
                int random = _gameMain.Random.Next(_gameMain.RaceManager.Races.Count);
                if (!selectedRaces.Contains(_gameMain.RaceManager.Races[random]))
                {
                    _playerRaces[0] = _gameMain.RaceManager.Races[random];
                    selectedRaces.Add(_playerRaces[0]);
                }
            }
            //Galaxy already generated, move on to player setup
            _gameMain.DifficultyLevel = _difficultyComboBox.SelectedIndex;
            string emperorName = string.IsNullOrEmpty(_playerEmperorName.Text) ? _playerRaces[0].GetRandomEmperorName() : _playerEmperorName.Text;
            string homeworldName = string.IsNullOrEmpty(_playerHomeworldName.Text) ? NameGenerator.GetName() : _playerHomeworldName.Text;
            Empire empire = new Empire(emperorName, 0, _playerRaces[0], PlayerType.HUMAN, _playerColors[0], _gameMain);
            Planet homePlanet;
            StarSystem homeSystem = _gameMain.Galaxy.SetHomeworld(empire, out homePlanet);
            if (homeSystem == null)
            {
                _gameMain.EmpireManager.Reset();
                //No valid systems, start again
                SetUpGalaxy();
                return;
            }
            homeSystem.Name = homeworldName;
            empire.SetHomeSystem(homeSystem, homePlanet);
            empire.UpdateProduction(); //This sets up expenses and all that
            _gameMain.EmpireManager.AddEmpire(empire);

            for (int i = 0; i < _numericUpDownAI.Value; i++)
            {
                while (_playerRaces[i + 1] == null)
                {
                    int random = _gameMain.Random.Next(_gameMain.RaceManager.Races.Count);
                    if (!selectedRaces.Contains(_gameMain.RaceManager.Races[random]))
                    {
                        _playerRaces[i + 1] = _gameMain.RaceManager.Races[random];
                        selectedRaces.Add(_playerRaces[i + 1]);
                    }
                }
                empire = new Empire(_playerRaces[i + 1].GetRandomEmperorName(), i + 1, _playerRaces[i + 1], PlayerType.CPU, _playerColors[i + 1], _gameMain);
                //AI always have 50 initial population
                homeSystem = _gameMain.Galaxy.SetHomeworld(empire, out homePlanet);
                if (homeSystem == null)
                {
                    _gameMain.EmpireManager.Reset();
                    //No valid systems, start again
                    SetUpGalaxy();
                    return;
                }
                homeSystem.Name = NameGenerator.GetName();
                empire.SetHomeSystem(homeSystem, homePlanet);
                empire.UpdateProduction(); //This sets up expenses and all that
                _gameMain.EmpireManager.AddEmpire(empire);
            }
            _gameMain.EmpireManager.SetupContacts();
            _gameMain.EmpireManager.SetInitialEmpireTurn();
            _generatingGalaxy = false;
            _gameMain.ChangeToScreen(Screen.Galaxy);
        }