void Remove() { NegativeParticles.Stop(true); NegativeParticles.transform.SetParent(null); GameObject.Destroy(NegativeParticles, 4f); GameObject.Destroy(this.gameObject); }
public override void Kill() { if (!Alive) { return; } Alive = false; //base.Kill(); CoalescingEffect.Stop(true); PepperField.Stop(); NegativeParticles.Stop(); Astronaut.PlayKillSound(2); MyRigidbody.bodyType = RigidbodyType2D.Dynamic; Astronaut.TheAstronaut.dropResistance(.4f / (1f + HitsDone), this.transform.position, Astronaut.Element.Fire); exploded = false; if (Astronaut.AggressionLevelF >= 1f) { if (this.MyState == State.Exploding) { premature = true; explode(); } } dontstopparticles = true; deathKnockback(); }
void Start() { StartPosition = this.transform.position; StateTime = Time.time; originalspritesize = MySpriteRenderer.transform.localScale; setState(State.Waiting, .5f + (2f * Random.value)); if (SurpriseFromLava) { NegativeParticles.Stop(); } }
public void Remove() { ParticleExplosion.transform.SetParent(null); //ParticleExplosion.Stop(); GameObject.Destroy(ParticleExplosion.gameObject, 5f); ParticleTrail.transform.SetParent(null); ParticleTrail.Stop(); NegativeParticles.Stop(); NegativeParticles.transform.SetParent(null); GameObject.Destroy(ParticleTrail.gameObject, 5f); GameObject.Destroy(this.gameObject); }
// Update is called once per frame //public VoidProjectile[] private void FixedUpdate() { Astronaut plr = Astronaut.TheAstronaut; if (Alive && !isStunned()) { if ((plr != null) && (plr.Alive) && (!Astronaut.TheAstronaut.Quelling)) { Vector3 dif = (plr.transform.position - this.transform.position); if (dif.magnitude < 10f) { bool los = (Physics2D.Linecast(this.transform.position, plr.transform.position, LayerMask.GetMask(new string[] { "Geometry" })).collider == null); if (Existence >= 1f) { //create some orbs over time //MyVoidField.Activate if (EyeOpen) { MoveDirection = (dif.normalized * .5f) * (1f + (2f * Astronaut.AggressionLevelF)); if ((Time.time - AppearTime) >= 4f) { //Debug.Log("Want to fade"); fadeOut(); } } } else { MoveDirection = new Vector3(); if (!los) { if (Existence > 0f) { } } else { if ((Time.time - DisappearTime) >= (2f * (1f - Astronaut.AggressionLevelF))) { if (Existence == 0f) { stealthTeleport(); fadeIn(); } } } } //LookDirection = (int)((dif.x != 0) ? Mathf.Sign(dif.x) : LookDirection); } } } else { MoveDirection = new Vector3(); } if (Alive) { MyCollider.enabled = (Existence > 0f); MySpriteRenderer.sprite = ((EyeOpen && (Existence >= 1f)) ? EyeOpenSprite : EyeClosedSprite); if (EyeOpen || Fading) { MySpriteRenderer.color = new Color(MySpriteRenderer.color.r, MySpriteRenderer.color.g, MySpriteRenderer.color.b, Existence); } else { } if (Fading) { if (FadingIn) { Existence = Mathf.Clamp01(Existence + (Time.fixedDeltaTime * 1f)); if (Existence >= 1f) { if (Astronaut.AggressionLevel > 0) { MyVoidField.Activate(); } EyeOpen = true; Fading = false; AppearTime = Time.time; } } else { Existence = Mathf.Clamp01(Existence - (Time.fixedDeltaTime * 1f)); if (Existence <= 0f) { Fading = false; DisappearTime = Time.time; fadefinishtime = Time.time; } //Dispose of the Projectiles since we're fading out for (int i = 0; i < MyOrbittingProjectiles.Length; i++) { if (MyOrbittingProjectiles[i] != null) { MyOrbittingProjectiles[i].Disposing = true; MyOrbittingProjectiles[i] = null; } } } } if (Existence > .5f) { if (!NegativeParticles.isPlaying) { NegativeParticles.Play(); } } else { if (NegativeParticles.isPlaying) { NegativeParticles.Stop(); } } if (Existence <= 0f) { MySpriteRenderer.enabled = false; //Dispose of the Projectiles since we're fading out if (isIncinerating()) { IncinerationTime = Time.time; } for (int i = 0; i < MyOrbittingProjectiles.Length; i++) { if (MyOrbittingProjectiles[i] != null) { MyOrbittingProjectiles[i].Disposing = true; MyOrbittingProjectiles[i] = null; } } } else { MySpriteRenderer.enabled = true; if (EyeOpen) { float sr = (1f / (OrbitSpawnRate * (1f + (2f * Astronaut.AggressionLevelF)) * 1f)); for (int i = 0; i < MyOrbittingProjectiles.Length; i++) { if (MyOrbittingProjectiles[i] != null) { MyOrbittingProjectiles[i].transform.position = getOrbitalPosition(i); } else { if (!isStunned()) { if (Time.time - lastProjectileFormTime > sr) { formProjectile(i); } } } } } else { for (int i = 0; i < MyOrbittingProjectiles.Length; i++) { if (MyOrbittingProjectiles[i] != null) { MyOrbittingProjectiles[i].Disposing = true; MyOrbittingProjectiles[i] = null; } } } } if (Alive) { MyRigidbody.velocity = new Vector3(MoveDirection.x, MoveDirection.y, 0f); OrbitalTime += Time.fixedDeltaTime; } else { if ((NegativeParticles) && (NegativeParticles.isPlaying)) { NegativeParticles.Stop(); } } } float sf = (1f + 1.5f * Astronaut.AggressionLevelF); SpeedFactor = Mathf.Lerp(SpeedFactor, sf, .5f); }