/// <summary>
	/// This function will run whenever a particle enters the extents of the Manipulator.
	/// </summary>
	/// <param name="particle">Particle.</param>
	void OnManipulatorEnter (PlaygroundEventParticle particle) {

		// Do something here
		// Debug.Log("Particle "+particle.particleId+" from particle system "+particle.particleSystemId+" at position "+particle.position+" is within the Manipulator.");

		// Then remove the particle from its current location
		particles.Kill (particle.particleId);

		// Increase pickups by one
		pickups++;
	}
	void OnEventParticleTime (PlaygroundEventParticle particle) {
		Debug.Log ("A particle called in at "+particle.position+" with the lifetime of "+particle.life);
	}
Пример #3
0
		/// <summary>
		/// Returns all current particles within a local manipulator (in form of an Event Particle, however no event will be needed).
		/// </summary>
		/// <returns>The manipulator particles.</returns>
		/// <param name="manipulator">Manipulator.</param>
		/// <param name="playgroundParticles">Playground particles.</param>
		public static List<PlaygroundEventParticle> GetManipulatorParticles (int manipulator, PlaygroundParticlesC playgroundParticles) {
			if (manipulator<0 || manipulator>=playgroundParticles.manipulators.Count) return null;
			List<PlaygroundEventParticle> particles = new List<PlaygroundEventParticle>();
			PlaygroundEventParticle particle = new PlaygroundEventParticle();
			for (int i = 0; i<playgroundParticles.particleCount; i++) {
				if (playgroundParticles.manipulators[manipulator].Contains(playgroundParticles.playgroundCache.position[i], playgroundParticles.manipulators[manipulator].transform.position)) {
					playgroundParticles.UpdateEventParticle(particle, i);
					particles.Add (particle.Clone());
				}
			}
			return particles;
		}
Пример #4
0
		/// <summary>
		/// Gets the particle in particle system at index. Note that the Manipulator must have trackParticles set to true.
		/// </summary>
		/// <returns>The particle.</returns>
		/// <param name="particleSystemId">Particle system identifier.</param>
		/// <param name="particleId">Particle identifier.</param>
		public PlaygroundEventParticle GetParticle (int particleSystemId, int particleId) {
			PlaygroundEventParticle returnEventParticle = new PlaygroundEventParticle();
			if (PlaygroundC.reference.particleSystems[particleSystemId].UpdateEventParticle(returnEventParticle, particleId))
				return returnEventParticle;
			else return null;
		}
Пример #5
0
		/// <summary>
		/// Sends the particle event collision.
		/// </summary>
		/// <param name="eventParticle">Event particle.</param>
		public static void SendParticleEventCollision (PlaygroundEventParticle eventParticle) {
			if (particleEventCollisionInitialized)
				particleEventCollision(eventParticle);
		}
	void OnManipulatorEnter (PlaygroundEventParticle particle) {

		/* A manipulator using events will send information to any Event Listeners (such as this function).
		 * OnManipulatorEnter() has hooked up in Start() to the Event Delegate of the manipulator attached to bubbleParticles.
		 * Whenever a particle enters the confined space of the manipulator OnManipulatorEnter() will be called.
		 * You can use this to know which particle it is, where it entered and extract further information such as velocity,
		 * size, color and if it has been altered by any properties. The particle id is the same number as within its position 
		 * in the playgroundCache. Uncomment the section below for an example in the console.
		*/
		/*
		Debug.Log ("Position: "+			particle.position			+"\n"+
		           "Velocity: "+			particle.velocity			+"\n"+
		           "Color: "+				particle.color				+"\n"+
		           "Particle System Id: "+	particle.particleSystemId	+"\n"+
		           "Particle Id: "+			particle.particleId			+"\n"
		           );
		*/
	}
	void OnManipulatorDeath (PlaygroundEventParticle particle) {
		
		// A particle has died inside the manipulator. Uncomment the line below for an example in the console.
		//Debug.Log ("Particle "+particle.particleId+" from system "+particle.particleSystemId+" has died inside the manipulator.");
	}
Пример #8
0
	/// <summary>
	/// Event listener for particle death.
	/// </summary>
	/// <param name="particle">Particle.</param>
	void OnParticleDidDie (PlaygroundEventParticle particle) {
		int followerId = GetFollowerWithId(particle.particleId);
		if (followerId<0) return;
		followers[followerId].enabled = false;
	}
	// Run ParticleEvent each time a particle sends an Event
	void ParticleEvent (PlaygroundEventParticle particle) {
		if (Vector3.Distance (particle.position, thisPosition) <= killRange)
			particles.Kill (particle.particleId);
	}
Пример #10
0
 void OnEvent(PlaygroundEventParticle particle)
 {
     if (this == null) return;
     if (particle.collisionCollider.gameObject == this.gameObject)
     {
         Health -= FlameDamage;
         //Debug.Log(" OnEvent() Health:" + Health);
         if (Random.Range(0, 10) == 0)
         {
             var fire = FireManager.Instance.GetOne("SmallFire");
             if (fire != null)
             {
                 fire.GetComponent<Fire>().Init(transform, new Vector3(Random.Range(-0.1f, 0.1f), Random.Range(0f, 0.4f), -0.01f));
                 fires.Add(fire.GetComponent<Fire>());
                 //fire.transform.position = transform.position + new Vector3(Random.Range(-0.5f, 0.5f), Random.Range(-0.25f, 0.25f), -0.01f);
                 //fire.GetComponent<Fire>().Init();
                 //fire.transform.SetParent(transform);
                 Escape();
             }
         }
     }
 }
Пример #11
0
	/// <summary>
	/// Emits particles whenever the event is triggered. You could use more info from the passed in event particle if you'd like for more advanced emission behaviors.
	/// Note that this will by default be called on a second thread.
	/// </summary>
	/// <param name="particle">Event Particle.</param>
	void EmitOnEvent (PlaygroundEventParticle particle) {
		particlesEmit.ThreadSafeEmit (emitCount, particle.collisionParticlePosition, randomVelocityMin, randomVelocityMax, color);
	}
	// DoSomething will run when a particle triggers the Event
	void DoSomething (PlaygroundEventParticle particle) {
		gizmoPosition = particle.position;
	}
	/// <summary>
	/// Called upon the event, this function will be called from a different thread if multithreading is enabled.
	/// </summary>
	void OnParticleEvent (PlaygroundEventParticle particle) {
		queuedSystems.Add (particle.position);
	}
Пример #14
0
		public void SendParticleEvent (PlaygroundEventParticle eventParticle) {
			particleEvent(eventParticle);
		}
	// Run ParticleEvent each time a particle sends an Event
	void ParticleEvent (PlaygroundEventParticle particle) {

		// If the particle's collider is this then change the localAxisRotation based on particle's size and velocity
		if (particle.collisionCollider == thisCollider)
			localAxisRotation += particle.size*particle.velocity.magnitude*collisionAmplifier;
	}
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// MonoBehaviours
		//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

		void Awake () {

			if (isSnapshot) return;

			// Make sure all references exists
			CheckReferences();

			// Make sure that state data is initialized
			for (int x = 0; x<states.Count; x++)
				states[x].Initialize();
			
			// Initialize
			if (worldObject!=null && worldObject.transform!=null)
				worldObject.Initialize();
			if (skinnedWorldObject!=null && skinnedWorldObject.transform!=null)
				skinnedWorldObject.Initialize();
			if (projection!=null && projection.projectionTexture)
				projection.Initialize();
			if (manipulators.Count>0) {
				for (int i = 0; i<manipulators.Count; i++)
					manipulators[i].Update();
			}

			internalRandom01 = new System.Random();
			internalRandom02 = new System.Random();
			internalRandom03 = new System.Random();
			turbulenceSimplex = new SimplexNoise();
			eventParticle = new PlaygroundEventParticle();

			if (PlaygroundC.reference!=null) {
				#if UNITY_EDITOR
				if (isSnapshot && !PlaygroundC.reference.showSnapshotsInHierarchy) {
					gameObject.hideFlags = HideFlags.HideInHierarchy;
					return;
				}
				#endif
				if (isSnapshot) return;
				if (!PlaygroundC.reference.particleSystems.Contains(this))
					PlaygroundC.reference.particleSystems.Add(this);
				if (particleSystemTransform.parent==null && PlaygroundC.reference.autoGroup)
					particleSystemTransform.parent = PlaygroundC.referenceTransform;
			}

			// Reset event controlled by-list, this will be refreshed first calculation
			eventControlledBy = new List<PlaygroundParticlesC>();
		}
Пример #17
0
	/// <summary>
	/// Event listener for particle birth.
	/// </summary>
	/// <param name="particle">Particle.</param>
	void OnParticleDidBirth (PlaygroundEventParticle particle) {
		waitingFollowers.Add (new PlaygroundFollower(null, null, null, followerLifetime<=0? particle.totalLifetime+trailTime : followerLifetime, particle.particleId));
	}
Пример #18
0
 void OnEvent(PlaygroundEventParticle particle)
 {
     if (this == null) return;
     if (particle.collisionCollider.gameObject == this.gameObject)
     {
         Health -= 0.0005f;
         if (Random.Range(0, 500) == 0)
         {
             var fire = FireManager.Instance.GetOne("Fire");
             if (fire != null)
             {
                 fire.GetComponent<Fire>().Init(transform, new Vector3(Random.Range(-0.5f, 0.5f), Random.Range(-0.25f, 0.25f), -0.01f));
                 AudioSource fireSource = GetComponent<AudioSource>();
                 if (!fireSource.isPlaying)
                 {
                     fireSource.Play();
                 }
             }
         }
     }
 }
	void OnManipulatorExit (PlaygroundEventParticle particle) {

		// A particle left the manipulator. Uncomment the line below for an example in the console.
		//Debug.Log ("Particle "+particle.particleId+" from system "+particle.particleSystemId+" left the manipulator.");
	}
Пример #20
0
		/****************************************************************************
			Event Listeners
		 ****************************************************************************/

		/// <summary>
		/// This function will be called whenever a particle is birthed.
		/// </summary>
		/// <param name="particle">The birthed particle.</param>
		void OnParticleBirthEvent (PlaygroundEventParticle particle)
		{
			_birthQueue.Enqueue (new TrailParticleInfo(particle.particleId, particle.position, particle.velocity));
		}
	void OnManipulatorCollision (PlaygroundEventParticle particle) {
		
		// A particle has collided inside the manipulator. You need to activate collision on bubbleParticles for this function to have effect. Uncomment the line below for an example in the console.
		//Debug.Log ("Particle "+particle.particleId+" from system "+particle.particleSystemId+" has collided with "+particle.collisionTransform.name+" at position "+particle.collisionParticlePosition+" inside the manipulator.");
	}
Пример #22
0
		/// <summary>
		/// This function will be called whenever a particle has died.
		/// </summary>
		/// <param name="particle">The particle which died.</param>
		void OnParticleDeathEvent (PlaygroundEventParticle particle)
		{
			int trailIndex = GetOldestTrailWithParticleId(particle.particleId);
			if (trailIndex > -1)
			{
				if (createLastPointOnParticleDeath)
				{
					_trails[trailIndex].SetLastPoint(particle.position, particle.velocity, EvaluateWidth(0), time, _calculationStartTime);
				}
				else
				{
					_trails[trailIndex].SetParticlePosition(particle.position);
					_trails[trailIndex].Die();
				}
			}
		}
Пример #23
0
		/// <summary>
		/// Sends the particle event death.
		/// </summary>
		/// <param name="eventParticle">Event particle.</param>
		public static void SendParticleEventDeath (PlaygroundEventParticle eventParticle) {
			if (particleEventDeathInitialized)
				particleEventDeath(eventParticle);
		}
Пример #24
0
		/// <summary>
		/// This function will be called whenever a particle is colliding.
		/// </summary>
		/// <param name="particle">The collided particle.</param>
		void OnParticleCollisionEvent (PlaygroundEventParticle particle)
		{
			if (createPointsOnCollision)
			{
				int trailIndex = GetNewestTrailWithParticleId (particle.particleId);
				if (trailIndex < 0)
					return;
				ParticlePlaygroundTrail trailAtIndex = _trails[trailIndex];
				trailAtIndex.AddPoint (playgroundSystem.particleCache[particle.particleId].position, EvaluateWidth(0), time, _calculationStartTime);
			}
		}
Пример #25
0
		/// <summary>
		/// Sends the particle event time.
		/// </summary>
		/// <param name="eventParticle">Event particle.</param>
		public static void SendParticleEventTime (PlaygroundEventParticle eventParticle) {
			if (particleEventTimeInitialized)
				particleEventTime(eventParticle);
		}
Пример #26
0
 public bool UpdateEventParticle(PlaygroundEventParticle eParticle, int p)
 {
     if (p>=particleCount || p<0) return false;
     eParticle.particleSystemId = particleSystemId;
     eParticle.particleId = p;
     eParticle.birth = playgroundCache.birth[p];
     eParticle.birthDelay = playgroundCache.birthDelay[p];
     eParticle.changedByProperty = playgroundCache.changedByProperty[p];
     eParticle.changedByPropertyColor = playgroundCache.changedByPropertyColor[p];
     eParticle.changedByPropertyColorKeepAlpha = playgroundCache.changedByPropertyColorKeepAlpha[p];
     eParticle.changedByPropertyColorLerp = playgroundCache.changedByPropertyColorLerp[p];
     eParticle.changedByPropertyDeath = playgroundCache.changedByPropertyDeath[p];
     eParticle.changedByPropertySize = playgroundCache.changedByPropertySize[p];
     eParticle.changedByPropertyTarget = playgroundCache.changedByPropertyTarget[p];
     eParticle.collisionParticlePosition = playgroundCache.collisionParticlePosition[p];
     eParticle.color = particleCache[p].color;
     eParticle.scriptedColor = playgroundCache.scriptedColor[p];
     eParticle.death = playgroundCache.death[p];
     eParticle.emission = playgroundCache.emission[p];
     eParticle.initialColor = playgroundCache.initialColor[p];
     eParticle.initialLocalVelocity = playgroundCache.initialLocalVelocity[p];
     eParticle.initialRotation = playgroundCache.initialRotation[p];
     eParticle.initialSize = playgroundCache.initialSize[p];
     eParticle.initialVelocity = playgroundCache.initialVelocity[p];
     eParticle.initialLocalVelocity = playgroundCache.initialLocalVelocity[p];
     eParticle.life = playgroundCache.life[p];
     eParticle.lifetimeColorId = playgroundCache.lifetimeColorId[p];
     eParticle.noForce = playgroundCache.noForce[p];
     eParticle.totalLifetime = (playgroundCache.death[p]-playgroundCache.birth[p])-playgroundCache.lifetimeSubtraction[p];
     eParticle.lifetimeOffset = playgroundCache.lifetimeOffset[p];
     eParticle.localSpaceMovementCompensation = playgroundCache.localSpaceMovementCompensation[p];
     eParticle.position = playgroundCache.position[p];
     eParticle.previousParticlePosition = playgroundCache.previousParticlePosition[p];
     eParticle.previousTargetPosition = playgroundCache.previousTargetPosition[p];
     eParticle.propertyColorId = playgroundCache.propertyColorId[p];
     eParticle.propertyId = playgroundCache.propertyId[p];
     eParticle.excludeFromManipulatorId = playgroundCache.excludeFromManipulatorId[p];
     eParticle.propertyTarget = playgroundCache.propertyTarget[p];
     eParticle.rebirth = playgroundCache.rebirth[p];
     eParticle.rotation = playgroundCache.rotation[p];
     eParticle.rotationSpeed = playgroundCache.rotationSpeed[p];
     eParticle.scatterPosition = playgroundCache.scatterPosition[p];
     eParticle.size = playgroundCache.size[p];
     eParticle.targetDirection = playgroundCache.targetDirection[p];
     eParticle.targetPosition = playgroundCache.targetPosition[p];
     eParticle.velocity = playgroundCache.velocity[p];
     eParticle.isMasked = playgroundCache.isMasked[p];
     eParticle.maskAlpha = playgroundCache.maskAlpha[p];
     eParticle.isFirstLoop = playgroundCache.isFirstLoop[p];
     eParticle.isNonBirthed = playgroundCache.isNonBirthed[p];
     return true;
 }
Пример #27
0
		/// <summary>
		/// Sends the particle event.
		/// </summary>
		/// <param name="eventParticle">Event particle.</param>
		public void SendParticleEvent (PlaygroundEventParticle eventParticle) {
			if (initializedEvent)
				particleEvent(eventParticle);
		}
Пример #28
0
        /// <summary>
        /// Copies this PlaygroundEventParticle.
        /// </summary>
        public PlaygroundEventParticle Clone()
        {
            PlaygroundEventParticle playgroundEventParticle = new PlaygroundEventParticle();
            playgroundEventParticle.initialSize = initialSize;
            playgroundEventParticle.size = size;
            playgroundEventParticle.life = life;
            playgroundEventParticle.totalLifetime = totalLifetime;
            playgroundEventParticle.rotation = rotation;
            playgroundEventParticle.birth = birth;
            playgroundEventParticle.birthDelay = birthDelay;
            playgroundEventParticle.death = death;
            playgroundEventParticle.emission = emission;
            playgroundEventParticle.rebirth = rebirth;
            playgroundEventParticle.lifetimeOffset = lifetimeOffset;
            playgroundEventParticle.velocity = velocity;
            playgroundEventParticle.initialVelocity = initialVelocity;
            playgroundEventParticle.initialLocalVelocity = initialLocalVelocity;
            playgroundEventParticle.position = position;
            playgroundEventParticle.targetPosition = targetPosition;
            playgroundEventParticle.targetDirection = targetDirection;
            playgroundEventParticle.previousTargetPosition = previousTargetPosition;
            playgroundEventParticle.previousParticlePosition = previousParticlePosition;
            playgroundEventParticle.collisionParticlePosition = collisionParticlePosition;
            playgroundEventParticle.localSpaceMovementCompensation = localSpaceMovementCompensation;
            playgroundEventParticle.scatterPosition = scatterPosition;
            playgroundEventParticle.initialRotation = initialRotation;
            playgroundEventParticle.rotationSpeed = rotationSpeed;
            playgroundEventParticle.color = color;
            playgroundEventParticle.scriptedColor = scriptedColor;
            playgroundEventParticle.initialColor = initialColor;
            playgroundEventParticle.lifetimeColorId = lifetimeColorId;
            playgroundEventParticle.noForce = noForce;
            playgroundEventParticle.changedByProperty = changedByProperty;
            playgroundEventParticle.changedByPropertyColor = changedByPropertyColor;
            playgroundEventParticle.changedByPropertyColorLerp = changedByPropertyColorLerp;
            playgroundEventParticle.changedByPropertyColorKeepAlpha = changedByPropertyColorKeepAlpha;
            playgroundEventParticle.changedByPropertySize = changedByPropertySize;
            playgroundEventParticle.changedByPropertyTarget = changedByPropertyTarget;
            playgroundEventParticle.changedByPropertyDeath = changedByPropertyDeath;
            playgroundEventParticle.propertyTarget = propertyTarget;
            playgroundEventParticle.propertyId = propertyId;
            playgroundEventParticle.excludeFromManipulatorId = excludeFromManipulatorId;
            playgroundEventParticle.propertyColorId = propertyColorId;
            playgroundEventParticle.particleId = particleId;
            playgroundEventParticle.particleSystemId = particleSystemId;
            playgroundEventParticle.manipulatorId = manipulatorId;
            playgroundEventParticle.isMasked = isMasked;
            playgroundEventParticle.maskAlpha = maskAlpha;

            playgroundEventParticle.collisionTransform = collisionTransform;
            playgroundEventParticle.collisionCollider = collisionCollider;
            playgroundEventParticle.collisionCollider2D = collisionCollider2D;

            return playgroundEventParticle;
        }
Пример #29
0
		/// <summary>
		/// Returns all current particles within a global manipulator (in form of an Event Particle, however no event will be needed).
		/// </summary>
		/// <returns>The manipulator particles.</returns>
		/// <param name="manipulator">Manipulator.</param>
		public static List<PlaygroundEventParticle> GetManipulatorParticles (int manipulator) {
			if (manipulator<0 || manipulator>=reference.manipulators.Count) return null;
			List<PlaygroundEventParticle> particles = new List<PlaygroundEventParticle>();
			PlaygroundEventParticle particle = new PlaygroundEventParticle();
			for (int s = 0; s<reference.particleSystems.Count; s++) {
				for (int i = 0; i<reference.particleSystems[s].particleCount; i++) {
					if (reference.particleSystems[s].manipulators[manipulator].Contains(reference.particleSystems[s].playgroundCache.position[i], reference.particleSystems[s].manipulators[manipulator].transform.position)) {
						reference.particleSystems[s].UpdateEventParticle(particle, i);
						particles.Add (particle.Clone());
					}
				}
			}
			return particles;
		}
	void OnEventParticleCollision (PlaygroundEventParticle particle) {
		Debug.Log ("A particle collided at "+particle.position+" with "+particle.collisionTransform.name+". The id of the particle was "+particle.particleId+" from particle system "+particle.particleSystemId);
	}