Class Bomb
Bomb script. Responsible for timing and instantiating the explosion. Used for normal bomb, Pierce bomb and Remote bomb.
Implements
Inherited Members
Namespace: BomberDogs.Level
Assembly: Assembly-CSharp.dll
Syntax
public class Bomb : MonoBehaviour, IDamageTaker
Fields
| Edit this page View SourceExplosionPrefab
Explosion prefab
Declaration
[Tooltip("Prefab to explosion")]
public GameObject ExplosionPrefab
Field Value
| Type | Description |
|---|---|
| GameObject |
ExplosionSize
Current explosion size. If this bomb was dropped through the PlayerDropBombBehaviour this field will be overwritten by the value that this component sends.
Declaration
[Tooltip("Explosion size in unity units")]
public int ExplosionSize
Field Value
| Type | Description |
|---|---|
| int |
Pierce
If this is turned on the bomb explosion will go through walls.
Declaration
[Tooltip("If the explosion will pierce several walls.")]
public bool Pierce
Field Value
| Type | Description |
|---|---|
| bool |
Remote
If this is turned on the bomb will not explode unless it is activated by remote control.
Declaration
[Tooltip("The bomb will not explode unless activated via remote control.")]
public bool Remote
Field Value
| Type | Description |
|---|---|
| bool |
ShadowObject
Shadow object. Must be contained within the bomb prefab.
Declaration
[Tooltip("Shadow object. Must be contained within the bomb prefab")]
public GameObject ShadowObject
Field Value
| Type | Description |
|---|---|
| GameObject |
TimeToExplode
Time for the bomb to explode
Declaration
[Tooltip("Time for the bomb to explode")]
public float TimeToExplode
Field Value
| Type | Description |
|---|---|
| float |
Methods
| Edit this page View SourceAwake()
Declaration
public void Awake()
ConfigureBombAndInitiate(MonoBehaviour, int)
Configure the bomb and start it. The timer starts counting, and when it finishes it instantiates the bomb explosion object
Declaration
public void ConfigureBombAndInitiate(MonoBehaviour emitter, int explosionSize)
Parameters
| Type | Name | Description |
|---|---|---|
| MonoBehaviour | emitter | Person who emits this bomb |
| int | explosionSize | Bomb explosion size |
Explode()
Explode the bomb
Declaration
public void Explode()
GetTimer()
Get current time on timer
Declaration
public float GetTimer()
Returns
| Type | Description |
|---|---|
| float |
Kick(Vector2)
Kick the bomb. It will slide until it enconters a wall
Declaration
public void Kick(Vector2 dir)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | dir |
OnCollisionEnter2D(Collision2D)
Stop the kicking slide when it collides
Declaration
public void OnCollisionEnter2D(Collision2D col)
Parameters
| Type | Name | Description |
|---|---|---|
| Collision2D | col |
SetToKinematicModeAndSetParent(Transform)
Configure kinematic mode and another necessary things to animate the bomb. This is called when the player throws the bomb.
Declaration
public void SetToKinematicModeAndSetParent(Transform parent)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | parent |
TakeDamage(DamageEmissionDto)
Explode the bomb when takes damage
Declaration
public DamageResponseDto TakeDamage(DamageEmissionDto emission)
Parameters
| Type | Name | Description |
|---|---|---|
| DamageEmissionDto | emission |
Returns
| Type | Description |
|---|---|
| DamageResponseDto |
Throw(Vector2, Vector2, int)
Here the bomb is thrown by the player in the specified direction. This method guides the throw's trajectory until it lands in a free spot. If the bomb reaches the edge of the board, it will reappear on the opposite side of the board.
Declaration
public void Throw(Vector2 fromPosition, Vector2 dir, int distance)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | fromPosition | origin |
| Vector2 | dir | Direction |
| int | distance | Distance |