Corgi Engine  v8.8
MoreMountains.CorgiEngine.DamageOnTouch Class Reference

Add this component to an object and it will cause damage to objects that collide with it. More...

Inheritance diagram for MoreMountains.CorgiEngine.DamageOnTouch:
MoreMountains.CorgiEngine.CorgiMonoBehaviour

Public Types

enum  KnockbackStyles { KnockbackStyles.NoKnockback, KnockbackStyles.SetForce, KnockbackStyles.AddForce }
 the possible ways to add knockback : noKnockback, which won't do nothing, set force, or add force More...
 
enum  CausedKnockbackDirections { CausedKnockbackDirections.BasedOnOwnerPosition, CausedKnockbackDirections.BasedOnSpeed, CausedKnockbackDirections.BasedOnDamageOnTouchPosition }
 the possible knockback directions when causing damage More...
 
enum  TakenKnockbackDirections { TakenKnockbackDirections.BasedOnDamagerPosition, TakenKnockbackDirections.BasedOnSpeed, TakenKnockbackDirections.BasedOnDamageOnTouchPosition }
 the possible knockback directions when taking damage More...
 

Public Member Functions

delegate void OnHitDelegate ()
 a delegate used to communicate hit events More...
 
virtual void SetCorgiController (CorgiController newController)
 A public method you can use to set the controller from another class More...
 
virtual void IgnoreGameObject (GameObject newIgnoredGameObject)
 Adds the gameobject set in parameters to the ignore list More...
 
virtual void StopIgnoringObject (GameObject ignoredGameObject)
 Removes the object set in parameters from the ignore list More...
 
virtual void ClearIgnoreList ()
 Clears the ignore list. More...
 
virtual void OnTriggerStay2D (Collider2D collider)
 When a collision with the player is triggered, we give damage to the player and knock it back More...
 
virtual void OnTriggerEnter2D (Collider2D collider)
 

Public Attributes

LayerMask TargetLayerMask
 the layers that will be damaged by this object More...
 
bool ApplyDamageOnTriggerEnter = true
 if this is true, the damage will apply on trigger enter More...
 
bool ApplyDamageOnTriggerStay = true
 if this is true, the damage will apply on trigger stay More...
 
float MinDamageCaused = 10f
 The minimum amount of health to remove from the player's health. More...
 
float MaxDamageCaused = 10f
 The maximum amount of health to remove from the player's health. More...
 
List< TypedDamageTypedDamages
 a list of typed damage definitions that will be applied on top of the base damage More...
 
KnockbackStyles DamageCausedKnockbackType = KnockbackStyles.SetForce
 the type of knockback to apply when causing damage More...
 
CausedKnockbackDirections DamageCausedKnockbackDirection = CausedKnockbackDirections.BasedOnOwnerPosition
 The direction to apply the knockback in. More...
 
Vector2 DamageCausedKnockbackForce = new Vector2(10,2)
 The force to apply to the object that gets damaged. More...
 
float InvincibilityDuration = 0.5f
 The duration of the invincibility frames after the hit (in seconds) More...
 
bool RepeatDamageOverTime = false
 Whether or not this damage on touch zone should apply damage over time. More...
 
int AmountOfRepeats = 3
 if in damage over time mode, how many times should damage be repeated? More...
 
float DurationBetweenRepeats = 1f
 if in damage over time mode, the duration, in seconds, between two damages More...
 
bool DamageOverTimeInterruptible = true
 if in damage over time mode, whether or not it can be interrupted (by calling the Health:InterruptDamageOverTime method More...
 
DamageType RepeatedDamageType
 if in damage over time mode, the type of the repeated damage More...
 
float DamageTakenEveryTime = 0
 The amount of damage taken every time, whether what we collide with is damageable or not. More...
 
float DamageTakenDamageable = 0
 The amount of damage taken when colliding with a damageable object. More...
 
float DamageTakenNonDamageable = 0
 The amount of damage taken when colliding with something that is not damageable. More...
 
KnockbackStyles DamageTakenKnockbackType = KnockbackStyles.NoKnockback
 the type of knockback to apply when taking damage More...
 
TakenKnockbackDirections DamageTakenKnockbackDirection = TakenKnockbackDirections.BasedOnDamagerPosition
 The direction to apply the knockback. More...
 
Vector2 DamageTakenKnockbackForce = Vector2.zero
 The force to apply to the object that gets damaged. More...
 
float DamageTakenInvincibilityDuration = 0.5f
 The duration of the invincibility frames after the hit (in seconds) More...
 
MMFeedbacks HitDamageableFeedback
 the feedback to play when applying damage to a damageable More...
 
MMFeedbacks HitNonDamageableFeedback
 the feedback to play when applying damage to a non damageable More...
 
float FreezeFramesOnHitDuration = 0f
 the duration of freeze frames on hit (leave it at 0 to ignore) More...
 
GameObject Owner
 the owner of the DamageOnTouch zone More...
 
OnHitDelegate OnHit
 
OnHitDelegate OnHitDamageable
 
OnHitDelegate OnHitNonDamageable
 
OnHitDelegate OnKill
 

Protected Member Functions

virtual void Awake ()
 Initialization More...
 
virtual void InitializeFeedbacks ()
 
virtual void OnEnable ()
 OnEnable we set the start time to the current timestamp More...
 
void OnDisable ()
 On Disable we clear our ignore list More...
 
virtual void Update ()
 During last update, we store the position and velocity of the object More...
 
virtual void ComputeVelocity ()
 Computes the velocity based on the object's last position More...
 
virtual void Colliding (Collider2D collider)
 
virtual void OnCollideWithDamageable (Health health)
 Describes what happens when colliding with a damageable object More...
 
virtual void ApplyDamageCausedKnockback (float damage, List< TypedDamage > typedDamages)
 
virtual bool ShouldApplyKnockback (float damage, List< TypedDamage > typedDamages)
 Determines whether or not knockback should be applied More...
 
virtual void ApplyDamageTakenKnockback ()
 
virtual void OnCollideWithNonDamageable ()
 Describes what happens when colliding with a non damageable object More...
 
virtual void SelfDamage (float damage)
 Applies damage to itself More...
 
virtual void OnDrawGizmos ()
 A method used to draw gizmos More...
 

Protected Attributes

Vector2 _lastPosition
 
float _startTime = 0f
 
Collider2D _collidingCollider
 
Health _colliderHealth
 
CorgiController _corgiController
 
CorgiController _colliderCorgiController
 
CharacterJump _characterJump
 
Health _health
 
List< GameObject > _ignoredGameObjects
 
Color _gizmosColor
 
Vector3 _gizmoSize
 
CircleCollider2D _circleCollider2D
 
BoxCollider2D _boxCollider2D
 
bool _initializedFeedbacks = false
 

Detailed Description

Add this component to an object and it will cause damage to objects that collide with it.

Member Enumeration Documentation

◆ CausedKnockbackDirections

the possible knockback directions when causing damage

Enumerator
BasedOnOwnerPosition 
BasedOnSpeed 
BasedOnDamageOnTouchPosition 

◆ KnockbackStyles

the possible ways to add knockback : noKnockback, which won't do nothing, set force, or add force

Enumerator
NoKnockback 
SetForce 
AddForce 

◆ TakenKnockbackDirections

the possible knockback directions when taking damage

Enumerator
BasedOnDamagerPosition 
BasedOnSpeed 
BasedOnDamageOnTouchPosition 

Member Function Documentation

◆ ApplyDamageCausedKnockback()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.ApplyDamageCausedKnockback ( float  damage,
List< TypedDamage typedDamages 
)
protectedvirtual

◆ ApplyDamageTakenKnockback()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.ApplyDamageTakenKnockback ( )
protectedvirtual

◆ Awake()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.Awake ( )
protectedvirtual

Initialization

◆ ClearIgnoreList()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.ClearIgnoreList ( )
virtual

Clears the ignore list.

◆ Colliding()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.Colliding ( Collider2D  collider)
protectedvirtual

◆ ComputeVelocity()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.ComputeVelocity ( )
protectedvirtual

Computes the velocity based on the object's last position

◆ IgnoreGameObject()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.IgnoreGameObject ( GameObject  newIgnoredGameObject)
virtual

Adds the gameobject set in parameters to the ignore list

Parameters
newIgnoredGameObjectNew ignored game object.

◆ InitializeFeedbacks()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.InitializeFeedbacks ( )
protectedvirtual

◆ OnCollideWithDamageable()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.OnCollideWithDamageable ( Health  health)
protectedvirtual

Describes what happens when colliding with a damageable object

Parameters
healthHealth.

◆ OnCollideWithNonDamageable()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.OnCollideWithNonDamageable ( )
protectedvirtual

Describes what happens when colliding with a non damageable object

◆ OnDisable()

void MoreMountains.CorgiEngine.DamageOnTouch.OnDisable ( )
protected

On Disable we clear our ignore list

◆ OnDrawGizmos()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.OnDrawGizmos ( )
protectedvirtual

A method used to draw gizmos

◆ OnEnable()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.OnEnable ( )
protectedvirtual

OnEnable we set the start time to the current timestamp

◆ OnHitDelegate()

delegate void MoreMountains.CorgiEngine.DamageOnTouch.OnHitDelegate ( )

a delegate used to communicate hit events

◆ OnTriggerEnter2D()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.OnTriggerEnter2D ( Collider2D  collider)
virtual

◆ OnTriggerStay2D()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.OnTriggerStay2D ( Collider2D  collider)
virtual

When a collision with the player is triggered, we give damage to the player and knock it back

Parameters
colliderwhat's colliding with the object.

◆ SelfDamage()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.SelfDamage ( float  damage)
protectedvirtual

Applies damage to itself

Parameters
damageDamage.

◆ SetCorgiController()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.SetCorgiController ( CorgiController  newController)
virtual

A public method you can use to set the controller from another class

Parameters
newController

◆ ShouldApplyKnockback()

virtual bool MoreMountains.CorgiEngine.DamageOnTouch.ShouldApplyKnockback ( float  damage,
List< TypedDamage typedDamages 
)
protectedvirtual

Determines whether or not knockback should be applied

Returns

◆ StopIgnoringObject()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.StopIgnoringObject ( GameObject  ignoredGameObject)
virtual

Removes the object set in parameters from the ignore list

Parameters
ignoredGameObjectIgnored game object.

◆ Update()

virtual void MoreMountains.CorgiEngine.DamageOnTouch.Update ( )
protectedvirtual

During last update, we store the position and velocity of the object

Member Data Documentation

◆ _boxCollider2D

BoxCollider2D MoreMountains.CorgiEngine.DamageOnTouch._boxCollider2D
protected

◆ _characterJump

CharacterJump MoreMountains.CorgiEngine.DamageOnTouch._characterJump
protected

◆ _circleCollider2D

CircleCollider2D MoreMountains.CorgiEngine.DamageOnTouch._circleCollider2D
protected

◆ _colliderCorgiController

CorgiController MoreMountains.CorgiEngine.DamageOnTouch._colliderCorgiController
protected

◆ _colliderHealth

Health MoreMountains.CorgiEngine.DamageOnTouch._colliderHealth
protected

◆ _collidingCollider

Collider2D MoreMountains.CorgiEngine.DamageOnTouch._collidingCollider
protected

◆ _corgiController

CorgiController MoreMountains.CorgiEngine.DamageOnTouch._corgiController
protected

◆ _gizmosColor

Color MoreMountains.CorgiEngine.DamageOnTouch._gizmosColor
protected

◆ _gizmoSize

Vector3 MoreMountains.CorgiEngine.DamageOnTouch._gizmoSize
protected

◆ _health

Health MoreMountains.CorgiEngine.DamageOnTouch._health
protected

◆ _ignoredGameObjects

List<GameObject> MoreMountains.CorgiEngine.DamageOnTouch._ignoredGameObjects
protected

◆ _initializedFeedbacks

bool MoreMountains.CorgiEngine.DamageOnTouch._initializedFeedbacks = false
protected

◆ _lastPosition

Vector2 MoreMountains.CorgiEngine.DamageOnTouch._lastPosition
protected

◆ _startTime

float MoreMountains.CorgiEngine.DamageOnTouch._startTime = 0f
protected

◆ AmountOfRepeats

int MoreMountains.CorgiEngine.DamageOnTouch.AmountOfRepeats = 3

if in damage over time mode, how many times should damage be repeated?

◆ ApplyDamageOnTriggerEnter

bool MoreMountains.CorgiEngine.DamageOnTouch.ApplyDamageOnTriggerEnter = true

if this is true, the damage will apply on trigger enter

◆ ApplyDamageOnTriggerStay

bool MoreMountains.CorgiEngine.DamageOnTouch.ApplyDamageOnTriggerStay = true

if this is true, the damage will apply on trigger stay

◆ DamageCausedKnockbackDirection

CausedKnockbackDirections MoreMountains.CorgiEngine.DamageOnTouch.DamageCausedKnockbackDirection = CausedKnockbackDirections.BasedOnOwnerPosition

The direction to apply the knockback in.

◆ DamageCausedKnockbackForce

Vector2 MoreMountains.CorgiEngine.DamageOnTouch.DamageCausedKnockbackForce = new Vector2(10,2)

The force to apply to the object that gets damaged.

◆ DamageCausedKnockbackType

KnockbackStyles MoreMountains.CorgiEngine.DamageOnTouch.DamageCausedKnockbackType = KnockbackStyles.SetForce

the type of knockback to apply when causing damage

◆ DamageOverTimeInterruptible

bool MoreMountains.CorgiEngine.DamageOnTouch.DamageOverTimeInterruptible = true

if in damage over time mode, whether or not it can be interrupted (by calling the Health:InterruptDamageOverTime method

◆ DamageTakenDamageable

float MoreMountains.CorgiEngine.DamageOnTouch.DamageTakenDamageable = 0

The amount of damage taken when colliding with a damageable object.

◆ DamageTakenEveryTime

float MoreMountains.CorgiEngine.DamageOnTouch.DamageTakenEveryTime = 0

The amount of damage taken every time, whether what we collide with is damageable or not.

◆ DamageTakenInvincibilityDuration

float MoreMountains.CorgiEngine.DamageOnTouch.DamageTakenInvincibilityDuration = 0.5f

The duration of the invincibility frames after the hit (in seconds)

◆ DamageTakenKnockbackDirection

TakenKnockbackDirections MoreMountains.CorgiEngine.DamageOnTouch.DamageTakenKnockbackDirection = TakenKnockbackDirections.BasedOnDamagerPosition

The direction to apply the knockback.

◆ DamageTakenKnockbackForce

Vector2 MoreMountains.CorgiEngine.DamageOnTouch.DamageTakenKnockbackForce = Vector2.zero

The force to apply to the object that gets damaged.

◆ DamageTakenKnockbackType

KnockbackStyles MoreMountains.CorgiEngine.DamageOnTouch.DamageTakenKnockbackType = KnockbackStyles.NoKnockback

the type of knockback to apply when taking damage

◆ DamageTakenNonDamageable

float MoreMountains.CorgiEngine.DamageOnTouch.DamageTakenNonDamageable = 0

The amount of damage taken when colliding with something that is not damageable.

◆ DurationBetweenRepeats

float MoreMountains.CorgiEngine.DamageOnTouch.DurationBetweenRepeats = 1f

if in damage over time mode, the duration, in seconds, between two damages

◆ FreezeFramesOnHitDuration

float MoreMountains.CorgiEngine.DamageOnTouch.FreezeFramesOnHitDuration = 0f

the duration of freeze frames on hit (leave it at 0 to ignore)

◆ HitDamageableFeedback

MMFeedbacks MoreMountains.CorgiEngine.DamageOnTouch.HitDamageableFeedback

the feedback to play when applying damage to a damageable

◆ HitNonDamageableFeedback

MMFeedbacks MoreMountains.CorgiEngine.DamageOnTouch.HitNonDamageableFeedback

the feedback to play when applying damage to a non damageable

◆ InvincibilityDuration

float MoreMountains.CorgiEngine.DamageOnTouch.InvincibilityDuration = 0.5f

The duration of the invincibility frames after the hit (in seconds)

◆ MaxDamageCaused

float MoreMountains.CorgiEngine.DamageOnTouch.MaxDamageCaused = 10f

The maximum amount of health to remove from the player's health.

◆ MinDamageCaused

float MoreMountains.CorgiEngine.DamageOnTouch.MinDamageCaused = 10f

The minimum amount of health to remove from the player's health.

◆ OnHit

OnHitDelegate MoreMountains.CorgiEngine.DamageOnTouch.OnHit

◆ OnHitDamageable

OnHitDelegate MoreMountains.CorgiEngine.DamageOnTouch.OnHitDamageable

◆ OnHitNonDamageable

OnHitDelegate MoreMountains.CorgiEngine.DamageOnTouch.OnHitNonDamageable

◆ OnKill

OnHitDelegate MoreMountains.CorgiEngine.DamageOnTouch.OnKill

◆ Owner

GameObject MoreMountains.CorgiEngine.DamageOnTouch.Owner

the owner of the DamageOnTouch zone

◆ RepeatDamageOverTime

bool MoreMountains.CorgiEngine.DamageOnTouch.RepeatDamageOverTime = false

Whether or not this damage on touch zone should apply damage over time.

◆ RepeatedDamageType

DamageType MoreMountains.CorgiEngine.DamageOnTouch.RepeatedDamageType

if in damage over time mode, the type of the repeated damage

◆ TargetLayerMask

LayerMask MoreMountains.CorgiEngine.DamageOnTouch.TargetLayerMask

the layers that will be damaged by this object

◆ TypedDamages

List<TypedDamage> MoreMountains.CorgiEngine.DamageOnTouch.TypedDamages

a list of typed damage definitions that will be applied on top of the base damage


The documentation for this class was generated from the following file: