BomberUnits
...a Unity learning project
Bomb Class Reference

The Bomb script handles all logics needed for Bomb behaviour in interaction with its Animator state machine. More...

+ Inheritance diagram for Bomb:
+ Collaboration diagram for Bomb:

Public Types

enum  State {
  Idle, HeldCharging, HeldCharged, LitThrowable,
  LitKickable, LitThrown, LitRolling, Detonated
}
 

Public Member Functions

void Init (string clientId, int uid, int newBombRange, float newFuzeLength)
 Actual initialization method with required parameters.
 
void CenterOn (Vector3 pos)
 
void LightFuze ()
 Uses the configured fuze length (countdown duration)
 
void Kick (Vector3 velocity)
 
void Throw ()
 
void EnableFreePhysics ()
 
void StartFuseCountdown (int startTimestamp)
 This saves the fuze ignition time to all clients, which will calcutate the instance of explosion based on this locally. More...
 
void SetAssociatedTile (Tile tile)
 
Tile GetAssociatedTile ()
 

Public Attributes

UnityEvent bombDestroyedEvent
 
Collider moveBlockingCollider
 The firstly active collider while the bomb is not rolling.
 
bool isFuseLitOnStart = false
 Set this on a placed bomb to ignite it without a player.
 
float fuzeLength = 3.0f
 Effective only if lit on start, not synced!
 
int bombRange = 1
 Effective only if lit on start, not synced!
 
State state = State.Idle
 

Private Member Functions

void Awake ()
 
void Start ()
 
void Update ()
 
void OnDestroy ()
 
bool TryToReadInitDataAndInit ()
 This is called whenever we got serialized init data by Network Instantiation. More...
 
void ActivateGravity ()
 
void FollowHoldingChar ()
 
void CheckSyncedFuzeTime ()
 Checks the current synchronized time that has passed against the fuse time. More...
 
void CheckStillThrowable ()
 
void SetCharged ()
 

Private Attributes

bool isCharged = false
 
Animator anim
 
PhotonView photonView
 
Rigidbody rb
 
Player owningPlayer = null
 
Transform holdingPlayerTransf = null
 
Tile associatedTile = null
 
int fuzeLengthInMilliseconds
 
int fuseLitTimestamp
 

Detailed Description

The Bomb script handles all logics needed for Bomb behaviour in interaction with its Animator state machine.

For syncing its properties it needs to be instantiated over Photon. The actual explosion is handled by the Explodable script.

Definition at line 15 of file Bomb.cs.

Member Function Documentation

◆ CheckSyncedFuzeTime()

void CheckSyncedFuzeTime ( )
inlineprivate

Checks the current synchronized time that has passed against the fuse time.

For synchronization it is necessary to do it this way instead of a one-time delayed "Invoke" call.

Definition at line 231 of file Bomb.cs.

◆ StartFuseCountdown()

void StartFuseCountdown ( int  startTimestamp)
inline

This saves the fuze ignition time to all clients, which will calcutate the instance of explosion based on this locally.

The flag activated here starts fuze checking during Update(). Also the charging animation is stopped by setting the 'Lit' Trigger.

Definition at line 189 of file Bomb.cs.

◆ TryToReadInitDataAndInit()

bool TryToReadInitDataAndInit ( )
inlineprivate

This is called whenever we got serialized init data by Network Instantiation.

This is usually the case. Expects: [0]: string clientID, [1]: int playerUID, [2]: int bombRange, [3]: float countdown Returns success.

Definition at line 204 of file Bomb.cs.


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