Simulate() private method

private Simulate ( float t ) : void
t float
return void
示例#1
0
 static public int Simulate(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l);
             System.Single a1;
             checkType(l, 2, out a1);
             self.Simulate(a1);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 3)
         {
             UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l);
             System.Single a1;
             checkType(l, 2, out a1);
             System.Boolean a2;
             checkType(l, 3, out a2);
             self.Simulate(a1, a2);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 4)
         {
             UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l);
             System.Single a1;
             checkType(l, 2, out a1);
             System.Boolean a2;
             checkType(l, 3, out a2);
             System.Boolean a3;
             checkType(l, 4, out a3);
             self.Simulate(a1, a2, a3);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 5)
         {
             UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l);
             System.Single a1;
             checkType(l, 2, out a1);
             System.Boolean a2;
             checkType(l, 3, out a2);
             System.Boolean a3;
             checkType(l, 4, out a3);
             System.Boolean a4;
             checkType(l, 5, out a4);
             self.Simulate(a1, a2, a3, a4);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#2
0
 public void Init(Main main)
 {
     currentValue = UnityEngine.Random.Range (minimum, maximum);
     transform.localScale = new Vector3 (main.LocationWidthInMeters / 2, 1, 1);
     transform.localPosition = new Vector3 (transform.localScale.x, main.LocationHeightInMeters + 1, 0);
     particles = GetComponent<ParticleSystem> ();
     particles.emissionRate = CalculateCurrentEmissionRate();
     particles.Simulate (1);
     particles.Play ();
 }
示例#3
0
    void Splash()
    {
        ps = GetComponent<ParticleSystem> ();
        ps.Simulate (0);
        ps.Play ();

        GetComponent<Renderer> ().enabled = false;

        foreach (Collider2D other in Physics2D.OverlapCircleAll (new Vector2 (rb.position.x, rb.position.y), splashRadius))
            if (other.tag == "Enemy")
                other.gameObject.AddComponent<DoT> ().Initialize (dps, duration);
    }
 static public int Simulate__Single(IntPtr l)
 {
     try {
         UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l);
         System.Single a1;
         checkType(l, 2, out a1);
         self.Simulate(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#5
0
        public static void ClusterSimulate(this UnityEngine.ParticleSystem ps, float t)
        {
            var observer = validateCheck(ps);

            if (observer == null)
            {
                return;
            }
            ps.Simulate(t);
            FduParticleSystemOP op = new FduParticleSystemOP();

            op.operation = FduParticleSystemOP.Operation.simulate;
            op.paras     = new object[1];
            op.paras[0]  = t;
            observer.addOperation(op);
        }
示例#6
0
        public static void ClusterSimulate(this UnityEngine.ParticleSystem ps, float t, bool withChildren, bool restart, bool fixedTimeStep)
        {
            var observer = validateCheck(ps);

            if (observer == null)
            {
                return;
            }
            ps.Simulate(t, withChildren, restart, fixedTimeStep);
            FduParticleSystemOP op = new FduParticleSystemOP();

            op.operation = FduParticleSystemOP.Operation.simulate;
            op.paras     = new object[4];
            op.paras[0]  = t;
            op.paras[1]  = withChildren;
            op.paras[2]  = restart;
            op.paras[3]  = fixedTimeStep;
            observer.addOperation(op);
        }
 static public int Simulate(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 2)
         {
             UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l);
             System.Single a1;
             checkType(l, 2, out a1);
             self.Simulate(a1);
             return(0);
         }
         else if (argc == 3)
         {
             UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l);
             System.Single a1;
             checkType(l, 2, out a1);
             System.Boolean a2;
             checkType(l, 3, out a2);
             self.Simulate(a1, a2);
             return(0);
         }
         else if (argc == 4)
         {
             UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l);
             System.Single a1;
             checkType(l, 2, out a1);
             System.Boolean a2;
             checkType(l, 3, out a2);
             System.Boolean a3;
             checkType(l, 4, out a3);
             self.Simulate(a1, a2, a3);
             return(0);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
 static public int Simulate__Single__Boolean__Boolean__Boolean(IntPtr l)
 {
     try {
         UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l);
         System.Single a1;
         checkType(l, 2, out a1);
         System.Boolean a2;
         checkType(l, 3, out a2);
         System.Boolean a3;
         checkType(l, 4, out a3);
         System.Boolean a4;
         checkType(l, 5, out a4);
         self.Simulate(a1, a2, a3, a4);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    static int Simulate(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 2 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.ParticleSystem), typeof(float)))
        {
            UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.ToObject(L, 1);
            float arg0 = (float)LuaDLL.lua_tonumber(L, 2);

            try
            {
                obj.Simulate(arg0);
            }
            catch (Exception e)
            {
                return(LuaDLL.toluaL_exception(L, e));
            }

            return(0);
        }
        else if (count == 3 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.ParticleSystem), typeof(float), typeof(bool)))
        {
            UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.ToObject(L, 1);
            float arg0 = (float)LuaDLL.lua_tonumber(L, 2);
            bool  arg1 = LuaDLL.lua_toboolean(L, 3);

            try
            {
                obj.Simulate(arg0, arg1);
            }
            catch (Exception e)
            {
                return(LuaDLL.toluaL_exception(L, e));
            }

            return(0);
        }
        else if (count == 4 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.ParticleSystem), typeof(float), typeof(bool), typeof(bool)))
        {
            UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.ToObject(L, 1);
            float arg0 = (float)LuaDLL.lua_tonumber(L, 2);
            bool  arg1 = LuaDLL.lua_toboolean(L, 3);
            bool  arg2 = LuaDLL.lua_toboolean(L, 4);

            try
            {
                obj.Simulate(arg0, arg1, arg2);
            }
            catch (Exception e)
            {
                return(LuaDLL.toluaL_exception(L, e));
            }

            return(0);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: UnityEngine.ParticleSystem.Simulate");
        }

        return(0);
    }
示例#10
0
        static int _m_Simulate(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            UnityEngine.ParticleSystem __cl_gen_to_be_invoked = (UnityEngine.ParticleSystem)translator.FastGetCSObj(L, 1);


            int __gen_param_count = LuaAPI.lua_gettop(L);

            try {
                if (__gen_param_count == 2 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2))
                {
                    float t = (float)LuaAPI.lua_tonumber(L, 2);

                    __cl_gen_to_be_invoked.Simulate(t);



                    return(0);
                }
                if (__gen_param_count == 3 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3))
                {
                    float t            = (float)LuaAPI.lua_tonumber(L, 2);
                    bool  withChildren = LuaAPI.lua_toboolean(L, 3);

                    __cl_gen_to_be_invoked.Simulate(t, withChildren);



                    return(0);
                }
                if (__gen_param_count == 4 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4))
                {
                    float t            = (float)LuaAPI.lua_tonumber(L, 2);
                    bool  withChildren = LuaAPI.lua_toboolean(L, 3);
                    bool  restart      = LuaAPI.lua_toboolean(L, 4);

                    __cl_gen_to_be_invoked.Simulate(t, withChildren, restart);



                    return(0);
                }
                if (__gen_param_count == 5 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 3) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 5))
                {
                    float t             = (float)LuaAPI.lua_tonumber(L, 2);
                    bool  withChildren  = LuaAPI.lua_toboolean(L, 3);
                    bool  restart       = LuaAPI.lua_toboolean(L, 4);
                    bool  fixedTimeStep = LuaAPI.lua_toboolean(L, 5);

                    __cl_gen_to_be_invoked.Simulate(t, withChildren, restart, fixedTimeStep);



                    return(0);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.ParticleSystem.Simulate!"));
        }
示例#11
0
    // Private Functions
    // Awake(): is called at the start of the program
    void Awake()
    {
        // Singleton
        if (s_Instance == null)
            s_Instance = this;
        else
            Destroy(this.gameObject);

        float resultColor;
        // while: Initialise a color and checks if the color is acceptable
        // Since HSV input of colors is harder to implement,
        // it converts RGB into one OVERALL value and check if is within fMinimumArtilleryRGB and fMaximumArtilleryRGB range
        do
        {
            colorArtillery = new Color(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value, 1f);
            resultColor = colorArtillery.r + colorArtillery.g + colorArtillery.b;

        } while (resultColor < 3f * fMinimumArtilleryRGB || resultColor > 3f * fMaximumArtilleryRGB);

        // Read level specific settings from Settings.cs
        colorArtillery = Settings.s_EnvironmentColor;
        fNutrientsChance = Settings.s_fPlayerNutrientChance;
        fWallSidesSpeed = Settings.s_fSideWallSpeed;
        fWallBackgroundSpeed = Settings.s_fBackgroundSpeed;

        // Background particle system set-up
        bgParticleSystem = transform.GetChild(2).GetComponent<ParticleSystem>();
        // Use the same color as the wall-sides and background
        bgParticleSystem.startColor = colorArtillery;
        // Set the starting speed from Settings.cs
        bgParticleSystem.startSpeed = Settings.s_fParticleStartSpeedMultiplier;
        // Since prewarm of particle systems doesn't adapt to the new color, the particle system will be simulated beforehand
        bgParticleSystem.Clear();
        bgParticleSystem.Simulate(bgParticleSystem.startLifetime);
        bgParticleSystem.Play();

        mAnimate = new Animate(transform.GetChild(0)); // Pool_WallSidesRenderer
    }
	/// <summary>
	/// Enables or disables the specified particle system
	/// </summary>
	/// <param name="partSys">Particle system to enable.</param>
	/// <param name="toggle">If set to <c>true</c> system will be enabled.</param>
	void particleToggle(ParticleSystem partSys, bool toggle){
		if (toggle){
			partSys.enableEmission = toggle;
			partSys.Simulate(3);
			partSys.Play();
		}
		else {
			partSys.Stop();
			partSys.Clear();
		}

	}
示例#13
0
        // Build voxel object
        public override float Build(Storage voxels, Bounds bounds, Informer informer, object parameter)
        {
            // Check for given array
            if (voxels != null)
            {
                int width = voxels.Width;
                int height = voxels.Height;
                int depth = voxels.Depth;
                int sides = voxels.FacesCount;
                int x, y, z;

                // Check for non-empty array
                if (width * height * depth * sides > 0)
                {
                    if (particles == null)
                    {
                        // Calculate total scaling for one block
                        globalScaling = new Vector3(2.0f * bounds.extents.x / (float)width, 2.0f * bounds.extents.y / (float)height, 2.0f * bounds.extents.z / (float)depth);

                        // Check for given template container containing a particle system and its renderer
                        if (template != null && template.GetComponent <UnityEngine.ParticleSystem>() != null && template.GetComponent <Renderer>() != null && template.GetComponent <Renderer>().GetType() == typeof(ParticleSystemRenderer) && ((ParticleSystemRenderer)template.GetComponent <Renderer>()).mesh != null)
                        {
                            // Calculate offset and scaling vector for a particle mesh
                            offset     = -((ParticleSystemRenderer)template.GetComponent <Renderer>()).mesh.bounds.center;
                            scaling.x  = 0.5f / ((ParticleSystemRenderer)template.GetComponent <Renderer>()).mesh.bounds.extents.x;
                            scaling.y  = 0.5f / ((ParticleSystemRenderer)template.GetComponent <Renderer>()).mesh.bounds.extents.y;
                            scaling.z  = 0.5f / ((ParticleSystemRenderer)template.GetComponent <Renderer>()).mesh.bounds.extents.z;
                            offset.x  *= scaling.x;
                            offset.y  *= scaling.y;
                            offset.z  *= scaling.z;
                            scaling.x *= globalScaling.x;
                            scaling.y *= globalScaling.y;
                            scaling.z *= globalScaling.z;
                        }
                        else
                        {
                            // Unset translation und scaling
                            offset  = Vector3.zero;
                            scaling = Vector3.one;
                        }

                        // Add offset for half voxel
                        offset += new Vector3(0.5f * globalScaling.x, 0.5f * globalScaling.y, 0.5f * globalScaling.z);

                        // Move to match position of the original object
                        offset += bounds.center - gameObject.transform.position - bounds.extents;

                        // Create array to store particles to
                        particles      = new UnityEngine.ParticleSystem.Particle[voxels.Count];
                        particlesCount = 0;

                        // Calculate size of one particle
                        particleSize = Mathf.Max(globalScaling.x, Mathf.Max(globalScaling.y, globalScaling.z)) * sizeFactor;
                    }

                    // Check for main container
                    if (particles != null)
                    {
                        // Process all voxels
                        z = currentDepth;
                        //for (z = currentDepth; z < currentDepth + 1; ++z)
                        {
                            y = currentHeight;
                            //for (y = currentHeight; y < currentHeight + 1; ++y)
                            {
                                for (x = 0; x < width; ++x)
                                {
                                    // Retrieve material for current coordinate
                                    Material material = voxels.GetMaterial(x, y, z);

                                    // Check for valid voxel
                                    if (material != null)
                                    {
                                        // Calculate current voxel position
                                        Vector3 currentPosition = new Vector3((float)x * globalScaling.x + offset.x, (float)y * globalScaling.y + offset.y, (float)z * globalScaling.z + offset.z);

                                        // Set particle properties
                                        particles[particlesCount].position          = currentPosition;
                                        particles[particlesCount].startColor        = material.color;
                                        particles[particlesCount].remainingLifetime = 1000;
                                        particles[particlesCount].startLifetime     = 0;
                                        particles[particlesCount].randomSeed        = 0;
                                        particles[particlesCount].rotation          = 0;
                                        particles[particlesCount].startSize         = particleSize;
                                        particles[particlesCount].velocity          = Vector3.zero;
                                        particles[particlesCount].angularVelocity   = 0;

                                        // Increase number of particles
                                        ++particlesCount;
                                    }
                                }
                            }

                            // Increase to next height line
                            if (++currentHeight >= height)
                            {
                                // Increase to next depth slice
                                ++currentDepth;
                                currentHeight = 0;
                            }
                        }

                        // Return current progress when building has not been finished
                        if (currentDepth < depth)
                        {
                            return((float)currentDepth / (float)depth);
                        }
                    }
                }
            }

            // Check for particles
            if (particles != null && particlesCount > 0)
            {
                GameObject particlesContainer;

                // Clone existing or create new container
                if (template != null)
                {
                    particlesContainer      = (GameObject)Instantiate(template);
                    particlesContainer.name = targetName;
                    particlesContainer.SetActive(true);
                }
                else
                {
                    particlesContainer = new GameObject(targetName);
                }

                if (particlesContainer != null)
                {
                    // Copy position and unset scale and rotation
                    particlesContainer.transform.localPosition = gameObject.transform.position;
                    particlesContainer.transform.localScale    = Vector3.one;
                    particlesContainer.transform.localRotation = Quaternion.identity;

                    // Add particles system
                    UnityEngine.ParticleSystem particleSystem = particlesContainer.GetComponent <UnityEngine.ParticleSystem>();
                    if (particleSystem == null)
                    {
                        particleSystem = particlesContainer.AddComponent <UnityEngine.ParticleSystem>();
                    }

                    if (particleSystem != null)
                    {
                        // Add particle system renderer, if there is none
                        ParticleSystemRenderer particleSystemRenderer = particlesContainer.GetComponent <ParticleSystemRenderer>();
                        if (particleSystemRenderer == null)
                        {
                            particleSystemRenderer = particlesContainer.AddComponent <ParticleSystemRenderer>();

                            // Set render properties
                            if (particleSystemRenderer != null)
                            {
                                particleSystemRenderer.cameraVelocityScale = 0;
                                particleSystemRenderer.lengthScale         = 0;
                                particleSystemRenderer.maxParticleSize     = 1000;
                                particleSystemRenderer.velocityScale       = 0;
                            }
                        }

                        UnityEngine.ParticleSystem.EmissionModule emission = particleSystem.emission;
                        emission.rateOverTime = new UnityEngine.ParticleSystem.MinMaxCurve(10, new AnimationCurve());
                        emission.enabled      = true;

                        // Set properties for static particles
                        var mainModule = particleSystem.main;
                        mainModule.playOnAwake     = false;
                        mainModule.maxParticles    = particlesCount;
                        mainModule.simulationSpeed = 1;
                        mainModule.startSpeed      = 0;
                        mainModule.startLifetime   = 1;
                        mainModule.startSize       = bounds.extents.magnitude * 2;
                        mainModule.startDelay      = 0;
                        mainModule.gravityModifier = 0;
                        mainModule.simulationSpace = ParticleSystemSimulationSpace.Local;

                        // Force a simulation to calculate boundaries
                        particleSystem.Simulate(particleSystem.main.startLifetime.constant);

                        // Set particles
                        particleSystem.SetParticles(particles, particlesCount);

                        // Stop automatic simulation
                        particleSystem.Stop();
                        emission.enabled = false;
                    }

#if UNITY_EDITOR
                    // Add object creation undo operation
                    if (!Application.isPlaying)
                    {
                        UnityEditor.Undo.RegisterCreatedObjectUndo(particlesContainer, "\"" + targetName + "\" Creation");
                    }
#endif

                    // Execute informer callback
                    if (informer != null)
                    {
                        informer(new UnityEngine.Object[] { particlesContainer }, parameter);
                    }
                }
            }

            // Reset current processing data
            currentDepth  = 0;
            currentHeight = 0;
            particles     = null;

            return(1);
        }
	static public int Simulate(IntPtr l) {
		try {
			#if DEBUG
			var method = System.Reflection.MethodBase.GetCurrentMethod();
			string methodName = GetMethodName(method);
			#if UNITY_5_5_OR_NEWER
			UnityEngine.Profiling.Profiler.BeginSample(methodName);
			#else
			Profiler.BeginSample(methodName);
			#endif
			#endif
			int argc = LuaDLL.lua_gettop(l);
			if(argc==2){
				UnityEngine.ParticleSystem self=(UnityEngine.ParticleSystem)checkSelf(l);
				System.Single a1;
				checkType(l,2,out a1);
				self.Simulate(a1);
				pushValue(l,true);
				return 1;
			}
			else if(argc==3){
				UnityEngine.ParticleSystem self=(UnityEngine.ParticleSystem)checkSelf(l);
				System.Single a1;
				checkType(l,2,out a1);
				System.Boolean a2;
				checkType(l,3,out a2);
				self.Simulate(a1,a2);
				pushValue(l,true);
				return 1;
			}
			else if(argc==4){
				UnityEngine.ParticleSystem self=(UnityEngine.ParticleSystem)checkSelf(l);
				System.Single a1;
				checkType(l,2,out a1);
				System.Boolean a2;
				checkType(l,3,out a2);
				System.Boolean a3;
				checkType(l,4,out a3);
				self.Simulate(a1,a2,a3);
				pushValue(l,true);
				return 1;
			}
			else if(argc==5){
				UnityEngine.ParticleSystem self=(UnityEngine.ParticleSystem)checkSelf(l);
				System.Single a1;
				checkType(l,2,out a1);
				System.Boolean a2;
				checkType(l,3,out a2);
				System.Boolean a3;
				checkType(l,4,out a3);
				System.Boolean a4;
				checkType(l,5,out a4);
				self.Simulate(a1,a2,a3,a4);
				pushValue(l,true);
				return 1;
			}
			pushValue(l,false);
			LuaDLL.lua_pushstring(l,"No matched override function Simulate to call");
			return 2;
		}
		catch(Exception e) {
			return error(l,e);
		}
		#if DEBUG
		finally {
			#if UNITY_5_5_OR_NEWER
			UnityEngine.Profiling.Profiler.EndSample();
			#else
			Profiler.EndSample();
			#endif
		}
		#endif
	}