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

A class used to describe the behaviour of a projectile, usually spawned by a ProjectileWeapon More...

Inheritance diagram for MoreMountains.CorgiEngine.Projectile:
MoreMountains.Tools.MMPoolableObject MoreMountains.Tools.MMObjectBounds MoreMountains.CorgiEngine.BouncyProjectile MoreMountains.CorgiEngine.ThrownObject

Public Member Functions

virtual void Movement ()
 Handles the projectile's movement, every frame More...
 
virtual void SetDirection (Vector3 newDirection, Quaternion newRotation, bool spawnerIsFacingRight=true)
 Sets the projectile's direction. More...
 
virtual void Flip ()
 Flip the projectile More...
 
virtual void SetWeapon (Weapon newWeapon)
 Sets the projectile's parent weapon. More...
 
virtual void SetOwner (GameObject newOwner)
 Sets the projectile's owner. More...
 
virtual GameObject GetOwner ()
 Returns the current Owner of the projectile More...
 
virtual void SetDamage (int newDamage)
 Sets the damage caused by the projectile's DamageOnTouch to the specified value More...
 
- Public Member Functions inherited from MoreMountains.Tools.MMPoolableObject
delegate void Events ()
 
virtual void Destroy ()
 Turns the instance inactive, in order to eventually reuse it. More...
 
virtual void TriggerOnSpawnComplete ()
 Triggers the on spawn complete event More...
 
- Public Member Functions inherited from MoreMountains.Tools.MMObjectBounds
virtual Bounds GetBounds ()
 Returns the bounds of the object, based on what has been defined More...
 

Public Attributes

bool FaceDirection = true
 if true, the projectile will rotate at initialization towards its rotation More...
 
float Speed = 200
 the speed of the object (relative to the level's speed) More...
 
float Acceleration = 0
 the acceleration of the object over time. Starts accelerating on enable. More...
 
Vector3 Direction = Vector3.left
 the current direction of the object More...
 
bool DirectionCanBeChangedBySpawner = true
 if set to true, the spawner can change the direction of the object. If not the one set in its inspector will be used. More...
 
Vector3 FlipValue = new Vector3(-1,1,1)
 the flip factor to apply if and when the projectile is mirrored More...
 
bool ProjectileIsFacingRight = true
 determines whether or not the projectile is facing right More...
 
float InitialInvulnerabilityDuration =0f
 the initial delay during which the projectile can't be destroyed More...
 
bool DamageOwner = false
 should the projectile damage its owner ? More...
 
bool SpawnSecurityCheck = false
 if this is true, the projectile will perform an extra check on initialization to make sure it's not within an obstacle. If it is, it'll disable itself. More...
 
LayerMask SpawnSecurityCheckLayerMask
 the layermask to use when performing the security check More...
 
- Public Attributes inherited from MoreMountains.Tools.MMPoolableObject
UnityEvent ExecuteOnEnable
 
UnityEvent ExecuteOnDisable
 
float LifeTime = 0f
 The life time, in seconds, of the object. If set to 0 it'll live forever, if set to any positive value it'll be set inactive after that time. More...
 
- Public Attributes inherited from MoreMountains.Tools.MMObjectBounds
WaysToDetermineBounds BoundsBasedOn
 

Protected Member Functions

virtual void Awake ()
 On awake, we store the initial speed of the object More...
 
virtual IEnumerator InitialInvulnerability ()
 Handles the projectile's initial invincibility More...
 
virtual void Initialization ()
 Initializes the projectile More...
 
virtual void CheckForCollider ()
 Performs a local check to see if the projectile is within a collider or not More...
 
virtual void FixedUpdate ()
 On FixedUpdate(), we move the object based on the level's speed and the object's speed, and apply acceleration More...
 
virtual void OnHit ()
 On hit, we trigger a hit on our owner weapon More...
 
virtual void OnHitDamageable ()
 On hit damageable, we trigger a hit damageable on our owner weapon More...
 
virtual void OnHitNonDamageable ()
 On hit non damageable, we trigger a hit non damageable on our owner weapon More...
 
virtual void OnKill ()
 On kill, we trigger a kill on our owner weapon More...
 
override void OnEnable ()
 On enable, we reset the object's speed More...
 
override void OnDisable ()
 On disable, we unsubscribe from our delegates More...
 
- Protected Member Functions inherited from MoreMountains.Tools.MMPoolableObject
virtual void Update ()
 Called every frame More...
 
- Protected Member Functions inherited from MoreMountains.Tools.MMObjectBounds
virtual void Reset ()
 When this component is added we define its bounds. More...
 
virtual void DefineBoundsChoice ()
 Tries to determine automatically what the bounds should be based on. In this order, it'll keep the last found of these : Collider2D, Collider or Renderer. If none of these is found, it'll be set as Undefined. More...
 

Protected Attributes

Weapon _weapon
 
GameObject _owner
 
Vector3 _movement
 
float _initialSpeed
 
SpriteRenderer _spriteRenderer
 
DamageOnTouch _damageOnTouch
 
WaitForSeconds _initialInvulnerabilityDurationWFS
 
BoxCollider2D _collider
 
Vector2 _raycastOrigin
 
Vector2 _raycastDestination
 
bool _facingRightInitially
 
bool _initialFlipX
 
Vector3 _initialLocalScale
 
RaycastHit2D _hit2D
 
Health _health
 
bool _spawnerIsFacingRight
 

Static Protected Attributes

const float _raycastSkinSecurity =0.01f
 

Properties

virtual DamageOnTouch TargetDamageOnTouch [get]
 Returns the associated damage on touch zone. More...
 
- Properties inherited from MoreMountains.Tools.MMObjectBounds
virtual Vector3 Size [get, set]
 

Additional Inherited Members

- Public Types inherited from MoreMountains.Tools.MMObjectBounds
enum  WaysToDetermineBounds { WaysToDetermineBounds.Collider, WaysToDetermineBounds.Collider2D, WaysToDetermineBounds.Renderer, WaysToDetermineBounds.Undefined }
 
- Events inherited from MoreMountains.Tools.MMPoolableObject
Events OnSpawnComplete
 

Detailed Description

A class used to describe the behaviour of a projectile, usually spawned by a ProjectileWeapon

Member Function Documentation

◆ Awake()

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

On awake, we store the initial speed of the object

◆ CheckForCollider()

virtual void MoreMountains.CorgiEngine.Projectile.CheckForCollider ( )
protectedvirtual

Performs a local check to see if the projectile is within a collider or not

◆ FixedUpdate()

virtual void MoreMountains.CorgiEngine.Projectile.FixedUpdate ( )
protectedvirtual

On FixedUpdate(), we move the object based on the level's speed and the object's speed, and apply acceleration

◆ Flip()

virtual void MoreMountains.CorgiEngine.Projectile.Flip ( )
virtual

Flip the projectile

◆ GetOwner()

virtual GameObject MoreMountains.CorgiEngine.Projectile.GetOwner ( )
virtual

Returns the current Owner of the projectile

Returns

◆ InitialInvulnerability()

virtual IEnumerator MoreMountains.CorgiEngine.Projectile.InitialInvulnerability ( )
protectedvirtual

Handles the projectile's initial invincibility

Returns
The invulnerability.

◆ Initialization()

virtual void MoreMountains.CorgiEngine.Projectile.Initialization ( )
protectedvirtual

◆ Movement()

virtual void MoreMountains.CorgiEngine.Projectile.Movement ( )
virtual

Handles the projectile's movement, every frame

Reimplemented in MoreMountains.CorgiEngine.ThrownObject.

◆ OnDisable()

override void MoreMountains.CorgiEngine.Projectile.OnDisable ( )
protectedvirtual

On disable, we unsubscribe from our delegates

Reimplemented from MoreMountains.Tools.MMPoolableObject.

◆ OnEnable()

override void MoreMountains.CorgiEngine.Projectile.OnEnable ( )
protectedvirtual

On enable, we reset the object's speed

Reimplemented from MoreMountains.Tools.MMPoolableObject.

Reimplemented in MoreMountains.CorgiEngine.ThrownObject.

◆ OnHit()

virtual void MoreMountains.CorgiEngine.Projectile.OnHit ( )
protectedvirtual

On hit, we trigger a hit on our owner weapon

◆ OnHitDamageable()

virtual void MoreMountains.CorgiEngine.Projectile.OnHitDamageable ( )
protectedvirtual

On hit damageable, we trigger a hit damageable on our owner weapon

◆ OnHitNonDamageable()

virtual void MoreMountains.CorgiEngine.Projectile.OnHitNonDamageable ( )
protectedvirtual

On hit non damageable, we trigger a hit non damageable on our owner weapon

◆ OnKill()

virtual void MoreMountains.CorgiEngine.Projectile.OnKill ( )
protectedvirtual

On kill, we trigger a kill on our owner weapon

◆ SetDamage()

virtual void MoreMountains.CorgiEngine.Projectile.SetDamage ( int  newDamage)
virtual

Sets the damage caused by the projectile's DamageOnTouch to the specified value

Parameters
newDamage

◆ SetDirection()

virtual void MoreMountains.CorgiEngine.Projectile.SetDirection ( Vector3  newDirection,
Quaternion  newRotation,
bool  spawnerIsFacingRight = true 
)
virtual

Sets the projectile's direction.

Parameters
newDirectionNew direction.
newRotationNew rotation.
spawnerIsFacingRightIf set to true spawner is facing right.

◆ SetOwner()

virtual void MoreMountains.CorgiEngine.Projectile.SetOwner ( GameObject  newOwner)
virtual

Sets the projectile's owner.

Parameters
newOwnerNew owner.

◆ SetWeapon()

virtual void MoreMountains.CorgiEngine.Projectile.SetWeapon ( Weapon  newWeapon)
virtual

Sets the projectile's parent weapon.

Parameters
newWeaponNew weapon.

Member Data Documentation

◆ _collider

BoxCollider2D MoreMountains.CorgiEngine.Projectile._collider
protected

◆ _damageOnTouch

DamageOnTouch MoreMountains.CorgiEngine.Projectile._damageOnTouch
protected

◆ _facingRightInitially

bool MoreMountains.CorgiEngine.Projectile._facingRightInitially
protected

◆ _health

Health MoreMountains.CorgiEngine.Projectile._health
protected

◆ _hit2D

RaycastHit2D MoreMountains.CorgiEngine.Projectile._hit2D
protected

◆ _initialFlipX

bool MoreMountains.CorgiEngine.Projectile._initialFlipX
protected

◆ _initialInvulnerabilityDurationWFS

WaitForSeconds MoreMountains.CorgiEngine.Projectile._initialInvulnerabilityDurationWFS
protected

◆ _initialLocalScale

Vector3 MoreMountains.CorgiEngine.Projectile._initialLocalScale
protected

◆ _initialSpeed

float MoreMountains.CorgiEngine.Projectile._initialSpeed
protected

◆ _movement

Vector3 MoreMountains.CorgiEngine.Projectile._movement
protected

◆ _owner

GameObject MoreMountains.CorgiEngine.Projectile._owner
protected

◆ _raycastDestination

Vector2 MoreMountains.CorgiEngine.Projectile._raycastDestination
protected

◆ _raycastOrigin

Vector2 MoreMountains.CorgiEngine.Projectile._raycastOrigin
protected

◆ _raycastSkinSecurity

const float MoreMountains.CorgiEngine.Projectile._raycastSkinSecurity =0.01f
staticprotected

◆ _spawnerIsFacingRight

bool MoreMountains.CorgiEngine.Projectile._spawnerIsFacingRight
protected

◆ _spriteRenderer

SpriteRenderer MoreMountains.CorgiEngine.Projectile._spriteRenderer
protected

◆ _weapon

Weapon MoreMountains.CorgiEngine.Projectile._weapon
protected

◆ Acceleration

float MoreMountains.CorgiEngine.Projectile.Acceleration = 0

the acceleration of the object over time. Starts accelerating on enable.

◆ DamageOwner

bool MoreMountains.CorgiEngine.Projectile.DamageOwner = false

should the projectile damage its owner ?

◆ Direction

Vector3 MoreMountains.CorgiEngine.Projectile.Direction = Vector3.left

the current direction of the object

◆ DirectionCanBeChangedBySpawner

bool MoreMountains.CorgiEngine.Projectile.DirectionCanBeChangedBySpawner = true

if set to true, the spawner can change the direction of the object. If not the one set in its inspector will be used.

◆ FaceDirection

bool MoreMountains.CorgiEngine.Projectile.FaceDirection = true

if true, the projectile will rotate at initialization towards its rotation

◆ FlipValue

Vector3 MoreMountains.CorgiEngine.Projectile.FlipValue = new Vector3(-1,1,1)

the flip factor to apply if and when the projectile is mirrored

◆ InitialInvulnerabilityDuration

float MoreMountains.CorgiEngine.Projectile.InitialInvulnerabilityDuration =0f

the initial delay during which the projectile can't be destroyed

◆ ProjectileIsFacingRight

bool MoreMountains.CorgiEngine.Projectile.ProjectileIsFacingRight = true

determines whether or not the projectile is facing right

◆ SpawnSecurityCheck

bool MoreMountains.CorgiEngine.Projectile.SpawnSecurityCheck = false

if this is true, the projectile will perform an extra check on initialization to make sure it's not within an obstacle. If it is, it'll disable itself.

◆ SpawnSecurityCheckLayerMask

LayerMask MoreMountains.CorgiEngine.Projectile.SpawnSecurityCheckLayerMask

the layermask to use when performing the security check

◆ Speed

float MoreMountains.CorgiEngine.Projectile.Speed = 200

the speed of the object (relative to the level's speed)

Property Documentation

◆ TargetDamageOnTouch

virtual DamageOnTouch MoreMountains.CorgiEngine.Projectile.TargetDamageOnTouch
get

Returns the associated damage on touch zone.


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