private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Enemy")) { Boom(); return; } if (collision.CompareTag("WooshBerryPlant")) { BerryPlantController bc = collision.GetComponent <BerryPlantController>(); if (!bc || !bc.canPick) { return; } BeginWoosh(bc.center, collision.transform.GetComponent <BerryPlantController>().getForward()); collision.GetComponent <BerryPlantController>().pickCallback.Invoke(ScriptableObject.CreateInstance <HitBox>()); } if (collision.CompareTag("AllyHitbox")) { AllyHitBoxController hbc = collision.GetComponent <AllyHitBoxController>(); if (hbc.hasHit) { return; } hbc.hasHit = true; HitBox hb = hbc.hitbox; if (flying) { returnToRigidbody(); } if (hb.interactBroom) { float dx = Vector3.Distance(gameManager.Instance.player.transform.position, transform.position); rb.velocity = Vector2.zero; rb.AddForce(Vector2.Scale(new Vector2(1.25f, 1), hb.kbDir) * 150); } } }
private void OnTriggerEnter2D(Collider2D collision) { if (hurtByPlayer && collision.CompareTag("AllyHitbox")) { AllyHitBoxController ac = collision.GetComponent <AllyHitBoxController>(); //if (ac.hasHit) return; HitBox hitbox = ac.hitbox; if (preventMultihit) { ac.hasHit = true; } Vector3 origin = gameManager.Instance.player.transform.position; Vector3 dir = transform.position - origin; lastHitBy = hitbox; if (cantHitThroughWall) { LayerMask wallLayer = LayerMask.NameToLayer("Wall"); if (Physics2D.RaycastAll(origin, dir, dir.magnitude, 1 << wallLayer).Length > 1) { return; } } if (blocking || (blockInfront && Mathf.Sign(dir.x * transform.localScale.x) != 1)) { if (blockCallback != null) { blockCallback.Invoke(); } return; } float dmg = 1; if (!takeOneDamage) { dmg = hitbox.damage; } takeDamage(dmg, hitbox, true); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("AllyHitbox") && canPick) { if (anim.GetBool("Dry")) { return; } AllyHitBoxController hbc = collision.GetComponent <AllyHitBoxController>(); if (hbc.hasHit) { return; } hbc.hasHit = true && tag != "BombBerryPlant"; gameManager.Instance.player.GetComponentInChildren <Deformer>().flashWhite(); HitBox hb = hbc.hitbox; if (hb.broom) { if (tag == "WooshBerryPlant") { broomCallback.Invoke(true); } if (tag == "BumpBerryPlant") { pickCallback.Invoke(hb); } } if (hb.interactBroom) { if (tag == "BombBerryPlant") { pickCallback.Invoke(hb); } } } }