public override void OnHitboxEvent(Hitbox hitbox, float damage) { base.OnHitboxEvent(hitbox, damage); Bullet bullet = hitbox.GetComponent <Bullet>(); if (bullet) { bullet.Vanish(); hitSFX.Play(); } if (gameObject.activeSelf) { StartCoroutine(BlinkAnimation()); } controller.TakeDamage(damage); if (controller.GetHealth() < 1) { ReleaseBullets(); controller.Die(); } }
public override void OnHitboxEvent(Hitbox hitbox, float damage) { base.OnHitboxEvent(hitbox, damage); Bullet bullet = hitbox.GetComponent <Bullet>(); if (bullet) { bullet.Vanish(); hitSFX.Play(); } if (gameObject.activeSelf) { StartCoroutine(BlinkAnimation()); } controller.TakeDamage(damage); if (controller.GetHealth() < 1) { if (bloatOnDeath && state != State.Bloated) { SetBloatedState(); } else { if (bloatOnDeath) { SuicideShots(); } controller.Die(); } } }
public static Hitbox CreateHitbox(GameObject owner, Dictionary <string, string> dict) { GameObject hboxObj = GameObject.CreatePrimitive(PrimitiveType.Cube); hboxObj.name = "Hitbox"; Hitbox hbox = hboxObj.AddComponent <Hitbox>(); hbox.transform.SetParent(owner.transform); hbox.owner = owner.GetComponent <BattleObject>(); Renderer rend = hbox.GetComponent <Renderer>(); Material mat = rend.material; mat.SetColor("_Color", new Color(1.0f, 0, 0, 0.5f)); StandardShaderUtils.ChangeRenderMode(mat, StandardShaderUtils.BlendMode.Transparent); //Load all the hitbox info from the dict of values generated by the subaction hbox.LoadValuesFromDict(dict); hbox.SizeToOwner(owner.GetComponent <BattleObject>()); //FIXME hitbox locks are odd. They're attached to actions for some reason? HitboxLock new_lock = new HitboxLock(hbox.lock_name); hbox.hitbox_lock = new_lock; return(hbox); }
protected virtual void Update() { if (stopAttacking < Time.time) { Attacking = false; } if (Attacking && attackBox) { int collisions = Physics.OverlapBoxNonAlloc(attackBox.transform.position + attackBox.center, attackBox.size / 2.0f, collisionBuffer, attackBox.transform.rotation, attackMask); Collider[] orderedCollisions = collisionBuffer.OrderBy ( collider => collider ? (collider.transform.position - attackBox.transform.position).sqrMagnitude : Mathf.Infinity ).ToArray(); for (int i = 0; i < collisions; i++) { Hitbox hitbox = null; if (orderedCollisions[i].GetComponent <RagdollHitbox>()) { hitbox = orderedCollisions[i].GetComponent <RagdollHitbox>().GetHitbox; } else if (orderedCollisions[i].attachedRigidbody) { hitbox = orderedCollisions[i].attachedRigidbody.GetComponent <Hitbox>(); } if (hitbox && !alreadyHit.Contains(hitbox)) { //Ignore the hitbox if its a weapon with the same parent Weapon weapon = hitbox.GetComponent <Weapon>(); if (weapon && weapon.CheckParentHitbox(GetParentedHitbox)) { continue; } alreadyHit.Add(hitbox); float damageDealt = hitbox.HitPosition( orderedCollisions[i], attack, this); Attacking = false; break; } } } }
public override void Death() { animationUpdater.PlayAnimation("No Motion", false, true); //Stops attacks after death Hitbox.GetComponent <CapsuleCollider>().enabled = false; if (FlagRef_Death) { ZF.SetFlag(FlagRef_Death.name); } base.Death(); }
public MovementController GetParentMovement() { if (parentedHitbox) { return(parentedHitbox.GetComponent <MovementController>()); } else { return(null); } }
public void SetDirectionalAttack(Vector2 direction, bool playerActivated) { attacking = true; m_animator.SetTrigger("Attack"); trailFX.Play(); linearMovement.enabled = true; transform.rotation = Quaternion.Euler(Vector2.SignedAngle(Vector2.left, direction) * Vector3.forward); linearMovement.SetDirection(direction); launchHitbox.GetComponent <Collider2D>().enabled = playerActivated; }
// Update is called once per frame void Update() { if (freezeController.getFreeze()) { return; } Collider2D[] results = new Collider2D[5]; ContactFilter2D filter = new ContactFilter2D(); filter.SetLayerMask(collisionMask); ctrlCollider.OverlapCollider(filter, results); for (int i = 0; i < results.Length; i++) { Collider2D hit = results[i]; if (!hit) { continue; } Hitbox hitbox = hit.GetComponent <Hitbox>(); if (!hitbox) { continue; } if (instakill) { hitbox.Die(); } else { Controller2D ctrl = hitbox.GetComponent <Controller2D>(); Vector2 direction = ctrl == null ? Vector2.right : -ctrl.collisions.faceDir * Vector2.right; if (ctrl.transform.position.y < transform.position.y) { direction.y = -1; } hitbox.Damage(damage.GetValue(), new Hitbox.Knockback { duration = knockbackDuration.GetValue(), direction = direction, speed = knockbackSpeed.GetValue() }); } } }
void GroundP() { hitbox.Damage = 18; hitbox.Duration = 20; hitbox.Direction = 60; NormalizeHitbox(); hitbox.Hitstun = 24; hitbox.Bone = transform.Find("Fighter1/bubbleguy_F_Hand").gameObject; var box = Instantiate(hitbox, transform.position, Quaternion.identity); var colliderSize = hitbox.GetComponent <BoxCollider2D> (); colliderSize.size = new Vector2(2, 1); }
private void DiveAttack(Vector2 facingDirection, float directionModifier) { direction = (facingDirection / 3) + Vector2.down; flightCicle.enabled = false; hitbox.direction = direction; hitbox.transform.localPosition = Vector2.right * .3f; hitbox.GetComponent <Collider2D>().enabled = true; float angle = Vector2.SignedAngle(Vector2.up, direction) + 90; transform.rotation = Quaternion.Euler(Vector3.forward * angle); m_renderer.flipX = true; m_renderer.flipY = (angle > 0) ? true : false; m_animator.SetTrigger("Attack"); flightFX.Play(); diveSFX.Play(); //targetRotation = 90 + (15 * directionModifier); targetRotation = facingLeft ? 180 : 0; state = State.Diving; }
//Okay, so this is a little bit of stuff to determine whether something's a land, ceiling, or wall interaction. See Utils for more details public override void CollisionOnSolid(Hitbox mine, Hitbox other) { ColliderDistance2D distance = mine.GetComponent <Collider2D>().Distance(other.GetComponent <Collider2D>()); double angle = Utils.Force2PI(Utils.VectorAngle(distance.normal)); if (angle > Utils.ToRad(Utils.WallBaseAngleDeg) && angle < Utils.ToRad(180d - Utils.WallBaseAngleDeg)) { CeilBonk(mine, other); } else if (angle > Utils.ToRad(180d + Utils.WallBaseAngleDeg) && angle < Utils.ToRad(360d - Utils.WallBaseAngleDeg)) { Land(mine, other); } else { WallBonk(mine, other); } }
public override void OnHitboxEvent(Hitbox hitbox, float damage) { base.OnHitboxEvent(hitbox, damage); Bullet bullet = hitbox.GetComponent <Bullet>(); if (bullet) { bullet.Vanish(); linearMovement.MoveBack(); hitSFX.Play(); } StartCoroutine(BlinkAnimation()); controller.TakeDamage(damage); if (controller.GetHealth() < 1) { Explode(); } }
// Start is called before the first frame update void Start() { hitbox = transform.Find("Hitbox").GetComponent <Hitbox>(); mesh = hitbox.GetComponent <MeshRenderer>(); mesh.enabled = false; }
protected int GetDamage(Hitbox hitbox) { Rigidbody2D hitRB = hitbox.GetComponent <Rigidbody2D>(); return(hitbox.Damage(hitRB == null ? 0 : (int)hitRB.velocity.sqrMagnitude)); }