Beispiel #1
0
        // Use this for initialization
        void Start()
        {
            List <StructureSource> sources = new List <StructureSource>();

            foreach (GameObject g in GameObject.FindGameObjectsWithTag("Source"))
            {
                sources.Add(g.GetComponent <StructureSource>());
            }

            List <StructureAttractor> Attractors = new List <StructureAttractor>();

            foreach (GameObject g in GameObject.FindGameObjectsWithTag("Attractor"))
            {
                Attractors.Add(g.GetComponent <StructureAttractor>());
            }

            int lastLevel         = 0;
            ParticleStatistics ps = GameObject.Find("ParticleManager").GetComponentInChildren <ParticleStatistics>();

            ps.ComputeModifierStatistics(ShaderConstants.PARTICLE_MODIFIER_TARGET, (s, e) =>
            {
                int level = (int)Mathf.Log(((ParticleStatisticsModifierEventArgs)e).sum[0], 1.03f);
                if (level - lastLevel != 0)
                {
                    lastLevel = level;
                    foreach (StructureSource c in sources)
                    {
                        if (level > 100 && level % 2 == 0 && c.spawnPeriod > minSpawnPeriod)
                        {
                            c.spawnPeriod--;
                        }
                    }
                }
            });
        }
Beispiel #2
0
        void Start()
        {
            ParticleManager pm = GameObject.Find("ParticleManager").GetComponent <ParticleManager>();

            cs = pm.GetComponentInChildren <ComputeSource>();
            ps = pm.GetComponentInChildren <ParticleStatistics>();

            //Just use ananyomous event handlers
            ps.ComputeModifierStatistics((s, e) =>
            {
                AliveParticlesText.text = ((ParticleStatisticsModifierEventArgs)e).sum[2].ToString();
            });

            ps.ComputeModifierStatistics(ShaderConstants.PARTICLE_MODIFIER_TARGET, (s, e) =>
            {
                TargetParticlesText.text = ((ParticleStatisticsModifierEventArgs)e).sum[0].ToString();
            });

            StartCoroutine(SlowUpdate());
        }