Beispiel #1
0
    private void OnEnable()
    {
        lighting = GetComponentInParent <CaveLighting>();
        Vector3 size = GetComponent <BoxCollider>().size;

        depth = size.z;
    }
    private void OnPreRender()
    {
        FogMode fogMode = FogMode.ExponentialSquared;

        fogColor   = Color.Lerp(defaultFogColor, creditsFogColor, MenuCameraEffects.instance.creditsAdjust);
        fogDensity = defaultFogDensity;
        if (player != null && player.cameraController.waterSensor != null && player.cameraController.waterSensor.waterBody != null)
        {
            Vector3 velocity;
            float   num = player.cameraController.waterSensor.waterBody.SampleDepth(base.transform.position, out velocity) * 10f - 0.5f;
            fogColor   = Color.Lerp(fogColor, waterFogColor, num);
            fogDensity = Mathf.Lerp(defaultFogDensity, waterFogDensity, num);
            if (num > 0f)
            {
                RenderSettings.fogMode = FogMode.Exponential;
            }
        }
        if (player != null)
        {
            cave = CaveLighting.GetCaveForPlayer(player);
            if (cave != null)
            {
                fogDensity *= Mathf.Lerp(1f, 0.1f, cave.GetPlaseForPlayer(player));
            }
        }
        if (RenderSettings.fogMode != fogMode)
        {
            RenderSettings.fogMode = fogMode;
        }
        if (RenderSettings.fogColor != fogColor)
        {
            RenderSettings.fogColor = fogColor;
        }
        if (RenderSettings.fogDensity != fogDensity)
        {
            RenderSettings.fogDensity = fogDensity;
        }
        for (int i = 0; i < Human.all.Count; i++)
        {
            if (Human.all[i].player.nametag != null)
            {
                Human.all[i].player.nametag.Align(base.transform);
            }
        }
    }