예제 #1
0
    public string _initialize(string seed)
    {
        if (String.IsNullOrEmpty(seed))
        {
            if (String.IsNullOrEmpty(randomWord))
            {
                seed = GameUtils.GenerateSeed(5).Trim();
            }
            else
            {
                seed = randomWord;
            }
        }
        else
        {
            seed = seed.ToUpper().Trim();
        }

        int n;

        if (int.TryParse(seed, out n))
        {
            UnityEngine.Random.InitState(n);
        }
        else
        {
            UnityEngine.Random.InitState(seed.GetHashCode());
        }

        // these two must happen before anything else kicks off
        GameUtils.SetHash();
        GameUtils.CreateSeedTable();

        // start generating world parameters
        NoiseConfig.Initialize();
        ColorFactory.GeneratePalette();
        Blocks.Initialize();
        cosmos.CreateSky();

        World.Seed = seed;

        Serialization.Decompress();

        // These populate the object pools
        ChunkData.SetLoadOrder();

        World.Spawn.Initialize(firstRun);

        // Initialize graphics
        edgeDetect.enabled    = Config.Outlines;
        edgeDetect.sampleDist = ((float)Screen.height / 1080f) * 1.4f;

        hbao         = mainCamera.GetComponent <HBAO>();
        hbao.enabled = Config.ContactShadows;

        RenderSettings.fog = true;

        if (Config.ShadowsEnabled)
        {
            if (Config.QualityLevel == Quality.Ultra)
            {
                sun.shadows  = LightShadows.Soft;
                moon.shadows = LightShadows.Soft;
            }
            else
            {
                sun.shadows  = LightShadows.Soft;
                moon.shadows = LightShadows.Soft;
            }
        }
        else
        {
            sun.shadows  = LightShadows.None;
            moon.shadows = LightShadows.None;
        }

        RenderSettings.ambientIntensity = 0f;
        sun.intensity = 0f;

        boids.StartBoids();

        firstRun = false;

        return(seed);
    }