Пример #1
0
        /// <summary>
        /// Creates a game with the user input game-name then proceeds to start the network host
        /// </summary>
        private void CreateGame()
        {
            string worldName = _worldNameInput.text;

            // Validate world name
            if (worldName == null || worldName == string.Empty)
            {
                // error message, text cannot be null
                return;
            }

            string worldSeed = _worldSeedInput.text;
            int    seed      = 784893570;

            if (worldSeed != null && worldSeed != string.Empty)
            {
                // turn the string into an int
                seed = worldSeed.GetHashCode();
            }

            if (!GameFile.CreateGame(worldName, seed))
            {
                // error message, cannot create file (save exists, disk full etc)
                return;
            }

            _gameManager.NetworkManager.StartHost();
        }