Exemplo n.º 1
0
    /// <summary>
    /// Changes the status of Light component attached to Player
    /// <param name="enabled">If true, the lights are toggled on.</param>
    /// <param name="percent">The strength percentage of the lights. 0 = off 1 = original strength</param>
    /// </summary>
    private void ToggleLights(bool enabled, float percent)
    {
        foreach (Light light in this.lightsToToggle.GetComponentsInChildren <Light>())
        {
            // Skip VeryClose Light
            //Light light = childComponent.GetComponent<Light>();
            if (light == null || light.name == "VeryClose Light")
            {
                continue;
            }

            //light.enabled = enabled;

            // Set the range of the light to the given percent
            LightRangeModifier rangeModifier = light.GetComponent <LightRangeModifier>();
            if (rangeModifier)
            {
                // Turn off the player's light
                //if (!enabled) { rangeModifier.TurnOffLight(); }
                rangeModifier.ActiveLights = enabled;
                rangeModifier.PercentRange = percent;
            }
        }
        // Update the status of the lights
        this.lightsEnabled = enabled;

        // Debug.Log("Toggle lights");
    }
    /// <summary>
    /// Changes the status of Light component attached to Player
    /// <param name="enabled">If true, the lights are toggled on.</param>
    /// <param name="percent">The strength percentage of the lights. 0 = off 1 = original strength</param>
    /// </summary>
    private void ToggleLights(bool enabled, float percent)
    {
        foreach (Light light in this.lightsToToggle.GetComponentsInChildren <Light>())
        {
            // Skip VeryClose Light
            if (light == null || light.name == "VeryClose Light")
            {
                continue;
            }

            // Set the range of the light to the given percent
            LightRangeModifier rangeModifier = light.GetComponent <LightRangeModifier>();
            if (rangeModifier)
            {
                rangeModifier.ActiveLights = enabled;
                rangeModifier.PercentRange = percent;
            }
        }
        // Update lights' status
        this.lightsEnabled = enabled;
    }