private void InternalEmit(int idx, EmitParams emitParams) { Particle p = particles[idx]; World2D world = GetWorld2d(); Physics2DDirectSpaceState spaceState = world.DirectSpaceState; foreach (ParticleSystem2DModule module in modules) { if (!module.enabled) { continue; } IParticleInitializable IInit = module as IParticleInitializable; if (IInit == null) { continue; } module.world = world; module.spaceState = spaceState; IInit.InitParticle(ref p, emitParams); } p.alive = true; particles[idx] = p; }
private void OnParticleTrigger() { if (!enabled) { return; } ParticleSystem ps = GetComponent <ParticleSystem>(); // particles List <Particle> enter = new List <ParticleSystem.Particle>(); // get int numEnter = ps.GetTriggerParticles(ParticleSystemTriggerEventType.Enter, enter); // iterate for (int i = 0; i < numEnter; i++) { ParticleSystem.Particle p = enter[i]; // Draw something at the position of the particle var paramsEmitter = new EmitParams(); paramsEmitter.position = p.position; paramsEmitter.startSize = 0.2f; paramsEmitter.velocity = p.velocity; paramsEmitter.startLifetime = 0.2f; paramsEmitter.applyShapeToPosition = true; particlesHit.Emit(paramsEmitter, 1); } // set ps.SetTriggerParticles(ParticleSystemTriggerEventType.Enter, enter); }
public void ShowDamageParticles(Vector3 _position, int _count = 30) { EmitParams eParams = new EmitParams(); eParams.ResetPosition(); eParams.applyShapeToPosition = true; eParams.position = transform.InverseTransformPoint(_position); particlesArmorDamage.Emit(eParams, _count); }
public void Emit(Vector3 position, Vector3 velocity, int count, params Color32[] color) { var emit = new EmitParams(); for (int i = 0; i < count; i++) { emit.startColor = RandomUtil.RandomElement(color); emit.velocity = AddVelocityNoise(velocity); emit.position = AddPositionNoise(position); Particle.Emit(emit, 1); } }
public void Emit(Vector3 position, Vector3 velocity, int count, Color32 color) { var emit = new EmitParams() { startColor = color, }; for (int i = 0; i < count; i++) { emit.velocity = AddVelocityNoise(velocity); emit.position = AddPositionNoise(position); Particle.Emit(emit, 1); } }
public void EmitTankExplosion(Vector3 position) { // Horizontal flames float t = Time.time; float deltaT = .1f; EmitParams emit; for (int i = 0; i < 2; i++) { emit = new EmitParams(m_flameOutPS, t, 1, position, -Camera.main.transform.right, Camera.main.transform.up); InsertTimeSorted(ref emit); emit = new EmitParams(m_flameOutPS, t, 1, position, Camera.main.transform.right, Camera.main.transform.up); InsertTimeSorted(ref emit); t += deltaT; } // Large central explosion t = Time.time; Vector3 pos = position; for (int i = 0; i < 2; i++) { t += .1f; // Note: local forward is the direction of particle motion, hence to move // up, we set *forward* direction to Vector3.up emit = new EmitParams(m_randomExplosionPS, t, 1, pos, Vector3.up, Vector3.forward); InsertTimeSorted(ref emit); pos += .1f * Vector3.up; } // Occasionally, a series of small bursts after a short pause float r = Random.Range(0f, 1f); if (r < 0.33f) // 33% chance { t += 0.33f; for (int i = 0; i < 5; i++) { emit = new EmitParams(m_randomExplosionSmallPS, t, 1, pos, Vector3.up, Vector3.forward); InsertTimeSorted(ref emit); t += 0.1f; } } // Blast wave CreateExplosionBlastWave(position, Vector3.up); }
public void Emit(int amount) { EmitParams emitParams = new EmitParams(); Transform2D t = Transform2D.Identity; switch (spaceMode) { case SpaceMode.World: { t = GlobalTransform; break; } } emitParams.shapeTransform = t; Emit(emitParams, amount); }
public void EmitInColliderBounds(Collider2D collider, Vector3 velocity, int count, params Color32[] color) { //const float VelocityClamp = 0.5f; //velocity *= VelocityClamp; Vector2[] points = RandomUtil.RandomsPointsInsiderCollider(collider, count); var emit = new EmitParams(); for (int i = 0; i < count; i++) { emit.startColor = RandomUtil.RandomElement(color); emit.velocity = AddVelocityNoise(velocity); emit.position = AddPositionNoise(points[i]); Particle.Emit(emit, 1); } }
public void Emit(EmitParams emitParams, int amount) { if (amount <= 0) { return; } for (int i = 0; i < maxParticles; i++) { if (!particles[i].alive) { InternalEmit(i, emitParams); amount--; if (amount == 0) { break; } } } }
private LinkedList <EmitParams> m_futureParticles; // in order of ascending time private void InsertTimeSorted(ref EmitParams item) { LinkedList <EmitParams> list = m_futureParticles; if (list.Count == 0 || list.Last.Value.time <= item.time) { list.AddLast(item); return; } for (LinkedListNode <EmitParams> node = list.First; node != null;) { if (node.Value.time > item.time) { list.AddBefore(node, item); break; } node = node.Next; } }
public void CreateMap() { starSystems = new List <Star> (); GameObject starParent = new GameObject("Star Parent"); Transform starParentTransform = starParent.transform; rawData = dataController.GetStarData(); if (rawData == null) { Debug.LogWarning("Raw Data is NULL from DataController.GetStarData. Please refresh star data and try again."); return; } List <SystemData> rawStarData = new List <SystemData>(rawData.systems); foreach (var starSystem in rawStarData) { GameObject starObject = Instantiate(starPrefab, Vector3.zero, Quaternion.identity) as GameObject; starObject.transform.parent = starParentTransform; starObject.name = starSystem.name; Star star = starObject.GetComponent <Star> (); star.starName = starSystem.name; if (starSystem.coords != null) { star.coordinates = new Vector3((float)starSystem.coords.x, (float)starSystem.coords.y, (float)starSystem.coords.z); } starObject.transform.position = star.coordinates; var emitParams = new EmitParams() { position = star.coordinates, velocity = Vector3.zero, startSize = starSize, startLifetime = Mathf.Infinity, startColor = Color.white }; starParticles.Emit(emitParams, 1); starSystems.Add(star); } }
extern public void Emit(EmitParams emitParams, int count);
private void EmitParticlesNow(EmitParams emit) { emit.particleSystem.transform.position = emit.position; emit.particleSystem.transform.rotation = emit.rotation; emit.particleSystem.Emit(emit.number); }
public void Emit(EmitParams emitParams, int num) { throw new NotImplementedException(); }