public void Toggle(bool _isOn)
 {
     if (_isOn && !isRunningCR)
     {
         isOn = _isOn;
         StartCoroutine(Animate());
         lightSource.Trigger(_isOn);
     }
     else
     {
         isOn = _isOn;
         lightSource.Trigger(_isOn);
     }
 }
Exemple #2
0
    private void ChangeLightState(LightMountState newState)
    {
        if (!EnsureInit())
        {
            return;
        }

        if (newState == LightMountState.MissingBulb)
        {
            lightSource.Trigger(false);
            spriteRenderer.sprite        = GetSprite(spriteListMissingBulb);
            spriteRendererLightOn.sprite = null;
            integrity.soundOnHit         = "";
        }
        else if (newState == LightMountState.Broken)
        {
            lightSource.Trigger(false);
            spriteRenderer.sprite        = GetSprite(spriteListBroken);
            spriteRendererLightOn.sprite = null;
            integrity.soundOnHit         = "GlassStep";
        }
        else if (newState == LightMountState.Off)
        {
            lightSource.Trigger(false);
            spriteRenderer.sprite        = GetSprite(spriteListFull);
            spriteRendererLightOn.sprite = null;
            integrity.soundOnHit         = "GlassHit";
        }
        else if (newState == LightMountState.On)
        {
            lightSource.Trigger(true);
            spriteRenderer.sprite        = GetSprite(spriteListFull);
            spriteRendererLightOn.sprite = GetSprite(spriteListLightOn);
            integrity.soundOnHit         = "GlassHit";
        }
    }
    public void Toggle(bool _isOn)
    {
        if (_isOn && !isRunningCR)
        {
            isOn = _isOn;
            if (!gameObject.activeInHierarchy)
            {
                return;
            }

            StartCoroutine(Animate());
        }
        else
        {
            isOn = _isOn;
        }

        if (lightSource)
        {
            lightSource.Trigger(_isOn);
        }
    }