private void OnCollisionHit(Collider2D collision) { Astronaut a = collision.gameObject.GetComponent <Astronaut>(); if ((a != null) && (a.Alive)) { if (!isStunned()) { if ((Time.time - lastchargehittime) >= 1.5f) { Vector3 dif = (a.transform.position - this.transform.position); HitsDone += 1f; lastchargehittime = Time.time; if (Rushing && ((Time.time - RushingTime) >= readytime)) { Vector3 dire = new Vector3(0f, a.JumpSpeed * 1f * (1f + 1f * Astronaut.AggressionLevelF), 0f); if (Mathf.Abs(Vector3.Dot(dif.normalized, Vector3.up)) < .5f) { dire = new Vector3(a.JumpSpeed * .5f * (1f + 1f * Astronaut.AggressionLevelF) * Mathf.Sign(RushDirection.x), a.JumpSpeed / 8f, 0f); } MyVoidField.Deactivate(); Am.am.oneshot(Am.am.M.VoidSkeleton_Contact); //ImpactParticles.Play(); a.PressParticles.Emit(20); if (a.TakeDamage(30f, dire)) { HitsDone += 4f; } else { //Teleport //Am.am.oneshot(Am.am.VoidWarpSound) } } else if (a.TakeDamage(10f, dif.normalized * 5f + new Vector3(0f, a.JumpSpeed, 0f))) { HitsDone += 4f; } //if (Astronaut.AggressionLevel > 2) //{ //} else //{ //} } } } }
private void OnTriggerEnter2D(Collider2D collision) { Astronaut plr = collision.GetComponent <Astronaut>(); if ((plr != null) && (plr.Alive) && (!plr.Invulnerable) && (Live)) { Vector3 dif = (plr.transform.position - this.transform.position); plr.TakeDamage(30f, dif.normalized * 10f + new Vector3(0f, plr.JumpSpeed / 4f, 0f)); if (plr.Alive) { if ((!plr.Frozen) && ((Time.time - plr.UnfreezeTime) >= 1.5f)) { plr.freeze(1.1f); } } if (plr.Alive) { plr.affectSpore(1f * Astronaut.AggressionLevelF); } explode(); } else if ((collision.gameObject.CompareTag("Geometry")) || (collision.gameObject.GetComponent <IceBlock>() != null) || (collision.gameObject.GetComponent <IcePillar>() != null)) { explode(); } }
private void OnTriggerEnter2D(Collider2D collision) { Astronaut plr = collision.GetComponent <Astronaut>(); if ((plr != null) && (plr.Alive) && (!plr.Invulnerable) && (Live)) { if (!EtherealBehavior) { Vector3 dif = (plr.transform.position - this.transform.position); plr.TakeDamage(30f * DamageMultiplier, dif.normalized * 10f + new Vector3(0f, plr.JumpSpeed / 4f, 0f)); if (plr.Alive) { if ((!plr.Frozen) && ((Time.time - plr.UnfreezeTime) >= 1.5f)) { plr.freeze(1.1f * FreezeTimeMultiplier); } } } else { plr.SendBackToEtherealCheckpoint(); } explode(); } else if ((collision.gameObject.CompareTag("Geometry")) || (collision.gameObject.GetComponent <IceBlock>() != null) || (collision.gameObject.GetComponent <IcePillar>() != null)) { explode(); } }
void OnTriggerStay2D(Collider2D col) { //if ((!Rising) || Falling) return; Astronaut a = col.gameObject.GetComponent <Astronaut>(); if ((a != null)) { if (!Frozen) { //if ((Time.time - a.lastDamageTakenTime) >= 2f) if (a.Alive) { Vector3 dif = (a.transform.position - this.transform.position); float dps = (100f * Time.fixedDeltaTime); if (a.TakeDamage(dps, new Vector3(Mathf.Sign(dif.x), 0f, 0f) * 4f)) { } } else { //BurnParticles } } } }
private void OnCollisionStay2D(Collision2D collision) { Astronaut a = collision.gameObject.GetComponent <Astronaut>(); if ((a != null) && (a.Alive) && (!this.Defeated)) { if (collision.otherCollider.gameObject.Equals(this.gameObject)) { //Collided with the body. Debug.Log("Collided with the Body"); if (!isStunned()) { if ((Time.time - a.lastDamageTakenTime) >= 2f) { Vector3 dif = (a.transform.position - this.transform.position); a.TakeDamage(5f, dif.normalized * 10f + new Vector3(0f, a.JumpSpeed, 0f)); } } } else if (collision.otherCollider.gameObject.Equals(ClawCollider)) { } else { Debug.Log("Collided with?: " + collision.otherCollider.gameObject.name); } } }
private void OnTriggerStay2D(Collider2D collision) { Astronaut a = collision.gameObject.GetComponent <Astronaut>(); if ((a != null) && (a.Alive)) { if (EtherealBehavior) { if (EtherealWillingToTeach) { if (!isStunned()) { a.SendBackToEtherealCheckpoint(); } } } else { if (!isStunned()) { if ((Time.time - a.lastDamageTakenTime) >= 2f) { Vector3 dif = (a.transform.position - this.transform.position); HitsDone += 1f; if (a.TakeDamage(20f, dif.normalized * 4f + new Vector3(0f, 0f, 0f))) { HitsDone += 4f; } } } } } }
private void OnCollisionStay2D(Collision2D collision) { Astronaut a = collision.gameObject.GetComponent <Astronaut>(); if ((a != null) && (a.Alive)) { if (!isStunned()) { if ((Time.time - a.lastDamageTakenTime) >= 1f) { Vector3 dif = (a.transform.position - this.transform.position); HitsDone += 1f; if (a.TakeDamage(20f, dif.normalized * 10f + new Vector3(0f, a.JumpSpeed, 0f))) { HitsDone += 4f; } if (a.Alive) { if (Astronaut.AggressionLevel > 0) { if (((Time.time - a.UnfreezeTime) >= 1.5f) && (!a.Frozen)) { if (Frosting) { a.freeze(.5f + (1.5f * (Astronaut.AggressionLevelF))); } } } } } } } }
private void OnTriggerStay2D(Collider2D collision) { Astronaut a = collision.gameObject.GetComponent <Astronaut>(); if ((a != null) && (a.Alive)) { if (!isStunned()) { //if ((Time.time - a.lastDamageTakenTime) >= 2f) //{ if (Inhaling) { Vector3 dif = (a.transform.position - this.transform.position); float suckspeed = ((8f * (1f + (1f * Astronaut.AggressionLevelF))) * suckacceleration); if (dif.magnitude < (suckspeed * Time.fixedDeltaTime * 3)) { HitsDone += 1f; if (a.TakeDamage(40f, new Vector3())) { HitsDone += 4f; } a.transform.position = this.transform.position; a.MyRigidbody.velocity = new Vector2(); Physics2D.IgnoreCollision(MyCollider, a.MyCollider, true); BiteFlash.transform.LookAt(BiteFlash.transform.position - dif); BiteFlash.Play(true); Inhaling = false; MySpriteRenderer.sprite = MouthClosedSprite; } } } //} } }
private void OnTriggerStay2D(Collider2D collision) { Astronaut a = collision.gameObject.GetComponent <Astronaut>(); if ((a != null) && (a.Alive)) { if (!MyMossGiantEnemy.isStunned()) { if ((Time.time - a.lastDamageTakenTime) >= .5f) { Am.am.oneshot(Am.am.M.MossGiantClubHit); Vector3 dif = (a.transform.position - this.transform.position); MyMossGiantEnemy.HitsDone += 1f; if (a.TakeDamage(20f, new Vector3(dif.x, -Mathf.Abs(dif.y), 0f).normalized *(1f + (1.25f * Astronaut.AggressionLevel)) + new Vector3(0f, a.JumpSpeed * .025f, 0f))) { MyMossGiantEnemy.HitsDone += 4f; } else { if (Astronaut.AggressionLevel > 1) { RaycastHit2D rh = Physics2D.Raycast(a.transform.position, Vector3.down, 2f, LayerMask.GetMask(new string[] { "Geometry" })); if (rh.collider != null) { a.pressIntoGround(new Vector3(rh.point.x, rh.point.y) + Vector3.up * 0.01f, 1f + (.5f * Astronaut.AggressionLevel)); } } } } } } }
private void OnTriggerStay2D(Collider2D collision) { if ((!Live || !Launched)) { return; } Astronaut plr = collision.GetComponent <Astronaut>(); if ((plr != null) && (plr.Alive) && (!plr.Invulnerable) && (Live)) { Am.am.oneshot(Am.am.M.FireballHit); Am.am.oneshot(Am.am.M.LavaBurn); Vector3 dif = (plr.transform.position - this.transform.position); plr.TakeDamage(10f, Vector3.zero);//dif.normalized * .2f + new Vector3(0f, plr.JumpSpeed / 4f, 0f) if (plr.Alive) { //plr.burn(2f); } explode(); } else if ((collision.gameObject.GetComponent <IceBlock>() != null) || (collision.gameObject.GetComponent <IcePillar>() != null)) { Am.am.oneshot(Am.am.M.PillarHit); explode(); } }
private void OnTriggerEnter2D(Collider2D collision) { Astronaut plr = collision.GetComponent <Astronaut>(); if ((plr != null) && (plr.Alive) && (!plr.Invulnerable) && (Live)) { Vector3 dif = (plr.transform.position - this.transform.position); plr.TakeDamage(25f, dif.normalized * 1f + new Vector3(0f, plr.JumpSpeed / 4f, 0f)); Am.am.oneshot(Am.am.M.FireballHit); Am.am.oneshot(Am.am.M.LavaBurn); if (plr.Alive) { //plr.freeze(2f); } explode(); } else if ((collision.gameObject.CompareTag("Geometry")) || (collision.gameObject.GetComponent <IceBlock>() != null) || (collision.gameObject.GetComponent <IcePillar>() != null)) { if ((collision.gameObject.GetComponent <IceBlock>() != null) || (collision.gameObject.GetComponent <IcePillar>() != null)) { Am.am.oneshot(Am.am.M.PillarHit); } else { Am.am.oneshot(Am.am.M.FireballHit); } explode(); } }
public void crash() { if (HasCrashed) { return; } HasCrashed = true; foreach (ParticleSystem p in this.GetComponentsInChildren <ParticleSystem>()) { p.transform.SetParent(null); p.Stop(); GameObject.Destroy(p.gameObject, 5f); } Astronaut plr = Astronaut.TheAstronaut; if ((plr != null) && (plr.Alive)) { Vector3 dif = (this.transform.position - plr.transform.position); float sc = 1f; float pre = 1f; float radius = (3f * sc);//*pre float dist = (dif.magnitude / radius); if (dist < 1f) { if ((Time.time - plr.lastDamageTakenTime) >= 1.5f) { Vector3 diff = (plr.transform.position - this.transform.position); float df = (1f - dist); df = Mathf.Pow(df, 1f / (1f + (1f * Astronaut.AggressionLevelF))); if (plr.TakeDamage(80 * df, new Vector3(0f, plr.JumpSpeed * 1f, 0f))) { } } } } if (IsEgg) { Am.am.oneshot(Am.am.M.VoidFireBallExplosion); } else { Am.am.oneshot(Am.am.M.LavaBallExplosion); } GameObject u = GameObject.Instantiate(ParticleExplosion, this.transform.position, ParticleExplosion.transform.rotation).gameObject; GameObject.Destroy(u.gameObject, 10f); GameObject.Destroy(this.gameObject); }
public void explode() { if (exploded) { return; } CoalescingEffect.Stop(true); PepperField.Stop(); PepperField.Clear(); ExplosionEffect.Play(true); exploded = true; Astronaut plr = Astronaut.TheAstronaut; Am.am.oneshot(Am.am.M.FireBallEnemyExplosion); //if (Alive && !isStunned()) //{ Vector3 dif = (this.transform.position - plr.transform.position); float sc = 1f; float pre = 1f; /* * if (premature) * { * float f = ((Time.time - StateTime) / StateDuration); * pre = (.25f + (.75f * f)); * //ExplosionEffect.transform.localScale = (Vector3.one * pre); * } else * { * * ExplosionEffect.transform.localScale = (Vector3.one ); * } */ float radius = (4f * sc); //*pre float dist = (dif.magnitude / radius); if (dist < 1f) { //if ((Time.time - plr.lastDamageTakenTime) >= 1.5f) //{ Vector3 diff = (plr.transform.position - this.transform.position); HitsDone += 1f; float df = (1f - dist); //df = Mathf.Pow(df, 1f/(1f + (1f * Astronaut.AggressionLevelF))); if (plr.TakeDamage(80f * df, (diff.normalized * 30f) + new Vector3(0f, plr.JumpSpeed * 2f, 0f))) { HitsDone += 4f; } //} } //} }
public void onSlashed(Collider2D collider) { Astronaut a = collider.gameObject.GetComponent <Astronaut>(); if ((a != null) && (a.Alive) && (!this.Defeated)) { //Debug.Log("Collided with?: " + collider.gameObject.name); if ((Time.time - a.lastDamageTakenTime) >= 2f) { Vector3 dif = (a.transform.position - this.transform.position); a.TakeDamage(50f, dif.normalized * 10f + new Vector3(0f, a.JumpSpeed, 0f)); } } }
public void OnVolcanoEruptionTriggered(Collider2D col) { if (!(Erupting || AlwaysErupting)) { return; } if (Frozen) { return; } Astronaut a = col.gameObject.GetComponent <Astronaut>(); float dps = (200f * Time.fixedDeltaTime); if ((a != null)) { if (!Frozen) { if ((Time.time - a.ReviveTime) >= 2f) { if (a.Alive) { Vector3 dif = (a.transform.position - this.transform.position); Vector3 cross = Vector3.Cross(this.transform.up, Vector3.forward); Am.am.oneshot(Am.am.M.LavaBurn); if (a.TakeDamage(dps, cross * 0f * 5f * Mathf.Sign(Vector3.Dot(cross, dif)))) { } } else { //BurnParticles } } } } else { GenericEnemy ge = col.gameObject.GetComponent <GenericEnemy>(); if ((ge != null) && (ge.Alive)) { //Am.am.oneshot(Am.am.M.LavaBurn); //ge.Kill(); ge.TakeDamage(dps, new Vector2()); Am.am.oneshot(Am.am.M.LavaBurn); } } }
private void OnSpearHit(Collider2D col) { if (col == null) { return; } Astronaut en = col.GetComponent <Astronaut>(); Vector2 vec = new Vector2((this.transform.position.x - lastposition.x), (this.transform.position.y - lastposition.y)); if (en != null) { //if (col.isTrigger) return; en.TakeDamage(30f, vec * 1f); if (en.Alive) { if (Astronaut.AggressionLevel > 0) { en.freeze(5f * Astronaut.AggressionLevelF); } Am.am.oneshot(Am.am.M.VoidPhantom_SlashHit); Am.am.oneshot(Am.am.M.VoidPhantom_SlashHitMelee); } ParticleSystem p = GameObject.Instantiate(PierceParticles, this.transform.position, Quaternion.LookRotation(-new Vector3(vec.x, vec.y, 0f))); GameObject.Destroy(p.gameObject, 1f); return; } IceBlock ib = col.GetComponentInParent <IceBlock>(); if (ib != null) { //be.TakeDamage(Damage, vec * 1f);//Damage ParticleSystem p = GameObject.Instantiate(PierceParticles, this.transform.position, Quaternion.LookRotation(-new Vector3(vec.x, vec.y, 0f))); ib.Remove(); return; } //Collision with geometry //Remove(); contact(this.transform.position); }
private void OnCollisionStay2D(Collision2D collision) { Astronaut a = collision.gameObject.GetComponent <Astronaut>(); if ((a != null) && (a.Alive)) { if (Astronaut.AggressionLevel >= 2) { if ((Time.time - a.lastDamageTakenTime) >= 1.25f) { Vector3 dif = (a.transform.position - this.transform.position); a.TakeDamage(10f, dif.normalized * 3f + new Vector3(0f, a.JumpSpeed, 0f)); } } } }
private void OnTriggerStay2D(Collider2D collision) { Astronaut plr = collision.GetComponent <Astronaut>(); if ((plr != null) && (plr.Alive) && (!plr.Invulnerable) && (Live)) { Vector3 dif = (plr.transform.position - this.transform.position); float particledot = 5f; plr.TakeDamage(particledot * Time.fixedDeltaTime, MyRigidbody.velocity.normalized * 1f); FrostHitEffect.Play(); //Apply a slow effect? //And possibly a freeze effect } else if ((collision.gameObject.CompareTag("Geometry")) || (collision.gameObject.GetComponent <IceBlock>() != null)) { } }
void OnParticleCollision(GameObject other) { int numCollisionEvents = MagmaSplash.GetCollisionEvents(other, collisionEvents); Astronaut a = other.GetComponent <Astronaut>(); int i = 0; while (i < numCollisionEvents) { if (a) { Vector3 pos = collisionEvents[i].intersection; Vector3 force = collisionEvents[i].velocity * 10; a.TakeDamage(10f * Time.fixedDeltaTime, collisionEvents[i].velocity); } i++; } }
public void Explode() { if (Exploded) { return; } Exploded = true; ExplosionParticles.Play(true); SparkleParticles.Stop(); Astronaut plr = Astronaut.TheAstronaut; Am.am.oneshot(Am.am.M.VoidFireBallExplosion); //if (Alive && !isStunned()) //{ Vector3 dif = (this.transform.position - plr.transform.position); float sc = 1f; float radius = BlastRadius;//(2f * sc);//*pre float dist = (dif.magnitude / radius); if (dist < 1f) { //if ((Time.time - plr.lastDamageTakenTime) >= 1.5f) //{ Vector3 diff = (plr.transform.position - this.transform.position); float df = (1f - dist); //df = Mathf.Pow(df, 1f/(1f + (1f * Astronaut.AggressionLevelF))); if (plr.TakeDamage(20f * df, new Vector3(0f, plr.JumpSpeed * .25f * df, 0f))) { } Am.am.oneshot(Am.am.M.LavaBurn); //} } //} Remove(); }
private void OnTriggerEnter2D(Collider2D collision) { if (!Falling) { return; } Astronaut plr = collision.GetComponent <Astronaut>(); if ((plr != null) && (plr.Alive) && (!plr.Invulnerable) && (Live)) { Vector3 dif = (plr.transform.position - this.transform.position); plr.TakeDamage(10f, dif.normalized * 2f + new Vector3(0f, plr.JumpSpeed / 10f, 0f)); explode(); } else if ((collision.gameObject.CompareTag("Geometry")) || (collision.gameObject.GetComponent <IceBlock>() != null)) { explode(); } }
private void OnTriggerEnter2D(Collider2D collision) { Astronaut plr = collision.GetComponent <Astronaut>(); if ((plr != null) && (plr.Alive) && (!plr.Invulnerable) && (Live) && ((Time.time - lastHitTime) >= .4f)) { lastHitTime = Time.time; Vector3 dif = (plr.transform.position - this.transform.position); plr.TakeDamage(Damage, new Vector3()); //Am.am.oneshot(Am.am.M.FireballHit); //Am.am.oneshot(Am.am.M.LavaBurn); if (plr.Alive) { //plr.freeze(2f); } explode(); if (Launched) { } else { } } else if ((collision.gameObject.CompareTag("Geometry")) || (collision.gameObject.GetComponent <IceBlock>() != null) || (collision.gameObject.GetComponent <IcePillar>() != null)) { if ((collision.gameObject.GetComponent <IceBlock>() != null) || (collision.gameObject.GetComponent <IcePillar>() != null)) { Am.am.oneshot(Am.am.M.PillarHit); } else { //Am.am.oneshot(Am.am.M.FireballHit); } if (Launched) { explode(); } } }
private void OnTriggerEnter2D(Collider2D collision) { Astronaut plr = collision.GetComponent <Astronaut>(); if ((plr != null) && (plr.Alive) && (!plr.Invulnerable) && (Live)) { Vector3 dif = (plr.transform.position - this.transform.position); plr.TakeDamage(15f * DamageRatio, (dif.normalized * 10f + new Vector3(0f, plr.JumpSpeed / 4f, 0f)) * 0f); if (plr.Alive) { } explode(); } else if ((collision.gameObject.CompareTag("Geometry")) || (collision.gameObject.GetComponent <IceBlock>() != null) || (collision.gameObject.GetComponent <IcePillar>() != null)) { explode(); } }
public void contact(Vector3 pos) { if (MadeContact || !Live) { return; } MadeContact = true; Live = false; this.transform.position = pos; Dispersing = true; ContactTime = Time.time; Am.am.oneshot(Am.am.M.MakeIcePillar); ParticleSystem ps = GameObject.Instantiate(IceExplosion, pos, IceExplosion.transform.rotation); ps.Play(true); GameObject.Destroy(ps.gameObject, 4f); //Maybe form some Ice Pillars while you're at it Vector3 dif = (Astronaut.TheAstronaut.transform.position - pos); float mag = (dif.magnitude / 5f); if (mag < 1f) { Astronaut plr = Astronaut.TheAstronaut; plr.TakeDamage(10f, new Vector3()); plr.MyRigidbody.velocity = new Vector2(); if (plr.Alive) { if ((!plr.Frozen) && ((Time.time - plr.UnfreezeTime) >= .25f)) { if (Astronaut.AggressionLevel > 0) { plr.freeze(5f * Astronaut.AggressionLevelF); } } } } }
private void OnCollisionStay2D(Collision2D collision) { Astronaut a = collision.gameObject.GetComponent <Astronaut>(); if (HazardActive) { if ((a != null)) { Vector3 dif = (a.transform.position - this.transform.position); BurnParticles.transform.position = collision.contacts[0].point; BurnParticles.transform.position = collision.contacts[0].point; //BurnParticles.Emit(50); float d = 25f; if (a.Alive) { Am.am.oneshot(Am.am.M.LavaBurn); } if (a.TakeDamage(d, (a.Health > d) ? new Vector3(Mathf.Abs(a.MyRigidbody.velocity.x) * Mathf.Sign(-(a.transform.position - a.LastGroundedLocation).x), 10f, 0f) : new Vector3(0f, 1f, 0f))) { //... //...WHAT HAPPENS IF YOU DIE IN LAVA? //You teleport a.transform.position = a.LastGroundedLocation; a.MyRigidbody.velocity = new Vector2(); } else { } BurnParticles.transform.position = collision.contacts[0].point; BurnParticles.Emit(20 / (prevparticlelowlevel?4:1)); } else { GenericEnemy ge = collision.gameObject.GetComponent <GenericEnemy>(); if ((ge != null) && (ge.Alive)) { Am.am.oneshot(Am.am.M.LavaBurn); ge.Kill(); } } } }
private void OnCollisionStay2D(Collision2D collision) { Astronaut a = collision.gameObject.GetComponent <Astronaut>(); if ((a != null) && (a.Alive)) { if (!isStunned()) { if ((Time.time - a.lastDamageTakenTime) >= 2f) { Vector3 dif = (a.transform.position - this.transform.position); HitsDone += 1f; if (a.TakeDamage(20f, dif.normalized * 3f + new Vector3(0f, a.JumpSpeed * .1f, 0f))) { HitsDone += 4f; } } } } }
private void OnTriggerStay2D(Collider2D col) { //return; if (!Alive) { return; } //Deal Damage over time if (SurpriseFromLava && !surprising) { return; } Astronaut plr = col.gameObject.GetComponent <Astronaut>(); if ((plr != null) && (plr.Alive)) { Vector3 diff = (plr.transform.position - this.transform.position); float dist = (diff.magnitude / ConvectionCollider.radius); if (dist >= 1f) { return; } float df = (1f - dist); //df = Mathf.Pow(df, 1f / (1f + (1f * Astronaut.AggressionLevelF))); if (plr.TakeDamage(20f * df * Time.deltaTime, Vector3.zero)) { HitsDone += 4f; } else { HitsDone += Time.deltaTime * df; } } if (plr != null) { ConvectionGlow.transform.position = plr.transform.position; ConvectionGlow.Emit(1); ConvectionGlow.transform.position = this.transform.position; } }
private void OnTriggerStay2D(Collider2D collision) { Astronaut a = collision.gameObject.GetComponent <Astronaut>(); if ((a != null) && (a.Alive)) { if (!MyBushEnemy.isStunned()) { //if ((Time.time - a.lastDamageTakenTime) >= 2f) //{ Vector3 dif = (a.transform.position - this.transform.position); MyBushEnemy.HitsDone += 1f; if (a.TakeDamage(20f, new Vector3(0f, a.JumpSpeed * .25f, 0f))) { MyBushEnemy.HitsDone += 4f; } //} } } }
private void OnCollisionEnter2D(Collision2D collision) { Astronaut a = collision.gameObject.GetComponent <Astronaut>(); if ((a != null) && (a.Alive)) { if (EtherealBehavior) { //teleport the player backward if (EtherealWillingToTeach) { a.SendBackToEtherealCheckpoint(); } } else { if (!isStunned()) { if ((Time.time - a.lastDamageTakenTime) >= 2f) { Vector3 dif = (a.transform.position - this.transform.position); HitsDone += 1f; if (Astronaut.AggressionLevel > 0) { if ((!a.Frozen) && ((Time.time - a.UnfreezeTime) >= 1.5f)) { a.freeze(.5f * Astronaut.AggressionLevel); } } if (a.TakeDamage(20f, dif.normalized * 10f + new Vector3(0f, a.JumpSpeed, 0f))) { HitsDone += 4f; } } } } } }
private void OnTriggerEnter2D(Collider2D collision) { Astronaut plr = collision.GetComponent <Astronaut>(); if ((plr != null) && (plr.Alive) && (!plr.Invulnerable) && (Live) && (lastHitTime < 0f)) { lastHitTime = Time.time; Vector3 dif = (plr.transform.position - this.transform.position); Am.am.oneshot(Am.am.M.VoidPhantom_SlashHit); Am.am.oneshot(Am.am.M.VoidPhantom_SlashHitMelee); plr.TakeDamage(Damage, ((new Vector3(MyRigidbody.velocity.x, MyRigidbody.velocity.y, 0f).normalized *-plr.JumpSpeed) + new Vector3(0f, plr.JumpSpeed / 8, 0f)) * (.1f + (.9f * Astronaut.AggressionLevelF))); //Am.am.oneshot(Am.am.M.FireballHit); //Am.am.oneshot(Am.am.M.LavaBurn); if (plr.Alive) { //plr.freeze(2f); } SliceFlare.Play(true); //slice(); } else if ((collision.gameObject.CompareTag("Geometry")) || (collision.gameObject.GetComponent <IceBlock>() != null) || (collision.gameObject.GetComponent <IcePillar>() != null)) { if ((collision.gameObject.GetComponent <IceBlock>() != null) || (collision.gameObject.GetComponent <IcePillar>() != null)) { Am.am.oneshot(Am.am.M.PillarHit); } else { //Am.am.oneshot(Am.am.M.FireballHit); } slice(); } }