static int Emit(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem)); int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); obj.Emit(arg0); return(0); } else if (count == 3) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem)); UnityEngine.ParticleSystem.EmitParams arg0 = StackTraits <UnityEngine.ParticleSystem.EmitParams> .Check(L, 2); int arg1 = (int)LuaDLL.luaL_checknumber(L, 3); obj.Emit(arg0, arg1); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.ParticleSystem.Emit")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public void shoot(bool _fire, ParticleSystem _projectile) { rotate(gattlingGunData.warmupDelay); if (_fire) { if (gattlingGunData.warmupDelay < gattlingGunData.warmState) { gattlingGunData.warmupDelay++; return; } gattlingGunData.currentShotDelay--; if (gattlingGunData.currentShotDelay <= 0) { _projectile.Emit(1); gattlingGunData.currentShotDelay = gattlingGunData.shotDelayMax; } } else { if (gattlingGunData.warmupDelay > gattlingGunData.coldState) { gattlingGunData.warmupDelay--; } } }
// Use this for initialization void Start () { rend = GetComponent<SpriteRenderer>(); jumpParticle = GetComponent<ParticleSystem>(); startCol = rend.material.color; fadeCol = new Color(startCol.r, startCol.g, startCol.b, 0); jumpParticle.Emit(6); }
static int Emit(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.ParticleSystem), typeof(int))) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.ToObject(L, 1); int arg0 = (int)LuaDLL.lua_tonumber(L, 2); obj.Emit(arg0); return(0); } else if (count == 3 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.ParticleSystem), typeof(UnityEngine.ParticleSystem.EmitParams), typeof(int))) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.ToObject(L, 1); UnityEngine.ParticleSystem.EmitParams arg0 = (UnityEngine.ParticleSystem.EmitParams)ToLua.ToObject(L, 2); int arg1 = (int)LuaDLL.lua_tonumber(L, 3); obj.Emit(arg0, arg1); return(0); } else { return(LuaDLL.tolua_error(L, "invalid arguments to method: UnityEngine.ParticleSystem.Emit")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int QPYX_Emit_YXQP(IntPtr L_YXQP) { try { int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP); if (QPYX_count_YXQP == 2) { UnityEngine.ParticleSystem QPYX_obj_YXQP = (UnityEngine.ParticleSystem)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.ParticleSystem)); int QPYX_arg0_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 2); QPYX_obj_YXQP.Emit(QPYX_arg0_YXQP); return(0); } else if (QPYX_count_YXQP == 3) { UnityEngine.ParticleSystem QPYX_obj_YXQP = (UnityEngine.ParticleSystem)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.ParticleSystem)); UnityEngine.ParticleSystem.EmitParams QPYX_arg0_YXQP = StackTraits <UnityEngine.ParticleSystem.EmitParams> .Check(L_YXQP, 2); int QPYX_arg1_YXQP = (int)LuaDLL.luaL_checknumber(L_YXQP, 3); QPYX_obj_YXQP.Emit(QPYX_arg0_YXQP, QPYX_arg1_YXQP); return(0); } else { return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: UnityEngine.ParticleSystem.Emit")); } } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
void Start() { particleSystem = gameObject.GetComponent<ParticleSystem>(); const int maxParticle = 1000; particleSystem.maxParticles = maxParticle; particles = new ParticleSystem.Particle[maxParticle]; particleData = new ParticleData[maxParticle]; particleSystem.Emit(maxParticle); particleSystem.GetParticles(particles); for (int i = 0; i < maxParticle; i++) { particles[i].position = Vector3.zero; particles[i].velocity = Vector3.zero; particles[i].size = 0.1f; float rotateX = Random.value * 360; float rotateY = Random.value * 180; float rotateZ = Random.value * 360; Quaternion q = new Quaternion(); q.eulerAngles = new Vector3(rotateX, rotateY, rotateZ); particleData[i].direction = q * Vector3.forward; particleData[i].speed = 1; particleData[i].cos = i / ((float)maxParticle / 10); } particleSystem.SetParticles(particles, maxParticle); }
static public int Emit(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 2) { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); self.Emit(a1); pushValue(l, true); return(1); } else if (argc == 3) { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); UnityEngine.ParticleSystem.EmitParams a1; checkValueType(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); self.Emit(a1, a2); 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)); } }
private void SpawnConnection(JumpConnection connection, ParticleSystem PS) { Vector3 startPos = galaxy.Systems[connection.StartID].Position; Vector3 endPos = galaxy.Systems[connection.EndID].Position; for (int i = 0; i < lineParticleCount; i++) PS.Emit(Vector3.Lerp(startPos * scale + transform.position, endPos * scale + transform.position, (float)((float)(i + 1f) / (float)(lineParticleCount + 1f))), Vector3.zero, particleSize * 0.33f, float.MaxValue, Color.white); }
// Use this for initialization void Awake() { TimeStart = Time.time; MyParticles = gameObject.GetComponent<ParticleSystem> (); MyParticles.startLifetime = Random.Range (3f,10f); MyParticles.loop = false; MyParticles.Emit(InitialEmmision/5); MyParticles.enableEmission = true; Destroy (gameObject, TimeTotal); }
// Use this for initialization void Awake() { particles = GetComponentInChildren<ParticleSystem>(); for (int i=0; i<nrOfDustParticles; i++){ particles.startSize = Random.Range (1, maxSize)/(maxSize*2.5f); particles.startSpeed = Random.Range (1,maxSpeed); particles.Emit(1); } }
public void Init(Vector3 pos, int maxParticles, Color color) { transform.localPosition = pos + Vector3.up * 0.25f; particles = GetComponent<ParticleSystem>(); particles.GetComponent<Renderer>().sortingLayerName = "Ui"; particles.startColor = color; particles.Emit(maxParticles); Destroy(gameObject, 1f); }
void play(ParticleSystem ps, ParticleInfos pi){ //ps.duration = pi.duration / music.tempo * 60; ps.Stop (); ps.startSize = pi.size; ps.startSpeed = pi.speed; if(pi.quantity > 0) ps.Emit (pi.quantity); ps.emissionRate = pi.timeQuantity; ps.Play (); }
public void Init(Vector3 startPos, Vector3 endPos, float duration, int maxParticles, Color color) { startPos += Vector3.up * 0.25f; particles = GetComponent<ParticleSystem>(); particles.GetComponent<Renderer>().sortingLayerName = "Ui"; particles.startColor = color; particles.Emit(maxParticles); StartCoroutine(Move(startPos, endPos, duration)); }
static int _m_Emit(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)) { int count = LuaAPI.xlua_tointeger(L, 2); __cl_gen_to_be_invoked.Emit(count); return(0); } if (__gen_param_count == 3 && translator.Assignable <UnityEngine.ParticleSystem.EmitParams>(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3)) { UnityEngine.ParticleSystem.EmitParams emitParams; translator.Get(L, 2, out emitParams); int count = LuaAPI.xlua_tointeger(L, 3); __cl_gen_to_be_invoked.Emit(emitParams, count); 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.Emit!")); }
static public int Emit__Int32(IntPtr l) { try { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); self.Emit(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
private void Emit(ParticleSystem p, ref Vector3 pos) { int count = UnityEngine.Random.Range(2, 5); while (count != 0) { float yVelocity = UnityEngine.Random.Range(1.0f, 3.0f); float zVelocity = UnityEngine.Random.Range(-2.0f, 2.0f); float xVelocity = UnityEngine.Random.Range(-2.0f, 2.0f); const float lifetime = 0.75f;// UnityEngine.Random.Range(0.25f, 0.75f); float size = UnityEngine.Random.Range(0.05f, 0.1f); p.Emit(pos, new Vector3(xVelocity, yVelocity, zVelocity), size, lifetime, color); count--; } }
void Start() { mf = GetComponent<SkinnedMeshRenderer>(); ps = GetComponent<ParticleSystem> (); origVerts = mf.sharedMesh.vertices; int i = 0; while (i < origVerts.Length) { ps.Emit(origVerts[i], Vector3.zero, size, float.PositiveInfinity, Color.white); i++; } particles = new ParticleSystem.Particle[ps.particleCount]; ps.GetParticles (particles); }
public static void ClusterEmit(this UnityEngine.ParticleSystem ps, int count) { var observer = validateCheck(ps); if (observer == null) { return; } ps.Emit(count); FduParticleSystemOP op = new FduParticleSystemOP(); op.operation = FduParticleSystemOP.Operation.emit; op.paras = new object[1]; op.paras[0] = count; observer.addOperation(op); }
static public int Emit(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.Int32 a1; checkType(l,2,out a1); self.Emit(a1); pushValue(l,true); return 1; } else if(argc==3){ UnityEngine.ParticleSystem self=(UnityEngine.ParticleSystem)checkSelf(l); UnityEngine.ParticleSystem.EmitParams a1; checkValueType(l,2,out a1); System.Int32 a2; checkType(l,3,out a2); self.Emit(a1,a2); pushValue(l,true); return 1; } pushValue(l,false); LuaDLL.lua_pushstring(l,"No matched override function Emit 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 }
static public int Emit(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (matchType(l, argc, 2, typeof(UnityEngine.ParticleSystem.Particle))) { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); UnityEngine.ParticleSystem.Particle a1; checkValueType(l, 2, out a1); self.Emit(a1); pushValue(l, true); return(1); } else if (matchType(l, argc, 2, typeof(int))) { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); self.Emit(a1); pushValue(l, true); return(1); } else if (argc == 6) { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); UnityEngine.Vector3 a1; checkType(l, 2, out a1); UnityEngine.Vector3 a2; checkType(l, 3, out a2); System.Single a3; checkType(l, 4, out a3); System.Single a4; checkType(l, 5, out a4); UnityEngine.Color32 a5; checkValueType(l, 6, out a5); self.Emit(a1, a2, a3, a4, a5); 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)); } }
void Start() { mf = GetComponent<MeshFilter>(); ps = GetComponent<ParticleSystem> (); scale = this.transform.localScale; origVerts = mf.sharedMesh.vertices; newVerts = new Vector3[origVerts.Length]; int i = 0; while (i < origVerts.Length) { ps.Emit(origVerts[i], Vector3.zero, 1f, float.PositiveInfinity, Color.white); i++; } particles = new ParticleSystem.Particle[ps.particleCount]; ps.GetParticles (particles); }
// Update is called once per frame void Update () { if (Input.GetKey (KeyCode.Joystick1Button2) && DoublePush == false) { emitter = GetComponent<ParticleSystem> (); // Emit one particle at the origin, shooting straight up. // The size of the particle is 0.2 and it will live 2 seconds long. emitter.Emit (new Vector3 (0, 0, 0), new Vector3 (0, 0, 0), 1, 0.3f, new Color (0.647f, 0.870f, 0.894f)); } if (Input.GetKey (KeyCode.Joystick1Button0) && DoublePush == false) { emitter = GetComponent<ParticleSystem> (); // Emit one particle at the origin, shooting straight up. // The size of the particle is 0.2 and it will live 2 seconds long. emitter.Emit (new Vector3 (0, 0, 0), new Vector3 (0, 0, 0), 1, 0.3f, new Color (0.709f, 0.792f, 0.627f)); } if (Input.GetKey (KeyCode.Joystick1Button2) && Input.GetKey (KeyCode.Joystick1Button0)) { DoublePush = true; emitter = GetComponent<ParticleSystem> (); // Emit one particle at the origin, shooting straight up. // The size of the particle is 0.2 and it will live 2 seconds long. emitter.Emit (new Vector3 (0, 0, 0), new Vector3 (0, 0, 0), 1, 0.3f, new Color (0.400f, 0.729f, 0.717f)); } if (Input.GetKeyUp (KeyCode.Joystick1Button0) || Input.GetKeyUp (KeyCode.Joystick1Button2)) { DoublePush = false; } if (Input.GetAxis ("360_Triggers") < -0.9) { emitter = GetComponent<ParticleSystem> (); // Emit one particle at the origin, shooting straight up. // The size of the particle is 0.2 and it will live 2 seconds long. emitter.Emit (new Vector3 (0, 0, 0), new Vector3 (0, 0, 0), 1, 0.3f, new Color (0.980f, 0.839f, 0.537f)); } if (Input.GetAxis ("360_Triggers") > 0.9 && PlayerInputPower.Trigger == false) { emitter = GetComponent<ParticleSystem> (); // Emit one particle at the origin, shooting straight up. // The size of the particle is 0.2 and it will live 2 seconds long. emitter.Emit (new Vector3 (0, 0, 0), new Vector3 (0, 0, 0), 1, 0.3f, new Color (0.956f, 0.654f, 0.725f)); } }
static int Emit(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2 && TypeChecker.CheckTypes <UnityEngine.ParticleSystem.Particle>(L, 2)) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem)); UnityEngine.ParticleSystem.Particle arg0 = StackTraits <UnityEngine.ParticleSystem.Particle> .To(L, 2); obj.Emit(arg0); return(0); } else if (count == 2 && TypeChecker.CheckTypes <int>(L, 2)) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem)); int arg0 = (int)LuaDLL.lua_tonumber(L, 2); obj.Emit(arg0); return(0); } else if (count == 6) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.CheckObject(L, 1, typeof(UnityEngine.ParticleSystem)); UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 2); UnityEngine.Vector3 arg1 = ToLua.ToVector3(L, 3); float arg2 = (float)LuaDLL.luaL_checknumber(L, 4); float arg3 = (float)LuaDLL.luaL_checknumber(L, 5); UnityEngine.Color32 arg4 = StackTraits <UnityEngine.Color32> .Check(L, 6); obj.Emit(arg0, arg1, arg2, arg3, arg4); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.ParticleSystem.Emit")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static public int Emit(IntPtr l) { try{ if (matchType(l, 2, typeof(int))) { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); self.Emit(a1); return(0); } else if (matchType(l, 2, typeof(UnityEngine.Vector3), typeof(UnityEngine.Vector3), typeof(float), typeof(float), typeof(UnityEngine.Color32))) { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); UnityEngine.Vector3 a1; checkType(l, 2, out a1); UnityEngine.Vector3 a2; checkType(l, 3, out a2); System.Single a3; checkType(l, 4, out a3); System.Single a4; checkType(l, 5, out a4); UnityEngine.Color32 a5; checkType(l, 6, out a5); self.Emit(a1, a2, a3, a4, a5); return(0); } else if (matchType(l, 2, typeof(UnityEngine.ParticleSystem.Particle))) { UnityEngine.ParticleSystem self = (UnityEngine.ParticleSystem)checkSelf(l); UnityEngine.ParticleSystem.Particle a1; checkType(l, 2, out a1); self.Emit(a1); 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); } }
private void Emit(ParticleSystem p, ref Vector3 pos) { int count = UnityEngine.Random.Range(2, 5); while (count != 0) { float yVelocity = UnityEngine.Random.Range(1.0f, 3.0f); float zVelocity = UnityEngine.Random.Range(-2.0f, 2.0f); float xVelocity = UnityEngine.Random.Range(-2.0f, 2.0f); const float lifetime = 0.75f;// UnityEngine.Random.Range(0.25f, 0.75f); float size = UnityEngine.Random.Range(0.05f, 0.1f); ParticleSystem.EmitParams param = new ParticleSystem.EmitParams(); param.position = pos; param.velocity = new Vector3(xVelocity, yVelocity, zVelocity); param.startLifetime = lifetime; param.startSize = size; param.startColor = color; p.Emit(param, 1); count--; } }
// //Creates fireball object // void makeFireball() { // //Create fireBall // fireBall = (GameObject) Instantiate(PrefabStore.fireBall); fireBall.transform.eulerAngles = transform.eulerAngles; fireBall.transform.position = transform.position; fireBallScript = fireBall.GetComponent<FireBall>(); fireBallScript.speed = fireBallScript.speed+forwardSpeed*2; // //Create fireSpray // fireSpray = (GameObject) Instantiate(PrefabStore.fireSpray); fireSpray.transform.eulerAngles = transform.eulerAngles; fireSpray.transform.position = transform.position; fireSpray.transform.Translate(Vector3.forward*1); // //Adjust particle system of fireSpray object // fireSprayParticle = fireSpray.GetComponent<ParticleSystem>(); fireSprayParticle.startSpeed = 60+forwardSpeed*2; fireSprayParticle.Emit(50); }
void Start() { //get the particle system from the GameObject containing it system = systemHolder.GetComponent<ParticleSystem>(); //create the specified count of particles system.Emit(emitCount); //create an array to hold the particles particleArray = new ParticleSystem.Particle[systemHolder.GetComponent<ParticleSystem>().particleCount]; //fill particle array with system's particles so they can be manipulated system.GetParticles(particleArray); //the spacing between particles y value float offset = 2.0f / emitCount; //how much to increment the phi angle of the particles float increment = Mathf.PI * (3.0f - Mathf.Sqrt(5.0f)); float x, y, z, r; //set the initial velocity and position of each of the particles in radial pattern using fibonnacci spiral //the fibonnacci spiral method prevents bunching of particles near the poles of the sphere (lat and long method) for (float i = 0; i < system.particleCount; i++) { //get the y value of current particle y = ((i * offset) - 1) + (offset / 2.0f); //find rotation along spiral based on y value r = Mathf.Sqrt(1 - Mathf.Pow(y, 2.0f)); //calculate an approximation of phi for current particle float phi = ((i + 1) % emitCount) * increment; //use rotation along spiral r, and phi to calculate x and z coords x = Mathf.Cos(phi) * r; z = Mathf.Sin(phi) * r; //set particle position and velocity //initial postion of all particles is set to the center since they are meant to explode outwards particleArray[(int)i].position = new Vector3(0, 0, 0); //allow initial velocity to be tweaked with the speedFactor particleArray[(int)i].velocity = new Vector3(x / speedFactor, y / speedFactor, z / speedFactor); } //set the position and velocity of the particles in the system based on array system.SetParticles(particleArray, system.particleCount); }
void On_CosmosReady() { isReady = true; cacheTransform = Cosmos.instance.SpaceCamera.transform; // Create particle system gameObject.AddComponent<ParticleSystem>(); cacheCosmosParticle = GetComponent<ParticleSystem>(); cacheCosmosParticle.playOnAwake = false; cacheCosmosParticle.enableEmission = false; cacheCosmosParticle.simulationSpace = ParticleSystemSimulationSpace.Local; cacheCosmosParticle.emissionRate = 0; cacheCosmosParticle.startSpeed = 0; cacheCosmosParticle.startLifetime = Mathf.Infinity; cacheCosmosParticle.startRotation = Random.Range(-Mathf.PI,Mathf.PI); cacheCosmosParticle.GetComponent<Renderer>().material = mat; cacheCosmosParticle.GetComponent<Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; cacheCosmosParticle.GetComponent<Renderer>().receiveShadows = false; // Pre Spawn for (int i=0; i < maxParticle; i ++) { Vector3 drift = Vector3.zero; if (enableDrift){ drift =new Vector3( Random.Range(-1f,1f),Random.Range(-1f,1f),0) * driftSpeed; } cacheCosmosParticle.Emit( cacheTransform.position + (UnityEngine.Random.insideUnitSphere * 200), drift, Random.Range(minSize, maxSize ) , Mathf.Infinity, color.Evaluate( Random.Range(0f,1f))); } }
void PositionAndEmit(Vector3 point, ParticleSystem system, int count) { system.transform.position = point; system.Emit(count); }
public void FixedUpdate() { // Solve collisions only for obbs (not particles) collisionSolver.Solve(); // Update particle system particleSystem.Update(Constants.TimeStepSeconds); // Solve collisions only for particles collisionSolver.Solve(ref particleSystem.Particles); // Do simulation fluidSim.Calculate(ref particleSystem.Particles, lGravity, Constants.TimeStepSeconds); if (fillTypeIndex == 1) { renderer.GetComponent <MeshRenderer>().enabled = true; Mesh mesh = generator.GenerateMesh(fluidSim.m_grid.getFluidMapCount(), Constants.CellSpace / 3); filter.mesh = mesh; } else if (fillTypeIndex == 0) { renderer.GetComponent <MeshRenderer>().enabled = false; // align Unity Particles with simulated Particles ... int d = particleSystem.Particles.Count - ps.particleCount; if (d > 0) { ps.Emit(d); } ps.GetParticles(particles); mParticle p; for (int i = 0; i < particleSystem.Particles.Count; i++) { p = particleSystem.Particles[i]; particles[i].position = new Vector3(p.Position.x, p.Position.y, 0); particles[i].remainingLifetime = 1f; } ps.SetParticles(particles, particleSystem.MaxParticles); } else { //update particle buffer smallParticle[] particleArray = new smallParticle[particleSystem.Particles.Count]; for (int i = 0; i < particleSystem.Particles.Count; i++) { particleArray[i] = particleSystem.Particles[i].toE(); } particleBuffer.SetData(particleArray); // Bind the ComputeBuffer to the shader and the compute shader computeShader.SetBuffer(mComputeShaderKernelID, "particleBuffer", particleBuffer); computeShader.SetInt("particle_length", particleSystem.Particles.Count); int mWarpCount = Mathf.CeilToInt((float)fluidSim.m_grid.GPUVoxel / Constants.WARP_SIZE); computeShader.Dispatch(mComputeShaderKernelID, mWarpCount, 1, 1); grid[] gridArray = new grid[fluidSim.m_grid.GPUVoxel]; gridBuffer.GetData(gridArray); int[] field = new int[gridArray.GetLength(0)]; for (int i = 0; i < gridArray.GetLength(0); i++) { if (gridArray[i].value > 0) { field[i] = 1; } } int[,] f = Helper.Make2DArray <int>(field, fluidSim.m_grid.Width * Constants.resolution + 1, fluidSim.m_grid.Height * Constants.resolution + 1); renderer.GetComponent <MeshRenderer>().enabled = true; Mesh mesh = generator.GenerateMesh(f, Constants.CellSpace / Constants.resolution); mesh = mattatz.MeshSmoothingSystem.MeshSmoothing.LaplacianFilter(mesh); filter.mesh = mesh; } }
public void damageHead(float dmg) { //print ("headshot "+headDamage); //if(dead)return; if(headDamages.Count > 0){ int rnd = Random.Range (0, headDamages.Count-1); //print ("hole count "+bulletHoleCount+" "+bulletHoles.Length); var h = headDamages[rnd]; h.SetActive(true); faceBlood = h.transform.Find ("blood").GetComponent<ParticleSystem>(); faceBlood.transform.parent = null; faceBlood.Emit(120); Destroy(faceBlood.gameObject,2f); headDamages.Remove(h); } aud.clip = bulletHitClips[Random.Range (0, bulletHitClips.Length)]; aud.Play(); }
public void makeBodyBulletHole() { if(bulletHoles.Count >0){ int rnd = Random.Range (0, bulletHoles.Count-1); //print ("hole count "+bulletHoleCount+" "+bulletHoles.Length); var b = bulletHoles[rnd]; b.SetActive(true); bodyBlood = b.transform.Find ("blood").GetComponent<ParticleSystem>(); bodyBlood.transform.parent = null; bodyBlood.Emit(160); Destroy(bodyBlood.gameObject,2f); bulletHoles.Remove(b); } //bulletHoleCount++; aud.clip = bulletHitClips[Random.Range (0, bulletHitClips.Length)]; aud.Play(); }
//use a bunch of blood from the bulletholes for hard splat impacts from damage collider public void makeBodyBlood() { var count = 0; for(int i = 0; i<bulletHoles.Count;i++){ int rnd = Random.Range (0, bulletHoles.Count-1); //print ("hole count "+bulletHoleCount+" "+bulletHoles.Length); var b = bulletHoles[rnd]; //b.SetActive(true); bodyBlood = b.transform.Find ("blood").GetComponent<ParticleSystem>(); bodyBlood.transform.parent = null; bodyBlood.Emit(160); Destroy(bodyBlood.gameObject,2f); count++; bulletHoles.Remove(b); if(count>3){ return; } } }
protected void StartReshuffleTilesAnim() { // Start their re-shuffle tween animation. Match3Tile tile; // Spawn a reshuffle effect that will get auto-destroyed. effectReshuffle = (GameObject.Instantiate(prefabEffectReshuffle) as GameObject).transform; effectReshuffle.parent = Match3BoardGameLogic.Instance.boardVisualContainer; cachedParticleSystem = effectReshuffle.particleSystem; // Auto destroy the effect. GameObject.Destroy(effectReshuffle.gameObject, 4.0f); Tweener lastTween = null; // if(piecesToReshuffle.Count == 0) { // Debug.LogWarning("[piecesToReshuffle.Count] " + piecesToReshuffle.Count); // } for(int i = 0; i < piecesToReshuffle.Count; i++) { tile = piecesToReshuffle[i].Tile as Match3Tile; if (tile != null) { // Stored the tile position in a separate vector because so the below lambda method will receive a copy of this value to execute correctly. Vector3 tilePos = tile.cachedTransform.position; // Offset effect to bring it in front of the tiles. tilePos.z -= 1f; lastTween = HOTween.To(tile.tileModelTransform, 0.5f, new TweenParms() .Prop("localScale", Vector3.zero) .Ease(EaseType.EaseOutQuad) .Delay(0.9f) .OnStart(() => { if (effectReshuffle != null) { // Position the effect effectReshuffle.position = tilePos; cachedParticleSystem.Emit(Random.Range(minNumParticles, maxNumParticles)); } })); // if (lastTween == null) { // Debug.LogWarning("Last tween is NULL!!!"); // } } // else { // Debug.LogWarning("[StartReshuffleTilesAnim] Boardpiece has NULL tile = " + piecesToReshuffle[i]); // } } if (lastTween != null) { lastTween.ApplyCallback(CallbackType.OnComplete, () => { ReshuffleTiles(); }); } // else { // Debug.LogWarning("[StartReshuffleTilesAnim] Error lastTween is NULL"); // } }
private void SpawnSystem(SolarSystem system, ParticleSystem PS) { PS.Emit(system.Position * scale + transform.position, Vector3.zero, particleSize, float.MaxValue, SecurityColor(system.Security)); }
void Start() { if(targetPrefab) { target = Instantiate(targetPrefab); target.transform.parent = gameObject.transform; target.transform.localPosition = new Vector3(0,0,0); rends = target.GetComponentsInChildren<FadeAway>(); targetScale = target.transform.localScale; } if(autoColors) { colors = GlobalData.godColors; } particles = new ParticleSystem.Particle[10 * countInOrbit]; system = GetComponent<ParticleSystem>(); system.Emit(10 * countInOrbit); time = 0; beat = GlobalData.beat * 2.0f; seed = 0.123f;//Random.Range(0.0f,1.0f); scale *= 0.4444f; float size = Camera.main.orthographicSize; float height = size; float width = size * Camera.main.aspect; if (rightBottom) { position = new Vector2(width - screenPosition.x, -height + screenPosition.y); } else { position = new Vector2(-width + screenPosition.x, height - screenPosition.y); } if(worldPos) { position = screenPosition; } }
private IEnumerator GenerateParticle(ParticleSystem p, Vector3 pos, float delay) { yield return new WaitForSeconds(delay); p.transform.position = pos; #if UNITY_PRE_5_3 p.Emit((int)p.emissionRate); #else p.Emit((int)p.emission.rate.constantMax); #endif }
static int Emit(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 2 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.ParticleSystem), typeof(UnityEngine.ParticleSystem.Particle))) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.ToObject(L, 1); UnityEngine.ParticleSystem.Particle arg0 = (UnityEngine.ParticleSystem.Particle)ToLua.ToObject(L, 2); try { obj.Emit(arg0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } return(0); } else if (count == 2 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.ParticleSystem), typeof(int))) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.ToObject(L, 1); int arg0 = (int)LuaDLL.lua_tonumber(L, 2); try { obj.Emit(arg0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } return(0); } else if (count == 6 && ToLua.CheckTypes(L, 1, typeof(UnityEngine.ParticleSystem), typeof(UnityEngine.Vector3), typeof(UnityEngine.Vector3), typeof(float), typeof(float), typeof(UnityEngine.Color32))) { UnityEngine.ParticleSystem obj = (UnityEngine.ParticleSystem)ToLua.ToObject(L, 1); UnityEngine.Vector3 arg0 = ToLua.ToVector3(L, 2); UnityEngine.Vector3 arg1 = ToLua.ToVector3(L, 3); float arg2 = (float)LuaDLL.lua_tonumber(L, 4); float arg3 = (float)LuaDLL.lua_tonumber(L, 5); UnityEngine.Color32 arg4 = (UnityEngine.Color32)ToLua.ToObject(L, 6); try { obj.Emit(arg0, arg1, arg2, arg3, arg4); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } return(0); } else { LuaDLL.luaL_error(L, "invalid arguments to method: UnityEngine.ParticleSystem.Emit"); } return(0); }
public IEnumerator WaitThenTurnOff(float duration, ParticleSystem emmitter) { float timer = 0; while(timer < duration){ emmitter.Emit(2); timer+=Time.deltaTime; yield return null; } TryGrow(); }
void Start() { countInOrbit = GlobalData.particleFXCount; if (targetPrefab) { target = Instantiate(targetPrefab); target.transform.parent = gameObject.transform; target.transform.localPosition = new Vector3(0, 0, 0); rends = target.GetComponentsInChildren<FadeAway>(); targetScale = target.transform.localScale; } updated = false; orbitCount = GlobalData.particleFXOrbCount; particles = new ParticleSystem.Particle[orbitCount * countInOrbit]; system = GetComponent<ParticleSystem>(); system.Emit(10 * countInOrbit); scale *= 0.4444f; beat = GlobalData.beat; if(longer) { beat *= 2.0f; } Reset(); time = 10.0f; if (auto) { Reset(); } if (godColors) { switch (GlobalData.selectedGod) { case GlobalData.Gods.RHINO: colors = rhinoColors3; break; case GlobalData.Gods.BEAR: colors = bearColors3; break; case GlobalData.Gods.BULL: colors = bullColors3; break; } } }