Ejemplo n.º 1
0
    private void OnMapComplete(string mapname)
    {
        //everything needed was loaded, no need to keep the current cache
        //FileCache.Report();
        FileCache.ClearAll();

        //add sounds to playlist (and cache)
        foreach (var sound in world.sounds)
        {
            sounds.Add(sound, null);
        }
        Debug.Log(sounds.Count() + " sounds loaded");


        if (WeatherEffect.HasMap(mapname))
        {
            //create sky
            sky = new Sky();
            //initialize clouds
            sky.Initialize(mapname);
        }
        else
        {
            //no weather effects, set sky color to blueish
            //Camera.main.backgroundColor = new Color(0.4f, 0.6f, 0.8f, 1.0f);
        }

        //add lights
        GameObject lightsParent = new GameObject("_lights");

        lightsParent.transform.parent = mapParent.transform;

        foreach (var light in world.lights)
        {
            var lightObj = new GameObject(light.name);
            lightObj.transform.SetParent(lightsParent.transform);
            Light lightComponent = lightObj.AddComponent <Light>();
#if UNITY_EDITOR
            lightComponent.lightmapBakeType = LightmapBakeType.Baked;
#endif

            lightComponent.color = new Color(light.color[0], light.color[1], light.color[2]);
            lightComponent.range = light.range;
            Vector3 position = new Vector3(light.pos[0] + width, -light.pos[1], light.pos[2] + height);
            lightObj.transform.position = position;
        }
    }