//triggered by activating
    public void EnableLight(Naivis source, Color lightColorSource)
    {
        if (!Triggered)
        {
            Triggered    = true;
            naivisSource = source;

            GameObject temp = Instantiate(lightParticles, transform.position, transform.rotation) as GameObject;
            particleCreated = temp.GetComponent <ParticleSystem> ();
            particleCreated.transform.localScale = Vector3.one * scaleMultiplierVisualLight;
            particleCreated.transform.SetParent(transform.parent);

            shapeMod                   = particleCreated.transform.GetChild(0).GetComponent <ParticleSystem> ().shape;
            shapeMod.length            = lightData.ParticleDustLength;
            particleCreated.startColor = lightColorSource;


            particleCreated.Play();
            particleCreated.transform.localEulerAngles = lightData.LightAngle;
            particleCreated.transform.localScale       = new Vector3(particleCreated.transform.localScale.x, lightData.MaxScale, particleCreated.transform.localScale.z);
            transformUp = particleCreated.transform.up;
            isRayCasted = false;
            MovingLight();
        }
    }
Example #2
0
    //trigger this light by flag(t/f)
    public void HasLight(bool flag, Color lightSourceColor, Naivis source = null)
    {
        naivisSource          = source;
        this.lightSourceColor = lightSourceColor;
        if (flag)
        {
            LightHolder.EnableLight(naivisSource, lightSourceColor);

            GameObject x = Instantiate(SparkyGO) as GameObject;
            x.transform.SetParent(this.transform.parent);
            x.transform.position = transform.position;
            Sparky = x.GetComponent <ParticleSystem> ();
            Sparky.Play();
            if (isChangeMaterial)
            {
                shaderHandler.originValue = emissiveLevel;
                shaderHandler.TriggerActivation(true);
            }
        }
        else
        {
            LightHolder.DisableLight();
            if (isChangeMaterial)
            {
                shaderHandler.TriggerActivation(false);
            }
            if (Sparky != null)
            {
                Sparky.Stop();
                Destroy(Sparky.gameObject, 5f);
            }
        }
    }
Example #3
0
    public override void Trigger(GameObject Actor)
    {
        if (Actor != null)
        {
            ltScript = Actor.GetComponent <Naivis>();
            if (ltScript == null)
            {
                Debug.LogError("Actor is does not have Naivis");
                return;
            }

            ltScript.ForcedTurnOffLight();
        }
    }
    public void DisableLight()
    {
        if (Triggered)
        {
            Triggered    = false;
            naivisSource = null;

            Material mat         = particleCreated.GetComponent <ParticleSystemRenderer>().material;
            Color    sourceColor = mat.GetColor("_TintColor");
            Color    targetColor = Color.clear;
            mat.SetColor("_TintColor", sourceColor);

            cAnimator.Trigger(sourceColor, targetColor, particleCreated.gameObject);

            mat = particleCreated.transform.GetChild(0).GetComponent <ParticleSystemRenderer>().material;
            mat.SetColor("_TintColor", sourceColor);

            cAnimator.Trigger(sourceColor, targetColor, particleCreated.transform.GetChild(0).gameObject);

            CastRay(false, Color.clear);
            particleCreated.Stop();
            Destroy(particleCreated.gameObject, 5f);
        }
    }