/// <inheritdoc /> public override void SpawnNew(float dt, ParticleEmitter emitter) { var spawnerState = GetUpdatedState(dt, emitter); if (spawnerState != SpawnerState.Active) { hasBegun = false; return; } if (!hasBegun) { hasBegun = true; oldPosition = emitter.CachedParticleSystem.Translation; return; } var totalDistance = (emitter.CachedParticleSystem.Translation - oldPosition).Length(); oldPosition = emitter.CachedParticleSystem.Translation; var toSpawn = spawnCount * totalDistance + carryOver; var integerPart = (int)Math.Floor(toSpawn); carryOver = toSpawn - integerPart; emitter.EmitParticles(integerPart); }
public InstantExplosionWeapon(string defaultPath, Camera camera) { if (sound == null) sound = new Sound(defaultPath + "Audio/laserfire3.wav"); this.reloadTime = 1000; this.damage = 10; Texture t = new BasicTexture(defaultPath + "Texture/Particle/p.png"); this.position = new Vector3f(); this.direction = new Vector3f(); pe = new PointEmitter(position); Vector3f maxV = new Vector3f(10.0f, 10.0f, 10.0f); Vector3f minV = maxV * -1.0f; Vector3f g = new Vector3f(0.0f, -0.001f, 0.0f); Color4f minC = new Color4f(1.0f, 0.7f, 0.7f, 0.0f); Color4f maxC = new Color4f(1.0f, 1.0f, 1.0f, 1.0f); pf = new BillboardedParticleFactory(t, minV, maxV, g, 0.0f, 1.0f, minC, maxC, 0.2f); ps = new ParticleSystem(pe, pf, camera, false, 0.1f, 1000); pe.setActive(false); ps.reset(); }
void Start() { if( !emitter ) emitter = particleEmitter; emitter.emit = false; }
// Update is called once per frame void Update() { FireParticles = this.transform.Find("Fire_Particles").gameObject.particleEmitter; FireLight = this.transform.Find("Fire_Light").gameObject.light; FireParticles.maxEnergy = 3.0f * (Health/MaxHealth); FireLight.range = 1.5f * Mathf.Sqrt((Health/MaxHealth)); //Debug.Log("Health " + Health); if(Health <= 0){ Destroy(this.gameObject); //gameObject GUIRef = gameObject.GetComponent GameObject[] GUIRef = GameObject.FindGameObjectsWithTag("MainCamera"); Gameplay_GUI ScoreRef = GUIRef[0].gameObject.GetComponent<Gameplay_GUI>(); ScoreRef.g_score += 10; RemoveFireFromRoomTable(); } }
public void Emit(ParticleEmitter emitter) { for (int i = 0; i < _particleSystems.Count; i++) { _particleSystems[i].Emit(emitter); } }
public void RegisterEffect(string name, EmitterData data) { Emitters[name] = new ParticleEmitter(Components, name, Components.RootComponent, Matrix.Identity, data); Emitters[name].DepthSort = false; Emitters[name].Tint = Color.White; Emitters[name].FrustrumCull = false; }
public void AddEmitter(ParticleEmitter emitter) { emitters.Add(emitter); ParticlePool pool = new ParticlePool(this, maxParticlesPerEmitter); CollectionUtils.Put(particlesByEmitter, emitter, pool); }
/* METHODES */ //Constructor void Awake() { // A retenir : GemLight = gameObject.AddComponent("Light") as Light; //Lien avec les composants des particules GemPartEmitter = GetComponent<ParticleEmitter>(); //Lien avec l'Emitter des particules GemPartAnimation = GetComponent<ParticleAnimator>(); //Lien avec l'Animator des particules //GemPartRenderer = GetComponent<ParticleRenderer>(); //Lien avec le Renderer des particules InitialColor = Color.yellow; //Définition de la couleur initiale de la Gemme OppositeColor = Color.magenta; //Définition de la couleur opposé de la Gemme //Initialisation du tableau dynamiquement GemPartStarkle = new Color[5]; //Initialisation des 5 couleurs comosant le Renderer //Lien avec la Lumière GemLight = GetComponent<Light>(); GemTitle = GameObject.Find("GUI Text"); //Lien avec le GUIText de la scène //Initialisation des statuts GemPartEmitter.emit = false; //Dissimulation des particules GemTitle.guiText.enabled = false; //Dissimulation du texte MyPart = (ParticleSystem) Instantiate(test); ChangeMode = false; }
void Awake() { emitter = GetComponent<ParticleEmitter>(); if (whenToEmit == WhenToEmit.Awake) Emit(quantityToEmit); }
// Use this for initialization void Start() { //input = biometricController.GetComponent("BioController") as Controller_Wild_Divine; smoke = GameObject.Find("Smoke").GetComponent("ParticleEmitter") as ParticleEmitter; inner = GameObject.Find("InnerCore").GetComponent("ParticleEmitter") as ParticleEmitter; outer = GameObject.Find("OuterCore").GetComponent("ParticleEmitter") as ParticleEmitter; }
void Start() { if( !emitter ) emitter = GetComponent<ParticleEmitter>(); emitter.emit = false; }
// Use this for initialization void Start () { hidingPlaceLayerMask = 1 << layerIndex; id = GetComponent<PlayerIdentity>(); echoParticleEmitter = GetComponentInChildren<ParticleEmitter>(); ui = GetComponentInChildren<InWorldUI>(); sfxManager = GetComponentInChildren<NetworkedSFXManager>(); }
/* METHODES */ //Constructor void Awake() { //Lien avec les composants des particules GemPartEmitter = GetComponent<ParticleEmitter>(); //Lien avec l'Emitter des particules GemPartAnimation = GetComponent<ParticleAnimator>(); //Lien avec l'Animator des particules InitialColor = Color.magenta; //Définition de la couleur initiale de la Gemme OppositeColor = new Color32(255,132,0,255); //Définition de la couleur opposé de la Gemme //Initialisation du tableau dynamiquement GemPartStarkle = new Color[5]; //Initialisation des 5 couleurs comosant le Renderer //Lien avec la Lumière GemLight = GetComponent<Light>(); GemTitle = GameObject.Find("Title").GetComponent<TextMesh>(); //Lien avec le GUIText de la scène //Initialisation des statuts GemPartEmitter.emit = false; //Dissimulation des particules GemTitle.renderer.enabled = false; //Dissimulation du texte ChangeMode = false; //Récuparation des scripts Blue = GameObject.FindGameObjectWithTag("Blue").GetComponent<BlueGem>(); Yellow = GameObject.FindGameObjectWithTag("Yellow").GetComponent<YellowGem>(); White = GameObject.FindGameObjectWithTag("White").GetComponent<WhiteGem>(); Black = GameObject.FindGameObjectWithTag("Black").GetComponent<BlackGem>(); Red = GameObject.FindGameObjectWithTag("Red").GetComponent<RedGem>(); }
// -------------------------------------------------------------------------------------- // Legacy Only... public static void ConvertToStaticScale(ParticleEmitter pe, ParticleAnimator pa) { if (pe == null) return; Vector3 vecVelScale = (pe.transform.lossyScale); float fVelScale = (NcTransformTool.GetTransformScaleMeanValue(pe.transform)); float fScale = (NcTransformTool.GetTransformScaleMeanValue(pe.transform)); pe.minSize *= fScale; pe.maxSize *= fScale; pe.worldVelocity = Vector3.Scale(pe.worldVelocity, vecVelScale); pe.localVelocity = Vector3.Scale(pe.localVelocity, vecVelScale); pe.rndVelocity = Vector3.Scale(pe.rndVelocity, vecVelScale); pe.angularVelocity *= fVelScale; pe.rndAngularVelocity *= fVelScale; pe.emitterVelocityScale *= fVelScale; if (pa != null) { pa.rndForce = Vector3.Scale(pa.rndForce, vecVelScale); pa.force = Vector3.Scale(pa.force, vecVelScale); // pa.damping *= fScale; } Vector3 ellipsoid; float minEmitterRange; NgSerialized.GetEllipsoidSize(pe, out ellipsoid, out minEmitterRange); NgSerialized.SetEllipsoidSize(pe, ellipsoid * fScale, minEmitterRange * fScale); // NgAssembly.LogFieldsPropertis(pe); }
void Start() { mEmitter = GetComponent<ParticleEmitter>(); mControl = Tools.FindInParents<Spaceship>(transform); mEmission = new Vector2(mEmitter.minEmission, mEmitter.maxEmission); mDir = transform.rotation * Vector3.back; }
public ParticleEffectInstanceManager(EffectManager effect_manager, Mesh character_mesh, bool letter_flipped, ParticleEffectSetup effect_setup, AnimationProgressionVariables progression_vars, AnimatePerOptions animate_per, ParticleEmitter particle_emitter = null, ParticleSystem particle_system = null) { m_particle_emitter = particle_emitter; m_particle_system = particle_system; m_letter_mesh = character_mesh; m_letter_flipped = letter_flipped; m_follow_mesh = effect_setup.m_follow_mesh; m_duration = effect_setup.m_duration.GetValue(progression_vars, animate_per); m_delay = effect_setup.m_delay.GetValue(progression_vars, animate_per); m_position_offset = effect_setup.m_position_offset.GetValue(progression_vars, animate_per); m_rotation_offset = Quaternion.Euler(effect_setup.m_rotation_offset.GetValue(progression_vars, animate_per)); m_rotate_with_letter = effect_setup.m_rotate_relative_to_letter; m_effect_manager_handle = effect_manager; m_active = false; if (m_particle_emitter != null) { m_transform = m_particle_emitter.transform; m_particle_emitter.emit = true; m_particle_emitter.enabled = false; } else if (m_particle_system != null) { m_transform = m_particle_system.transform; m_particle_system.playOnAwake = false; m_particle_system.Play(); #if !UNITY_3_5 && UNITY_EDITOR p_system_timer = 0; #endif } }
void Start() { _damageScript = GetComponent<TakeDamage>(); _controlScript = GetComponent<Controls>(); _emitter = transform.Find("Detailed Smoke").particleEmitter; }
private Vector3 _tmpPos; //calculated position... randomized inside sphere of incoming radius * size #endregion Fields #region Methods public void Awake() { _particleEmitter = (gameObject.AddComponent<EllipsoidParticleEmitter>()) as ParticleEmitter; _particleRenderer = (gameObject.AddComponent<ParticleRenderer>()) as ParticleRenderer; _particleAnimator = (gameObject.AddComponent<ParticleAnimator>()) as ParticleAnimator; _particleRenderer.sortingLayerName = "Topmost"; _particleEmitter.hideFlags = HideFlags.HideAndDontSave; _particleRenderer.hideFlags = HideFlags.HideAndDontSave; _particleAnimator.hideFlags = HideFlags.HideAndDontSave; _particleAnimator.damping = _baseDamping; _particleEmitter.emit = false; _particleRenderer.maxParticleSize = maxScreenSize; _particleRenderer.material = material; _particleRenderer.material.color = Color.white; //workaround for this not being settable elsewhere _particleAnimator.sizeGrow = sizeGrow; if (explodeOnAwake) { Explode(); } }
public void SetUp() { gameObject.SetActive(true); if(smokeEmitterInstance) { smokeEmitterInstance.ClearParticles(); smokeEmitterInstance = null; } // Reset to original trasform transform.rotation = originalRotation; transform.position = originalPosition; float pixelsToUnits = GameManager.height * 0.5f / Camera.main.orthographicSize; // Randomise the y starting point again float spawnYPos = originalPosition.y + Random.Range(-maxRange, maxRange) / pixelsToUnits * 50f; //todo remove hardcode transform.position = new Vector3(transform.position.x, spawnYPos, transform.position.z); collider2D.enabled = true; rigidbody2D.isKinematic = true; // Randomise the speed again planeSpeed = Random.Range(minSpeed, maxSpeed) / pixelsToUnits; flagObj.localPosition = new Vector3(-50f / pixelsToUnits,10f/pixelsToUnits,0f); rigidbody2D.gravityScale = 10f; }
private void DrawEmitter(GraphicsDevice device, Effect effect, ParticleEmitter emitter) { if (emitter.LiveParticles == 0) return; effect.Parameters["Time"].SetValue(emitter.Time); effect.Parameters["Acceleration"].SetValue(emitter.Acceleration); effect.Parameters["LifeSpan"].SetValue(emitter.LifeSpan); ParticleStateType[] instances = emitter.Particles; if (m_InstanceBuffer.VertexCount < instances.Length) { m_InstanceBuffer.Dispose(); m_InstanceBuffer = new DynamicVertexBuffer(device, typeof(ParticleStateType), 2 * instances.Length, BufferUsage.WriteOnly); } m_InstanceBuffer.SetData(instances, 0, emitter.LiveParticles, SetDataOptions.Discard); var particleres = m_ParticleBuffer.GetResource(); device.SetVertexBuffers( new VertexBufferBinding(particleres.Buffer, 0, 0), new VertexBufferBinding(m_InstanceBuffer, 0, 1) ); device.Indices = m_IndexBuffer; foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); device.DrawInstancedPrimitives(PrimitiveType.TriangleList, 0, 0, particleres.NumVertices, 0, particleres.PrimitiveCount, emitter.LiveParticles); } }
public ParticleEffectInstanceManager(ParticleEmitter p_emitter, EffectManager effect_manager, Mesh character_mesh, float delay, float duration, Vector3 position_offset, bool follow_mesh) { m_emitter = p_emitter; m_duration = duration; m_letter_mesh = character_mesh; m_delay = delay; m_position_offset = position_offset; m_follow_mesh = follow_mesh; m_effect_manager_handle = effect_manager; m_transform = m_emitter.transform; // Enable emitter m_emitter.emit = true; m_emitter.enabled = false; // Position effect according to offset m_letter_mesh.RecalculateNormals(); if(!m_letter_mesh.normals[0].Equals(Vector3.zero)) { Quaternion rotation = Quaternion.LookRotation(m_letter_mesh.normals[0], m_letter_mesh.vertices[1].Equals(m_letter_mesh.vertices[2]) ? Vector3.forward : m_letter_mesh.vertices[1] - m_letter_mesh.vertices[2]); m_transform.position = m_effect_manager_handle.m_transform.position + (rotation * m_position_offset) + (m_letter_mesh.vertices[0] + m_letter_mesh.vertices[1] + m_letter_mesh.vertices[2] + m_letter_mesh.vertices[3]) / 4; m_transform.rotation = rotation; } else { m_transform.position = m_effect_manager_handle.m_transform.position + m_position_offset + (m_letter_mesh.vertices[0] + m_letter_mesh.vertices[1] + m_letter_mesh.vertices[2] + m_letter_mesh.vertices[3]) / 4; } }
void Awake () { mytransform = transform; myparticle = GetComponent<ParticleEmitter>(); mymaterial = GetComponent<Renderer>().sharedMaterial; mycollider = GetComponent<Collider>(); }
void Start() { // We actually need the renderer for the sprite // Actually get a reference to SpriteFollowPlayer and make that do the work playerSpriteManager = GetComponent<SpriteFollowPlayer>(); minimapSpriteRenderer = transform.Find("Minimap Icon").GetComponent<Renderer>(); seekerParticleEmitter = transform.Find("Echo'd Particle Emitter").GetComponent<ParticleEmitter>(); }
protected override void Start() { base.Start(); if( fingerStationaryObject ) stationaryParticleEmitter = fingerStationaryObject.GetComponentInChildren<ParticleEmitter>(); }
// Use this for initialization void Start() { input = biometricController.GetComponent("BiometricInputClient") as BiometricInputClient; smoke = GameObject.Find("Smoke").GetComponent("ParticleEmitter") as ParticleEmitter; inner = GameObject.Find("InnerCore").GetComponent("ParticleEmitter") as ParticleEmitter; outer = GameObject.Find("OuterCore").GetComponent("ParticleEmitter") as ParticleEmitter; flameLight = GameObject.Find("Lightsource").GetComponent("Light") as Light; }
public void SpawnOneBurst() { camera.Position = Vector3D.One / 2; var emitterData = GetEmitterData(spark, 512); emitterData.SpawnInterval = 0.0f; var emitter = new ParticleEmitter(emitterData, Vector3D.Zero); new Command(() => emitter.Spawn(64)).Add(new KeyTrigger(Key.Space)); }
void Awake() { emitter = GetComponent<ParticleEmitter>(); fakeEmitter = GetComponent<FakeParticleEmitter>(); if (emitter) { PullFromLegacyEmitter(emitter); } if (fakeEmitter) { PullFromFakeEmitter(fakeEmitter); } }
// Use this for initialization void Start () { theLover = this; myRigidbody = GetComponent<Rigidbody>(); startPos = transform.position; parts = GetComponentInChildren<ParticleSystem>(); parte = GetComponentInChildren<ParticleEmitter>(); }
// Use this for initialization void Start() { pe = transform.GetComponent<ParticleEmitter>(); if (pe == null) { throw new System.Exception("The gameobject must have a ParticleEmitter for this script to work."); } particleController.addEmitter(pe); }
// Use this for initialization void Awake() { emitter = this.GetComponentInChildren<ParticleEmitter>(); pRenderer = this.GetComponentInChildren<ParticleRenderer>(); manager = GameObject.Find("GameManager").GetComponent<GameManager>(); colors = manager.colors; partMaterials = manager.materials; }
protected void ParseParticleEmitter2Property(Node node, string name) { ParticleEmitter emitter = (ParticleEmitter)node; switch (name) { case "Shape": emitter.Shape = (EmitterShape)lexer.ParseInt(); break; case "EmissionType": emitter.EmissionType = (EmissionType)lexer.ParseInt(); break; case "ParticlesLinkage": emitter.ParticlesLinkage = (ParticlesLinkage)lexer.ParseInt(); break; case "LinkageActorName": emitter.LinkageWidgetName = lexer.ParseQuotedString(); break; case "Number": emitter.Number = lexer.ParseFloat(); break; case "TimeShift": emitter.TimeShift = lexer.ParseFloat(); break; case "ImmortalParticles": emitter.ImmortalParticles = lexer.ParseBool(); break; case "Speed": emitter.Speed = lexer.ParseFloat(); break; case "Life": emitter.Lifetime = lexer.ParseNumericRange(); break; case "Velocity": emitter.Velocity = lexer.ParseNumericRange(); break; case "Zoom": emitter.Zoom = lexer.ParseNumericRange(); break; case "AspectRatio": emitter.AspectRatio = lexer.ParseNumericRange(); break; case "Spin": emitter.Spin = lexer.ParseNumericRange(); break; case "AngularVelocity": emitter.AngularVelocity = lexer.ParseNumericRange(); break; case "Orientation": emitter.Orientation = lexer.ParseNumericRange(); break; case "AlongTrackOrientation": emitter.AlongPathOrientation = lexer.ParseBool(); break; case "Direction": emitter.Direction = lexer.ParseNumericRange(); break; case "WindDirection": emitter.WindDirection = lexer.ParseNumericRange(); break; case "WindAmount": emitter.WindAmount = lexer.ParseNumericRange(); break; case "GravityDirection": emitter.GravityDirection = lexer.ParseNumericRange(); break; case "GravityAmount": emitter.GravityAmount = lexer.ParseNumericRange(); break; case "MagnetAmount": emitter.MagnetAmount = lexer.ParseNumericRange(); break; case "RandMotionRadius": emitter.RandomMotionRadius = lexer.ParseNumericRange(); break; case "RandMotionRotation": emitter.RandomMotionRotation = lexer.ParseNumericRange(); break; case "RandMotionSpeed": emitter.RandomMotionSpeed = lexer.ParseNumericRange(); break; case "RandMotionAspectRatio": emitter.RandomMotionAspectRatio = lexer.ParseFloat(); break; default: ParseGraphicProperty(emitter, name); break; } }
private bool OnStart() { // Create layer that can hold our renderable elements. layer = Layers.CreateDynamic("base"); var andy = ResourceManager.Load <Texture2D>("andy"); var autoscales = new Sprite(300.0f, 300.0f, andy); layer.Add(autoscales); c = new Circle(400.0f, 400.0f, 128.0f, Circle.RoughCircle); c.Fill = Color.White; //c.Texture = ResourceManager.Load<Texture2D>("andy"); c.BorderThickness = 32.0f; layer.Add(c); // Create triangles. for (var i = 0; i < 2; i++) { var triangle = new Triangle(Vector2.Zero, new Vector2(128.0f)); triangle.BorderThickness = 8.0f; triangle.BorderFill = Color.Blue; triangle.Fill = Color.White; triangle.Texture = andy; var transform = triangle.Transform; transform.position.x = 200.0f + 128.0f * i; transform.position.y = 200.0f; triangle.Transform = transform; layer.Add(triangle); } // Test sprite.. var manscales = new Sprite(new Vector2(300.0f), new Vector2(128.0f), andy); layer.Add(manscales); // Create 3 rectangles. for (var i = 0; i < 3; i++) { layer.Add(new Rectangle(100 + 48.0f * i, 100, 32.0f, 32.0f) { BorderThickness = 8.0f }); } // Create particle emitter. ParticleGenerator gen = ParticleGenerator.Empty(); gen.flags |= GeneratorFlags.VaryingVelocity; gen.flags |= GeneratorFlags.VaryingDecayTime; gen.flags |= GeneratorFlags.VaryingSpawnLocation; gen.flags |= GeneratorFlags.VaryingAngularVelocity; gen.flags |= GeneratorFlags.VaryingScale; gen.flags |= GeneratorFlags.UseScaleVelocity; gen.startVelocity = new Vector2(-0.325f, -0.25f); gen.velocityVariance = new Vector2(0.625f, 0.25f); gen.baseDecayTime = 550.0f; gen.decayTimeVariance = 350.0f; gen.spawnLocationMinOffset = new Vector2(-32.0f, 0.0f); gen.spawnLocationMaxOffset = new Vector2(32.0f, 0.0f); gen.baseAngularVelocity = 0.001f; gen.angularVelocityVariance = 0.01f; gen.baseScale = new Vector2(1.0f, 1.0f); gen.scaleVariance = new Vector2(0.5f, 0.5f); gen.baseScaleVelocity = new Vector2(0.001f, 0.001f); gen.scaleVelocityVariance = new Vector2(0.005f, 0.005f); gen.framesToFade = 16; gen.framesToFadeVariance = 4; // TODO: paska osuu tuulettimeen var x = 1280.0f / 2.0f; var y = 600.0f; ParticleEmitter emitter = new ParticleEmitter(gen, andy, new Vector2(x, y), 1024); layer.Add(emitter); var vars = CVars.GetCVars(); Console.WriteLine("CVARS C: {0}", vars.Length); foreach (var cvar in vars) { Console.WriteLine(cvar.ToString() + "\n"); } return(true); }
/// <summary> /// Override to remove the required fields from the parent emitter /// </summary> /// <param name="parentEmitter">Parent emitter from which required fields should be removed</param> public virtual void RemoveRequiredParentFields(ParticleEmitter parentEmitter) { }
partial void InitProjSpecific() { Sprite?.EnsureLazyLoaded(); Prefab.DeformableSprite?.EnsureLazyLoaded(); CurrentSwingAmount = Prefab.SwingAmountRad; CurrentScaleOscillation = Prefab.ScaleOscillation; SwingTimer = Rand.Range(0.0f, MathHelper.TwoPi); ScaleOscillateTimer = Rand.Range(0.0f, MathHelper.TwoPi); if (Prefab.ParticleEmitterPrefabs != null) { ParticleEmitters = new ParticleEmitter[Prefab.ParticleEmitterPrefabs.Count]; ParticleEmitterTriggers = new LevelTrigger[Prefab.ParticleEmitterPrefabs.Count]; for (int i = 0; i < Prefab.ParticleEmitterPrefabs.Count; i++) { ParticleEmitters[i] = new ParticleEmitter(Prefab.ParticleEmitterPrefabs[i]); ParticleEmitterTriggers[i] = Prefab.ParticleEmitterTriggerIndex[i] > -1 ? Triggers[Prefab.ParticleEmitterTriggerIndex[i]] : null; } } if (Prefab.LightSourceParams != null && Prefab.LightSourceParams.Count > 0) { LightSources = new LightSource[Prefab.LightSourceParams.Count]; LightSourceTriggers = new LevelTrigger[Prefab.LightSourceParams.Count]; for (int i = 0; i < Prefab.LightSourceParams.Count; i++) { LightSources[i] = new LightSource(Prefab.LightSourceParams[i]) { Position = new Vector2(Position.X, Position.Y), IsBackground = true }; LightSourceTriggers[i] = Prefab.LightSourceTriggerIndex[i] > -1 ? Triggers[Prefab.LightSourceTriggerIndex[i]] : null; } } Sounds = new RoundSound[Prefab.Sounds.Count]; SoundChannels = new SoundChannel[Prefab.Sounds.Count]; SoundTriggers = new LevelTrigger[Prefab.Sounds.Count]; for (int i = 0; i < Prefab.Sounds.Count; i++) { Sounds[i] = Submarine.LoadRoundSound(Prefab.Sounds[i].SoundElement, false); SoundTriggers[i] = Prefab.Sounds[i].TriggerIndex > -1 ? Triggers[Prefab.Sounds[i].TriggerIndex] : null; } int j = 0; foreach (XElement subElement in Prefab.Config.Elements()) { if (!subElement.Name.ToString().Equals("deformablesprite", StringComparison.OrdinalIgnoreCase)) { continue; } foreach (XElement animationElement in subElement.Elements()) { var newDeformation = SpriteDeformation.Load(animationElement, Prefab.Name); if (newDeformation != null) { newDeformation.Params = Prefab.SpriteDeformations[j].Params; spriteDeformations.Add(newDeformation); j++; } } } VisibleOnSonar = Prefab.SonarDisruption > 0.0f || Prefab.OverrideProperties.Any(p => p != null && p.SonarDisruption > 0.0f) || (Triggers != null && Triggers.Any(t => !MathUtils.NearlyEqual(t.Force, Vector2.Zero) && t.ForceMode != LevelTrigger.TriggerForceMode.LimitVelocity || !string.IsNullOrWhiteSpace(t.InfectIdentifier))); if (VisibleOnSonar && Triggers.Any()) { SonarRadius = Triggers.Select(t => t.ColliderRadius * 1.5f).Max(); } }
public override void OnStart(StartState state) { man = ImpulseVessel_manager.Instance; grav = new GravityTools(); try { //Debris GameObject go_Transporter = new GameObject("emitter_Transporter"); emitter_Transporter = go_Transporter.AddComponent("EllipsoidParticleEmitter") as ParticleEmitter; ParticleAnimator animator_debris = go_Transporter.AddComponent <ParticleAnimator>(); go_Transporter.AddComponent <ParticleRenderer>(); (go_Transporter.renderer as ParticleRenderer).uvAnimationXTile = 7; (go_Transporter.renderer as ParticleRenderer).uvAnimationYTile = 7; Material mat = new Material(Shader.Find("Particles/Additive")); mat.mainTexture = GameDatabase.Instance.GetTexture("SciFi/StarTrekImpulseDrive/particles/transporter_7x7_optimized2", false); go_Transporter.renderer.material = mat; emitter_Transporter.emit = false; emitter_Transporter.minSize = 10f; //radius * 0.05f; //4 3 + emitter_Transporter.maxSize = 10f; //radius * 0.1f; //8 emitter_Transporter.minEnergy = 1; emitter_Transporter.maxEnergy = 2; emitter_Transporter.rndVelocity = Vector3.zero; //1.6f * radius; //150 emitter_Transporter.useWorldSpace = false; emitter_Transporter.rndAngularVelocity = 0; animator_debris.rndForce = new Vector3(0, 0, 0); animator_debris.sizeGrow = 0f; emitter_Transporter.transform.position = FlightGlobals.ActiveVessel.transform.position; emitter_Transporter.Emit(1); TransporterSound = new FXGroup("TransporterSound"); GameObject audioObj = new GameObject(); audioObj.transform.position = FlightGlobals.ActiveVessel.transform.position; audioObj.transform.parent = FlightGlobals.ActiveVessel.transform; // add to parent TransporterSound.audio = audioObj.AddComponent <AudioSource>(); TransporterSound.audio.dopplerLevel = 0f; TransporterSound.audio.Stop(); TransporterSound.audio.clip = GameDatabase.Instance.GetAudioClip(TransporterSoundFile); TransporterSound.audio.loop = false; TransporterSound.audio.Play(); TransporterSound.audio.enabled = false; if (TransporterSound != null && TransporterSound.audio != null) { TransporterSound.audio.time = 0; float soundVolume = GameSettings.SHIP_VOLUME * TransporterSoundVolume; TransporterSound.audio.enabled = true; TransporterSound.audio.volume = soundVolume; } } catch (Exception ex) { Debug.LogError("TransporterSound Error : " + ex.Message); } if (TS == null) { TS = new LCARS_TransporterSystem(); } try { ConfigNode newMSE = null; newMSE = new ConfigNode("MODULE"); newMSE.AddValue("name", "ModuleScienceExperiment"); newMSE.AddValue("experimentID", "TricorderAwayTeamStatus"); newMSE.AddValue("experimentActionName", "AwayTeam's Log"); newMSE.AddValue("resetActionName", "Delete Log"); newMSE.AddValue("useStaging", "False"); newMSE.AddValue("useActionGroups", "True"); newMSE.AddValue("hideUIwhenUnavailable", "True"); newMSE.AddValue("resettable", "True"); newMSE.AddValue("xmitDataScalar", "10.0"); newMSE.AddValue("FxModules", "0"); this.vessel.rootPart.AddModule(newMSE); newMSE = new ConfigNode("MODULE"); newMSE.AddValue("name", "ModuleScienceExperiment"); newMSE.AddValue("experimentID", "TricorderAwayTeamSurfacescan"); newMSE.AddValue("experimentActionName", "Surface Scan"); newMSE.AddValue("resetActionName", "Delete Surface Scan"); newMSE.AddValue("useStaging", "False"); newMSE.AddValue("useActionGroups", "True"); newMSE.AddValue("hideUIwhenUnavailable", "True"); newMSE.AddValue("resettable", "True"); newMSE.AddValue("xmitDataScalar", "10.0"); newMSE.AddValue("FxModules", "0"); this.vessel.rootPart.AddModule(newMSE); newMSE = new ConfigNode("MODULE"); newMSE.AddValue("name", "ModuleScienceExperiment"); newMSE.AddValue("experimentID", "TricorderAwayTeamAtmosphereScan"); newMSE.AddValue("experimentActionName", "Atmosphere Scan"); newMSE.AddValue("resetActionName", "Delete Atmosphere Scan"); newMSE.AddValue("useStaging", "False"); newMSE.AddValue("useActionGroups", "True"); newMSE.AddValue("hideUIwhenUnavailable", "True"); newMSE.AddValue("resettable", "True"); newMSE.AddValue("xmitDataScalar", "10.0"); newMSE.AddValue("FxModules", "0"); this.vessel.rootPart.AddModule(newMSE); newMSE = new ConfigNode("MODULE"); newMSE.AddValue("name", "ModuleScienceExperiment"); newMSE.AddValue("experimentID", "TricorderAwayTeamLiquidScan"); newMSE.AddValue("experimentActionName", "Liquid Scan"); newMSE.AddValue("resetActionName", "Delete Liquid Scan"); newMSE.AddValue("useStaging", "False"); newMSE.AddValue("useActionGroups", "True"); newMSE.AddValue("hideUIwhenUnavailable", "True"); newMSE.AddValue("resettable", "True"); newMSE.AddValue("xmitDataScalar", "10.0"); newMSE.AddValue("FxModules", "0"); this.vessel.rootPart.AddModule(newMSE); ModuleScienceExperimentList = new Dictionary <string, ModuleScienceExperiment>() { }; foreach (PartModule PM in this.vessel.rootPart.Modules) { if (PM.moduleName == "ModuleScienceExperiment") { ModuleScienceExperiment foo = PM as ModuleScienceExperiment; ModuleScienceExperimentList.Add(foo.experimentID, foo); } //Debug.LogError("ModuleScienceExperiment rootPart.Module=" + PM.name); } /* * MODULE * { * name = ModuleScienceExperiment * experimentID = enterprisestatus * * experimentActionName = Captain's Log * resetActionName = Delete Log * * useStaging = False * useActionGroups = True * hideUIwhenUnavailable = True * resettable = True * * xmitDataScalar = 10.0 * * FxModules = 0 * } * * MODULE * { * name = ModuleScienceContainer * * reviewActionName = Review Mission Data * storeActionName = Log Data * evaOnlyStorage = False * storageRange = 1000.0 * } * * MODULE * { * name = ModuleDataTransmitter * * packetInterval = 0.01 * packetSize = 0.5 * * packetResourceCost = 1000.0 * requiredResource = ElectricCharge * * DeployFxModules = 0 * } */ } catch (Exception ex) { Debug.LogError("ModuleScienceExperiment Error : " + ex.Message); } }
/* ------------------------------------------------------------------------------------------------------ * -- SpawnEffect -- * * This function spawns a new particle effect system each time it's called. The system * spawned is the prefab referenced by the public particleEffect variable. * ------------------------------------------------------------------------------------------------------- */ void SpawnEffect() { // Instantiate the effect prefab. Transform effectObject = Instantiate(particleEffect, this.transform.position, this.transform.rotation) as Transform; // Parent the new effect to this script's transform. effectObject.parent = transform; // Get the particle emitter from the new effect object. ParticleEmitter emitter = effectObject.GetComponent <ParticleEmitter>(); // Make sure autodestruct is on so that dead particles systems get destroyed. ParticleAnimator animator = emitter.transform.GetComponent <ParticleAnimator>(); if (animator != null) { animator.autodestruct = true; } // Generate the particles. emitter.Emit(numberOfArms * particlesPerArm); // Extract the particles from the created emitter. Particle[] p = emitter.particles; // The rotation angle, in radians, between the arms of the spiral. float armSpacing = (2 * Mathf.PI) / numberOfArms; // Loop thru the arms... for (int j = 0; j < numberOfArms; j++) { float r = 0; float theta = 0; float armRotation = j * armSpacing; // Loop thru the particles for this arm and place them. for (int i = 0; i < particlesPerArm; i++) { // This particle's index. int pX = j * particlesPerArm + i; // This is the equation for our spiral in polar coords.... r = originOffset + turnDistance * theta; // All particles are positioned wrt the local transform origin. Vector3 newPos = effectObject.localPosition; //Vector3 newPos = effectObject.position; // Convert to Cartesian coords... newPos.x = newPos.x + r * Mathf.Cos(theta); newPos.z = newPos.z + r * Mathf.Sin(theta); // Rotate the particle about the origin to our desired position for this arm. float x = newPos.x * Mathf.Cos(armRotation) + newPos.z * Mathf.Sin(armRotation); float z = -newPos.x * Mathf.Sin(armRotation) + newPos.z * Mathf.Cos(armRotation); newPos.x = x; newPos.z = z; // Introduce the desired vertical offset. newPos.y = newPos.y + i * verticalTurnDistance; // Update the particle position. if (emitter.useWorldSpace) { newPos = transform.TransformPoint(newPos); } p[pX].position = newPos; // Bump to our next point on the curve. theta += particleSeparation; // Set particle lifetime to account for specified fade. p[pX].energy = p[pX].energy - i * fadeValue; // Set particle size to account for specified variation. p[pX].size = p[pX].size - i * sizeValue; } } // Update the actual particles. emitter.particles = p; }
public void SetManager(ParticleEmitter emitter) { _emitter = emitter; }
/// <summary> /// This method will be called form the emitter when it needs to poll how many particles to spawn (usually once per frame) /// </summary> /// <param name="dt">Time it has past since the last update (in seconds)</param> /// <param name="emitter">Parent emitter in which new particles should be emitter</param> public abstract void SpawnNew(float dt, ParticleEmitter emitter);
/* ------------------------------------------------------------------------------------------------------ * -- SpawnEffect -- * This function spawns a new particle effect system each time it's called. The system * spawned is the prefab referenced by the public particleEffect variable. * ------------------------------------------------------------------------------------------------------- */ void SpawnEffect() { // Instantiate the effect prefab. GameObject effectObject; if (m_ParticlePrefab != null) { effectObject = CreateGameObject(m_ParticlePrefab); if (effectObject == null) { return; } ChangeParent(transform, effectObject.transform, true, null); } else { effectObject = gameObject; } // Get the particle emitter from the new effect object. ParticleEmitter emitter = effectObject.GetComponent <ParticleEmitter>(); if (emitter == null) { return; } emitter.emit = false; emitter.useWorldSpace = false; // Make sure autodestruct is on so that dead particles systems get destroyed. ParticleAnimator animator = emitter.transform.GetComponent <ParticleAnimator>(); if (animator != null) { animator.autodestruct = true; } // Generate the particles. emitter.Emit(m_nNumberOfArms * m_nParticlesPerArm); // Extract the particles from the created emitter. Particle[] p = emitter.particles; // The rotation angle, in radians, between the arms of the spiral. float armSpacing = (2 * Mathf.PI) / m_nNumberOfArms; // Loop thru the arms... for (int j = 0; j < m_nNumberOfArms; j++) { float r = 0; float theta = 0; float armRotation = j * armSpacing; // Loop thru the particles for this arm and place them. for (int i = 0; i < m_nParticlesPerArm; i++) { // This particle's index. int pX = j * m_nParticlesPerArm + i; // This is the equation for our spiral in polar coords.... r = m_fOriginOffset + m_fTurnDistance * theta; // All particles are positioned wrt the local transform origin. Vector3 newPos = effectObject.transform.localPosition; //Vector3 newPos = effectObject.position; // Convert to Cartesian coords... newPos.x = newPos.x + r * Mathf.Cos(theta); newPos.z = newPos.z + r * Mathf.Sin(theta); // Rotate the particle about the origin to our desired position for this arm. float x = newPos.x * Mathf.Cos(armRotation) + newPos.z * Mathf.Sin(armRotation); float z = -newPos.x * Mathf.Sin(armRotation) + newPos.z * Mathf.Cos(armRotation); newPos.x = x; newPos.z = z; // Introduce the desired vertical offset. newPos.y = newPos.y + i * m_fVerticalTurnDistance; // Update the particle position. if (emitter.useWorldSpace) { newPos = transform.TransformPoint(newPos); } p[pX].position = newPos; // Bump to our next point on the curve. theta += m_fParticleSeparation; // Set particle lifetime to account for specified fade. // p[pX].energy = p[pX].energy - i * m_fFadeValue; if (m_fFadeValue != 0) { p[pX].energy = p[pX].energy * (1 - Mathf.Abs(m_fFadeValue)) + p[pX].energy * Mathf.Abs(m_fFadeValue) * (m_fFadeValue < 0 ? m_nParticlesPerArm - i : i + 1) / m_nParticlesPerArm; } // Set particle size to account for specified variation. // p[pX].size = p[pX].size - i * m_fSizeValue; if (m_fSizeValue != 0) { p[pX].size += Mathf.Abs(m_fSizeValue) * (m_fSizeValue < 0 ? m_nParticlesPerArm - i : i + 1) / m_nParticlesPerArm; } } } // Update the actual particles. emitter.particles = p; }
void LegacySetParticle() { ParticleEmitter pe = m_pe; ParticleAnimator pa = m_pa; ParticleRenderer pr = m_pr; if (pe == null || pr == null) { return; } if (m_bLegacyRuntimeScale) { Vector3 vecVelScale = Vector3.one * m_fStartSpeedRate; float fVelScale = m_fStartSpeedRate; pe.minSize *= m_fStartSizeRate; pe.maxSize *= m_fStartSizeRate; pe.minEnergy *= m_fStartLifeTimeRate; pe.maxEnergy *= m_fStartLifeTimeRate; pe.minEmission *= m_fStartEmissionRate; pe.maxEmission *= m_fStartEmissionRate; pe.worldVelocity = Vector3.Scale(pe.worldVelocity, vecVelScale); pe.localVelocity = Vector3.Scale(pe.localVelocity, vecVelScale); pe.rndVelocity = Vector3.Scale(pe.rndVelocity, vecVelScale); pe.angularVelocity *= fVelScale; pe.rndAngularVelocity *= fVelScale; pe.emitterVelocityScale *= fVelScale; // NgAssembly.LogFieldsPropertis(pe); if (pa != null) { pa.rndForce = Vector3.Scale(pa.rndForce, vecVelScale); pa.force = Vector3.Scale(pa.force, vecVelScale); // pa.damping *= fScale; } // pr.velocityScale *= fVelScale; pr.lengthScale *= m_fRenderLengthRate; } else { Vector3 vecVelScale = (m_bScaleWithTransform ? pe.transform.lossyScale : Vector3.one) * m_fStartSpeedRate; float fVelScale = (m_bScaleWithTransform ? NcTransformTool.GetTransformScaleMeanValue(pe.transform) : 1) * m_fStartSpeedRate; float fScale = (m_bScaleWithTransform ? NcTransformTool.GetTransformScaleMeanValue(pe.transform) : 1) * m_fStartSizeRate; pe.minSize *= fScale; pe.maxSize *= fScale; pe.minEnergy *= m_fStartLifeTimeRate; pe.maxEnergy *= m_fStartLifeTimeRate; pe.minEmission *= m_fStartEmissionRate; pe.maxEmission *= m_fStartEmissionRate; pe.worldVelocity = Vector3.Scale(pe.worldVelocity, vecVelScale); pe.localVelocity = Vector3.Scale(pe.localVelocity, vecVelScale); pe.rndVelocity = Vector3.Scale(pe.rndVelocity, vecVelScale); pe.angularVelocity *= fVelScale; pe.rndAngularVelocity *= fVelScale; pe.emitterVelocityScale *= fVelScale; // NgAssembly.LogFieldsPropertis(pe); if (pa != null) { pa.rndForce = Vector3.Scale(pa.rndForce, vecVelScale); pa.force = Vector3.Scale(pa.force, vecVelScale); // pa.damping *= fScale; } // pr.velocityScale *= fVelScale; pr.lengthScale *= m_fRenderLengthRate; } }
protected void ParseParticleTemplateProperty(Node node, string name) { ParticleModifier pm = (ParticleModifier)node; switch (name) { case "TexturePath": pm.Texture = new SerializableTexture(lexer.ParsePath()); try { var path = Path.ChangeExtension(pm.Texture.SerializationPath, "png"); using (var s = isTangerine ? AssetBundle.Current.OpenFile(Lime.Yuzu.Current?.ExpandPath(path) ?? path) : System.IO.File.OpenRead(path)) { using (var b = new Bitmap(s)) { pm.Size = new Vector2(b.Width, b.Height); } } } catch (System.Exception e) { Console.WriteLine($"Warning: can't extract size for particle modifier from {pm.Texture.SerializationPath}, {e.Message}"); } break; case "FirstFrame": pm.FirstFrame = lexer.ParseInt(); break; case "LastFrame": pm.LastFrame = lexer.ParseInt(); break; case "LoopedAnimation": pm.LoopedAnimation = lexer.ParseBool(); break; case "AnimationFPS": pm.AnimationFps = lexer.ParseFloat(); break; case "Scale": { var scale = lexer.ParseFloat(); pm.Scale = new Vector2(scale, scale); break; } case "AspectRatio": { var ar = lexer.ParseFloat(); if (ar != 1f) { pm.Scale = ParticleEmitter.ApplyAspectRatio(pm.Scale, ar); } break; } case "Velocity": pm.Velocity = lexer.ParseFloat(); break; case "WindAmount": pm.WindAmount = lexer.ParseFloat(); break; case "GravityAmount": pm.GravityAmount = lexer.ParseFloat(); break; case "MagnetAmount": pm.MagnetAmount = lexer.ParseFloat(); break; case "Spin": pm.Spin = lexer.ParseFloat(); break; case "AngularVelocity": pm.AngularVelocity = lexer.ParseFloat(); break; case "Color": pm.Color = lexer.ParseColor4(); break; default: ParseActorProperty(node, name); break; } }
void Start() { p = (ParticleEmitter)(GameObject.Find("StrangeParticles").GetComponent(typeof(ParticleEmitter))); particles = p.particles; }
public void SetupParticleEmitter() { pType = 2; pEmitter = thisObj.GetComponent <ParticleEmitter>(); Debug.Log("get ParticleEmitter " + pEmitter); }
/// <inheritdoc /> public unsafe override void SpawnNew(float dt, ParticleEmitter emitter) { if (isParentNameDirty) { RemoveControlGroup(); Parent = emitter.CachedParticleSystem?.GetEmitterByName(ParentName); AddControlGroup(); isParentNameDirty = false; } var spawnerState = GetUpdatedState(dt, emitter); if (spawnerState != SpawnerState.Active) { return; } // Get parent pool if (Parent == null) { return; } var parentPool = Parent.Pool; var parentParticlesCount = parentPool.LivingParticles; if (parentParticlesCount == 0) { return; } var spawnControlGroup = GetSpawnControlField(); if (!spawnControlGroup.IsValid()) { return; } ParticleSpawnTrigger?.PrepareFromPool(parentPool); var randomSeedFieldParent = parentPool.GetField(ParticleFields.RandomSeed); int totalParticlesToEmit = 0; foreach (var parentParticle in parentPool) { uint particlesToEmit = 0; var parentEventTriggered = ParticleSpawnTrigger?.HasTriggered(parentParticle) ?? false; if (parentEventTriggered) { var particlesToEmitFloat = SpawnCount.X; if (randomSeedFieldParent.IsValid()) { var randSeed = parentParticle.Get(randomSeedFieldParent); particlesToEmitFloat = (SpawnCount.X + (SpawnCount.Y - SpawnCount.X) * randSeed.GetFloat(0)); } particlesToEmit = (uint)Math.Floor(particlesToEmitFloat + carryOver); carryOver += (particlesToEmitFloat - particlesToEmit); } ParticleChildrenAttribute childrenAttribute = ParticleChildrenAttribute.Empty; childrenAttribute.ParticlesToEmit = particlesToEmit; totalParticlesToEmit += (int)particlesToEmit; (*((ParticleChildrenAttribute *)parentParticle[spawnControlGroup])) = childrenAttribute; } emitter.EmitParticles(totalParticlesToEmit); }
public static void MoveParticlesWithPlayerVelocity() { move = GameObject.FindWithTag(Globals.PLAYER).GetComponent <PlayerMovement>(); particles = move.GetComponentInChildren <ParticleEmitter>(); particles.worldVelocity = move.moveDirection; }
public override Task <Entity> CreateEntity(EntityHierarchyItemViewModel parent) { var name = ComputeNewName(parent, "Ribbon particle system"); var component = new ParticleSystemComponent(); var emitter = new ParticleEmitter { ParticleLifetime = new Vector2(2, 2) }; // 30 Particles per second var spawner = new SpawnerPerSecond { SpawnCount = 30 }; emitter.Spawners.Add(spawner); // Ribbon var ribbonShape = new ShapeBuilderRibbon { SmoothingPolicy = SmoothingPolicy.Best, Segments = 15, TextureCoordinatePolicy = TextureCoordinatePolicy.Stretched, TexCoordsFactor = 1f }; emitter.ShapeBuilder = ribbonShape; // Velocity var randVel = new InitialVelocitySeed { VelocityMin = new Vector3(-0.15f, 3f, -0.15f), VelocityMax = new Vector3(0.15f, 3, 0.15f) }; emitter.Initializers.Add(randVel); // Spawn Order var initialOrder = new InitialSpawnOrder(); emitter.Initializers.Add(initialOrder); // Size by Lifetime var sizeCurve = new ComputeAnimationCurveFloat(); var key0 = new AnimationKeyFrame <float> { Key = 0, Value = 0.1f }; var key1 = new AnimationKeyFrame <float> { Key = 0.9f, Value = 0f }; sizeCurve.KeyFrames.Add(key0); sizeCurve.KeyFrames.Add(key1); var sizeAnimation = new UpdaterSizeOverTime { SamplerMain = { Curve = sizeCurve } }; emitter.Updaters.Add(sizeAnimation); emitter.SortingPolicy = EmitterSortingPolicy.ByOrder; component.ParticleSystem.Emitters.Add(emitter); return(CreateEntityWithComponent(name, component)); }
// Use this for initialization void Start() { smokeEmitter = smokeObject.GetComponent <ParticleEmitter>(); }
public void Awake() { _rigidbody = GetComponent <Rigidbody> (); _emitter = GetComponent <ParticleEmitter> (); _particles = GetComponent <ParticleSystem> (); }
protected override void updateAttack() { if (attackWait < This.gameTime.TotalGameTime) { if (isAttackAnimDone && !IsSubmerged) { if (HasVomited || This.Game.rand.Next(4) != 0) { #region Spew List <Sprite> targets = (This.Game.CurrentLevel as FrostbyteLevel).allies; Sprite target = GetClosestTarget(targets); if (target != null) { int attackRange = 11; //Create Particle Emitter Effect particleEffect = This.Game.CurrentLevel.GetEffect("ParticleSystem"); Texture2D boulder = This.Game.CurrentLevel.GetTexture("boulder"); foreach (TimeSpan delay in new TimeSpan[] { TimeSpan.Zero, new TimeSpan(0, 0, 0, 1, 500), new TimeSpan(0, 0, 3), }) { ParticleEmitter particleEmitterEarth = new ParticleEmitter(1000, particleEffect, boulder); particleEmitterEarth.effectTechnique = "NoSpecialEffect"; particleEmitterEarth.blendState = BlendState.AlphaBlend; (particleEmitterEarth.collisionObjects.First() as Collision_BoundingCircle).Radius = attackRange; (particleEmitterEarth.collisionObjects.First() as Collision_BoundingCircle).createDrawPoints(); particleEmitters.Add(particleEmitterEarth); Vector2 oldDirection = Direction; double angle = Math.Atan2(Direction.Y, Direction.X); SpriteFrame frame = GetAnimation(); for (int x = 0; x < 3; x++) { mAttacks.Add(LevelFunctions.DelayEnumerable <bool>(Attacks.T1Projectile(target, this, 5, 20, new TimeSpan(0, 0, 0, 1, 750), attackRange, 6f, false, delegate(OurSprite attacker, Vector2 direction, float projectileSpeed, ParticleEmitter particleEmitter) { Random randPosition = new Random(); particleEmitter.createParticles(direction * projectileSpeed, Vector2.Zero, particleEmitterEarth.GroundPos, 10, 10); Vector2 tangent = new Vector2(-direction.Y, direction.X); for (int i = -5; i < 6; i++) { particleEmitter.createParticles(-direction * projectileSpeed * 5, tangent * -i * 40, particleEmitter.GroundPos + tangent * i * ParticleEmitter.EllipsePerspectiveModifier + (float)randPosition.NextDouble() * direction * 8f, 1.5f, 300); } }, particleEmitterEarth, new Vector2(0, -20)), delay).GetEnumerator()); } } } #endregion } else { SetAnimation(18); mAttacks.Add(Attacks.WormVomit(this, 18, 1, 24).GetEnumerator()); HasVomited = true; } } attackWait = This.gameTime.TotalGameTime + new TimeSpan(0, 0, rng.Next(1, 3)); } }
public Player(GameState state, Texture2D texture, Vector2 position, int width, int height, bool isControllable = true) : base(state, texture, position, width, height, true) { playerHealth = playerMaxHealth; FacingDirection = 1; Energy = MaxEnergy; Size = new Vector2(16, 32); Body.Velocity.X = 0; Body.Velocity.Y = -2f; FloatingUpSpeed = 0.8f; FloatingDownSpeed = FloatingUpSpeed * 2; Body.Acceleration.X = 1f; Body.MaxVelocity = 3f; Body.Drag.X = 0.6f; Body.Drag.Y = 0.6f; Body.Enabled = true; Body.Tag = "player"; /* Create a few bullets */ Bullets = new List <Bullet>(); for (int i = 0; i < 50; i++) { Bullet b = new Bullet(state, texture, Vector2.Zero, this); b.Animations.CurrentFrame = new Frame(48, 96, 16, 16); b.Body.SetSize(6, 6, 5, 5); b.Body.Drag.Y *= 1.1f; Bullets.Add(b); } movementParticleEmitter = new ParticleEmitter(State, 0, 0, 128); movementParticleEmitter.EmitterBox.Resize(1, 4); movementParticleEmitter.MakeParticles(texture, 16, 16); movementParticleEmitter.ParticleVelocity = new Vector2(0, 0.01f); movementParticleEmitter.SetAcceleration(0, -0.005f); movementParticleEmitter.XVelocityVariationRange = new Vector2(-20f, 20f); movementParticleEmitter.YVelocityVariationRange = new Vector2(-40f, 40f); movementParticleEmitter.SetTextureCropRectangle(new Rectangle(3 * 16, 6 * 16, 16, 16)); movementParticleEmitter.SpawnRate = 40f; movementParticleEmitter.ParticleLifespanMilliseconds = 750f; movementParticleEmitter.ParticleLifespanVariationMilliseconds = 50f; movementParticleEmitter.InitialScale = 0.5f; movementParticleEmitter.FinalScale = 1.1f; anchorParticleEmitter = new ParticleEmitter(State, 0, 0, 10); //anchorParticleEmitter.EmitterBox.Resize(1, 4); anchorParticleEmitter.EmitterBox.Resize(Body.Bounds.Width, Body.Bounds.Height); anchorParticleEmitter.MakeRandomParticles(texture, new Rectangle[] { new Rectangle(0, 80, 16, 16), new Rectangle(16, 80, 16, 16) }); float dispersion = 200f; anchorParticleEmitter.XVelocityVariationRange = new Vector2(-dispersion, dispersion); anchorParticleEmitter.YVelocityVariationRange = new Vector2(-dispersion, dispersion); anchorParticleEmitter.SpawnRate = 150f; anchorParticleEmitter.ParticleLifespanMilliseconds = 750f; anchorParticleEmitter.ParticleLifespanVariationMilliseconds = 100f; anchorParticleEmitter.InitialScale = 0.5f; anchorParticleEmitter.FinalScale = 0.1f; anchorParticleEmitter.Burst = true; anchorParticleEmitter.ParticlesPerBurst = 5; anchorParticleEmitter.Activated = false; Floating = true; }