Example #1
0
        public FractalNoise(float inH, float inLacunarity, float inOctaves, PerlinSKYMASTER noise)
        {
            m_Lacunarity = inLacunarity;
            m_Octaves    = inOctaves;
            m_IntOctaves = (int)inOctaves;
            m_Exponent   = new float[m_IntOctaves + 1];
            float frequency = 1.0F;

            for (int i = 0; i < m_IntOctaves + 1; i++)
            {
                m_Exponent[i] = (float)Math.Pow(m_Lacunarity, -inH);
                frequency    *= m_Lacunarity;
            }

            if (noise == null)
            {
                m_Noise = new PerlinSKYMASTER();
            }
            else
            {
                m_Noise = noise;
            }
        }
Example #2
0
        // Update is called once per frame
        void Update()
        {
            if (noise == null)
            {
                noise = new PerlinSKYMASTER();
            }

            float timex = Time.time * speed * 0.1365143f;
            float timey = Time.time * speed * 1.21688f;
            float timez = Time.time * speed * 2.5564f;

            if (Time.fixedTime - cur_time > delay & !emits)
            {
                start_emit_time = Time.fixedTime;
                emits           = true;
                cur_time        = Time.fixedTime;
            }

            if (emits)
            {
                if (Time.fixedTime - start_emit_time <= emit_time)
                {
//				Vector3 offset = new Vector3(noise.Noise(timex + his_light.intensity, timex + position.y, timex + position.z),
//					                             noise.Noise(timey + his_light.intensity, timey + position.y, timey + position.z),
//					                             noise.Noise(timez + his_light.intensity, timez + position.y, timez + position.z));
//				position += ((offset+(offset_bias1*i*0.01f)) * scale * ((float)i * oneOverZigs));

                    this_light.intensity = Random.Range(1, 3) * noise.Noise(timex + this_light.intensity, timey + this_light.intensity, timez + this_light.intensity);
                }
                else
                {
                    emits = false;
                    this_light.intensity = 0;
                    start_emit_time      = 0;
                }
            }
        }
Example #3
0
        void Update()
        {
            //v2.3
            if (Emitter == null)
            {
                Start();                 //v2.3
                if (Emitter == null)
                {
                    Debug.Log("Add a Shuriken particle to the object with the Lighting script first");
                    return;
                }
            }

            if (noise == null)
            {
                noise = new PerlinSKYMASTER();
            }

            if (is_parent | (!is_parent & Energized & current_depth < max_depth))
            {
                target1 = GameObject.FindGameObjectsWithTag("Conductor");

                if (target1 != null)
                {
                    if (target1.Length > 0)
                    {
                        int Choose = Random.Range(0, target1.Length);
                        if (Random_target)
                        {
                            if (Time.fixedTime - Time_count > Change_target_delay)
                            {
                                if (Vector3.Distance(target1 [Choose].transform.position, this.transform.position) < Affect_dist)
                                {
                                    target = target1 [Choose].transform;
                                }
                                else
                                {
                                    //GetComponent<ParticleEmitter>().ClearParticles();
                                    Emitter.Clear();                                     //v2.3
                                }
                                Time_count = Time.fixedTime;

                                //v1.4
                                //disable after N targets are found and hit
                                if (!is_parent & Energized & current_depth <max_depth& current_target_count> max_target_count)
                                {
                                    Energized = false;
                                }
                                current_target_count++;
                            }
                            if (target != null)
                            {
                                if (Vector3.Distance(target.position, this.transform.position) > Affect_dist)
                                {
                                    target = null;
                                    //GetComponent<ParticleEmitter>().ClearParticles();
                                    Emitter.Clear();                                     //v2.3
                                }
                            }
                        }
                        else
                        {
                            target = null;
                            //GetComponent<ParticleEmitter>().ClearParticles();
                            Emitter.Clear();                             //v2.3

                            int count_each = 0;
                            foreach (GameObject TRANS in target1)
                            {
                                if (Vector3.Distance(TRANS.transform.position, this.transform.position) < Affect_dist)
                                {
                                    target = TRANS.transform;
                                }
                                count_each = count_each + 1;
                            }

                            //v1.4
                            //disable after N targets are found and hit
                            if (!is_parent & Energized & current_depth <max_depth& current_target_count> max_target_count)
                            {
                                Energized = false;
                            }
                            current_target_count++;
                        }

                        float timex = Time.time * speed * 0.1365143f;
                        float timey = Time.time * speed * 1.21688f;
                        float timez = Time.time * speed * 2.5564f;

                        if (target != null)
                        {
                            for (int i = 0; i < particles.Length; i++)
                            {
                                Vector3 position = Vector3.Lerp(transform.position, target.position, oneOverZigs * (float)i);
                                Vector3 offset   = new Vector3(noise.Noise(timex + position.x, timex + position.y, timex + position.z),
                                                               noise.Noise(timey + position.x, timey + position.y, timey + position.z),
                                                               noise.Noise(timez + position.x, timez + position.y, timez + position.z));
                                position += (offset * scale * ((float)i * oneOverZigs));

                                particles [i].position   = position;
                                particles [i].startColor = Color.white;                                //particles [i].color = Color.white; //v2.3
                                //particles[i].energy = Particle_energy; //v2.3
                                particles [i].startLifetime = Particle_energy;                         //??
                            }

                            //v1.4
                            ChainLightningShuriken_SM next_in_Chain = target.gameObject.GetComponent(typeof(ChainLightningShuriken_SM)) as ChainLightningShuriken_SM;
                            //Energize target
                            if (next_in_Chain == null)
                            {
                                next_in_Chain = target.gameObject.GetComponentInChildren(typeof(ChainLightningShuriken_SM)) as ChainLightningShuriken_SM;
                            }

                            if (next_in_Chain != null)
                            {
                                if (!next_in_Chain.is_parent)
                                {
                                    next_in_Chain.Energized     = true;
                                    next_in_Chain.max_depth     = max_depth;
                                    next_in_Chain.current_depth = current_depth + 1;
                                }
                            }

                            //GetComponent<ParticleEmitter>().particles = particles;  //v2.3
                            Emitter.SetParticles(particles, particles.Length);       //v2.3

                            if (particles.Length >= 2)                               //if (GetComponent<ParticleEmitter>().particleCount >= 2)  //v2.3
                            {
                                if (startLight)
                                {
                                    startLight.transform.position = particles [0].position;
                                }

                                int get_in = 1;
                                get_in = Random.Range(1, optimize_factor);
                                if (endLight)
                                {
                                    if (get_in == 1 & target != null)
                                    {
                                        endLight.enabled = true;
                                        endLight.gameObject.SetActive(true);
                                        endLight.transform.position = particles [particles.Length - 1].position;
                                    }
                                    else
                                    {
                                        endLight.enabled = false;
                                    }
                                }
                            }
                            else
                            {
                                endLight.enabled = false;
                            }
                        }
                        else
                        {
                            for (int i = 0; i < particles.Length; i++)
                            {
                                particles [i].position = Vector3.zero;
                            }
                            //GetComponent<ParticleEmitter>().particles = particles;
                            Emitter.SetParticles(particles, particles.Length);                             //v2.3
                        }

                        if (endLight & target == null)
                        {
                            endLight.enabled = false;
                            endLight.gameObject.SetActive(false);
                        }
                    } //END check if targets > 0
                }
            }         //END check if parent
            else
            {
                for (int i = 0; i < particles.Length; i++)
                {
                    particles[i].position = Vector3.zero;
                }
                //GetComponent<ParticleEmitter>().particles = particles;
                Emitter.SetParticles(particles, particles.Length);               //v2.3
            }
        }