private void OnCollisionEnter2D(Collision2D collision) { collisionHitboxComponent = collision.collider.gameObject.GetComponent <HitboxComponent>(); if (!collisionHitboxComponent) { return; } collisionHitboxComponent.DealDamage(damage); }
private void ApplyHitBox() { LZFighterFrame frame = GetFrame(); HitboxComponent hc = fighter.gameObject.GetComponent <HitboxComponent>(); if (hc == null) { Debug.LogWarning(fighter.name + ": No hitbox component found"); return; } hc.SetDefense(frame.hitboxes.FindAll((h) => h._type == FightingGame.HitBox.Type.Body)); hc.SetAttack(frame.hitboxes.FindAll((h) => h._type == FightingGame.HitBox.Type.Attack)); }
private void RayCastShooting(int bulletCount, int shootCost, float damage, Vector2 dispersion, GameObject decal, AudioClip shootClip) { for (int i = 0; i < bulletCount; i++) { Vector3 rayOrigin = mainCam.ViewportToWorldPoint(new Vector2(0.5f, 0.5f)); Vector3 rayDirection = GetDirection(dispersion); RaycastHit shootHit = new RaycastHit(); if (Physics.Raycast(rayOrigin, rayDirection, out shootHit, 100f, ~(1 << 8))) { HitboxComponent tempHitbox = shootHit.collider.GetComponent <HitboxComponent>(); if (tempHitbox != null) { tempHitbox.ApllyDamage(damage); } else { Instantiate(decal, shootHit.point + shootHit.normal * 0.001f, Quaternion.FromToRotation(Vector3.forward, shootHit.normal)); } } } ammoCounter.ChangeAmmoCount(Data.WeaponType, -shootCost); }
public void Register(HitboxComponent component) { registered.Add(component); }