/// <summary> /// Spawn the specified particle explosion at position, with numOfParticles and of particleColour. /// </summary> /// <param name="position">The position of explosion.</param> /// <param name="numOfParticles">The number of particles.</param> /// <param name="particleColour">The particle colour.</param> public void Spawn(Vector2 position, int numOfParticles, Color particleColour) { float hue1 = UnityEngine.Random.Range(0f, 6f); float hue2 = (hue1 + UnityEngine.Random.Range(0f, 2f)) % 6f; Color colour1 = StaticExtensions.Color.FromHSV(hue1, 0.5f, 1); Color colour2 = StaticExtensions.Color.FromHSV(hue2, 0.5f, 1); for (int i = 0; i < numOfParticles; i++) { float speed = (12f * (1f - 1 / Random.Range(2f, 3f))) * 0.02f; var state = new ParticleBuilder() { velocity = StaticExtensions.Random.RandomVector2(speed, speed), wrapAroundType = WrapAroundType.None, lengthMultiplier = 40f, velocityDampModifier = 0.94f, removeWhenAlphaReachesThreshold = true, canBeCollectedByPlayer = true, maxLengthClamp = 1.5f }; var colour = Color.Lerp(colour1, colour2, UnityEngine.Random.Range(0f, 1f)); float duration = Random.Range(200f, 320f); var initialScale = new Vector2(1f, 1f); ParticleFactory.instance.CreateParticle(position, colour, duration, initialScale, state); } }
private void SpawnExplosion(Vector2 position) { WarpGrid.WarpingGrid.Instance.ApplyExplosiveForce(15f, transform.position, radius * 1.5f); for (int i = 0; i < NUM_OF_PARTICLES_ON_DEATH; i++) { float speed = (12f * (1f - 1 / 2f)) * 0.02f; var state = new ParticleBuilder() { velocity = StaticExtensions.Random.RandomVector2(speed, speed), wrapAroundType = WrapAroundType.None, lengthMultiplier = 20f, velocityDampModifier = 0.94f, removeWhenAlphaReachesThreshold = true, canBeCollectedByPlayer = true, maxLengthClamp = 1.5f }; float duration = Random.Range(200f, 320f); var initialScale = new Vector2(1f, 1f); ParticleFactory.instance.CreateParticle(position, colors[Mathf.RoundToInt(m_CurrentColour)], duration, initialScale, state); } }
//public GameObject Player; //private Player_Controller player_Script; public void SpawnExplosion(Vector2 position) { //float hue1 = Random.Range (0, 6); //float hue2 = (hue1 + Random.Range (0, 2)) % 6f; Color colour1 = Color.red; //StaticExtensions.Color.FromHSV (hue1, 0.5f, 1); Color colour2 = Color.green; //StaticExtensions.Color.FromHSV (hue2, 0.5f, 1); for (int i = 0; i < numToSpawn; i++) { float speed = (18f * (1f - 1 / Random.Range(1f, 10f))) * speedOffset; var state = new ParticleBuilder() { velocity = StaticExtensions.Random.RandomVector2(speed, speed), wrapAroundType = wrapAround, lengthMultiplier = lengthMultiplier, velocityDampModifier = 0.94f, removeWhenAlphaReachesThreshold = true }; var colour = Color.Lerp(colour1, colour2, Random.Range(0, 1)); float duration = 320f; var initialScale = new Vector2(2f, 1f); ParticleFactory.instance.CreateParticle(position, colour, duration, initialScale, state); } }
void Start() { m_CachedState = new ParticleBuilder() { velocity = Vector2.zero, wrapAroundType = WrapAroundType.None, lengthMultiplier = 40f, velocityDampModifier = 0.94f, removeWhenAlphaReachesThreshold = true, canBeCollectedByPlayer = true, maxLengthClamp = 1.5f }; }
public override void OnInteract(Projectile projectile) { //Checks if the projectile is already under influence of this weather if (CheckWeatherInfluence(projectile)) { return; } //Passes this instance to any projectile's dependent projectile projectile.OnBeginForceInteraction(this); //If the project can't collide, it should not be taken into consideration for spawning/explosion effects if (!projectile.CanCollide) { return; } //Once added to the list the projectile starts spawning force particles around it's flipbook WeatherProjectileParticleTimer wppt = new WeatherProjectileParticleTimer() { Projectile = projectile }; forceInteraction.Add(wppt); //Calculate new base damage for a projectile CalculateDamage(projectile); //Install itself on the projectile explosion event forcing every exploding projectile to be removed from the spawning list Action removeParticle = () => { OnStopInteracting(projectile); forceInteraction.Remove(wppt); }; projectile.OnExplodeAction += removeParticle; projectile.OnBeingDestroyedAction += removeParticle; //Install itself on the projectile ground destruction and dmg dealing Action <int> particleEffect = (p) => { forceInteraction.Remove(forceInteraction.Find((x) => x.Projectile == projectile)); ParticleBuilder.AsyncCreateForceCollapseParticleEffect(p, projectile.Position, projectile.CurrentFlipbookRotation); }; projectile.OnDestroyGroundAction += particleEffect; projectile.OnDealDamageAction += particleEffect; }
// Uses reflection to get all of the features in assemblies in the local folder and install them public static ParticleBuilder WithAllInstalledFeatures(this ParticleBuilder builder) { var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); foreach (var dll in Directory.GetFiles(path, "Particle.Features.*.dll")) { var assembly = Assembly.LoadFrom(dll); var featureDefinitions = assembly.GetTypes().Where(x => typeof(FeatureDefinition).IsAssignableFrom(x) && x.IsAbstract == false); foreach (var type in featureDefinitions) { var feature = (FeatureDefinition)Activator.CreateInstance(type); builder.With(feature); } } return(builder); }
void Start() { m_CachedState = new ParticleBuilder() { velocity = Vector2.zero, wrapAroundType = WrapAroundType.None, lengthMultiplier = 50f, velocityDampModifier = 0.94f, removeWhenAlphaReachesThreshold = true, canBeCollectedByPlayer = true, maxLengthClamp = 1.5f }; m_ToColour = new Color( Mathf.Clamp01(particleColour.r + UnityEngine.Random.Range(-COLOUR_OFFSET, COLOUR_OFFSET)), Mathf.Clamp01(particleColour.g + UnityEngine.Random.Range(-COLOUR_OFFSET, COLOUR_OFFSET)), Mathf.Clamp01(particleColour.b + UnityEngine.Random.Range(-COLOUR_OFFSET, COLOUR_OFFSET)), 1f ); }
//spawns an explosion at the position given and changes the color depending on the enemy public void SpawnExplosion(Vector3 position, GameObject enemy) { float hue1 = Random.Range(0, 6); float hue2 = (hue1 + Random.Range(0, 2)) % 6f; Color color = Color.white; for (int i = 0; i < numToSpawn; i++) { float speed = (18f * (1f - 1 / Random.Range(1f, 10f))) * speedOffset; var state = new ParticleBuilder() { velocity = StaticExtensions.Random.RandomVector2(speed, speed), wrapAroundType = wrapAround, lengthMultiplier = lengthMultiplier, velocityDampModifier = 0.94f, removeWhenAlphaReachesThreshold = true }; //custom code for the game to change the color depending on the enemy if (enemy.name.Contains("basic")) { color = Color.white; } else if (enemy.name.Contains("Health")) { color = Color.green; } else if (enemy.name.Contains("Sharp")) { color = Color.yellow; } float duration = 320f; var initialScale = new Vector2(2f, 1f); ParticleFactory.instance.CreateParticle(position, color, duration, initialScale, state); } }
static async Task Main(string[] args) { // The host decides where the config comes from var configProvider = new SampleParticleConfigProvider(); //var configProvider = new RoundRobinSampleParticleConfigProvider(); // The host also decides which features are available // Here we're just using reflection to load them all var particle = new ParticleBuilder(configProvider) .WithAllInstalledFeatures() .Build(); // The host controls the particle lifecycle await particle.Start() .ConfigureAwait(false); FakeSomeAuditMessages(particle); FakeAQuery(particle); await particle.Stop() .ConfigureAwait(false); }
private void SpawnExplosion() { WarpGrid.WarpingGrid.Instance.ApplyExplosiveForce(5f, transform.position, 1.3f); float hue1 = UnityEngine.Random.Range(0f, 6f); float hue2 = (hue1 + UnityEngine.Random.Range(0f, 2f)) % 6f; Color colour1 = StaticExtensions.Color.FromHSV(hue1, 0.5f, 1); Color colour2 = StaticExtensions.Color.FromHSV(hue2, 0.5f, 1); for (int i = 0; i < numOfParticlesToSpawnWhenTimeUp; i++) { float speed = (12f * (1f - 1 / UnityEngine.Random.Range(2f, 3f))) * 0.005f; var state = new ParticleBuilder() { velocity = StaticExtensions.Random.RandomVector2(speed, speed), wrapAroundType = WrapAroundType.None, lengthMultiplier = 30f, velocityDampModifier = 0.94f, removeWhenAlphaReachesThreshold = true, canBeCollectedByPlayer = false, ignoreEffectors = true, maxLengthClamp = 1.5f }; var colour = Color.Lerp(colour1, colour2, UnityEngine.Random.Range(0f, 1f)); float duration = UnityEngine.Random.Range(280f, 480f); var initialScale = new Vector2(1f, 1f); ParticleFactory.instance.CreateParticle(transform.position, colour, duration, initialScale, state); } }
private void BuildAgentParticles(CChar agent) { var builder = new ParticleBuilder(); builder.GenerateParticles(agent, agent.Proxy.LParty); }