protected void HitCharacter(AttachableHitbox user, CharacterCore receiver) { // Apply damage ShowFloatingText(receiver.transform, preset.Damage); receiver.TakeDamage(preset.Damage); user.Character.GetComponent <CharacterCore>().ApplyHitstun(preset.HitstunDuration); receiver.ApplyHitstun(preset.HitstunDuration); }
protected void HitDetachableHitbox(AttachableHitbox user, DetachableHitbox receiver) { // Destroy projectile(or deflect projectile + hitstun the projectile too) MonoBehaviour.Destroy(receiver.gameObject); // Apply hitstun user.Character.GetComponent <CharacterCore>().ApplyHitstun(preset.HitstunDuration); }
protected void HitCharacter(AttachableHitbox triggerer, CharacterCore receiver) { elapsedHitTime += Time.deltaTime; if (elapsedHitTime > preset.LaserTickDuration) { float damage = Mathf.Lerp(preset.MinLaserDamage, preset.MaxLaserDamage, elapsedChargeTime / Mathf.Lerp(preset.MinLaserDuration, preset.MaxLaserDuration, elapsedChargeTime / preset.MaxChargeTime)); ShowFloatingText(receiver.transform, damage); receiver.TakeDamage(damage); elapsedHitTime = 0f; } }
private void OnTriggerStay2D(Collider2D collision) { if (!Active || !StayActive) { return; } if (ReferenceEquals(User, collision.gameObject)) // If I collided with the user, ignore { return; } bool successfulHit = false; if (attachedHitboxLayer.Contains(collision.gameObject)) { AttachableHitbox other = collision.GetComponent <AttachableHitbox>(); OnHitAttachableHitboxStay?.Invoke((T)this, other); HitAttachableHitboxStay(other); successfulHit = true; } else if (detachedHitboxLayer.Contains(collision.gameObject)) { DetachableHitbox other = collision.GetComponent <DetachableHitbox>(); if (GetInstanceID() > other.GetInstanceID()) { OnHitDetachableHitboxStay?.Invoke((T)this, other); // Apply Destroy() within the Effect HitDetachableHitboxStay(other); successfulHit = true; } } else if (characterLayer.Contains(collision.gameObject)) { CharacterCore other = collision.GetComponent <CharacterCore>(); OnHitCharacterStay?.Invoke((T)this, other); HitCharacterStay(other); successfulHit = true; } else if (groundLayer.Contains(collision.gameObject)) { OnHitGroundStay?.Invoke((T)this); HitGroundStay(); successfulHit = true; } // General behaviour if (successfulHit) { HitAnythingStay(); } }
protected void HitAttachableHitbox(AttachableHitbox user, AttachableHitbox receiver) { // Parry user.Character.GetComponent <CharacterCore>().ApplyHitstun(preset.HitstunDuration); receiver.Character.GetComponent <CharacterCore>().ApplyHitstun(preset.HitstunDuration); }
protected virtual void HitAttachableHitboxStay(AttachableHitbox other) { }
protected virtual void HitAttachableHitboxEnter(AttachableHitbox other) { }