C# Class RaceTimer, KestrelFPV

Simple script that uses a property to sync a start time for a multiplayer game.
When entering a room, the first player will store the synchronized timestamp. You can't set the room's synchronized time in CreateRoom, because the clock on the Master Server and those on the Game Servers are not in sync. We use many servers and each has it's own timer. Everyone else will join the room and check the property to calculate how much time passed since start. You can start a new round whenever you like. Based on this, you should be able to implement a synchronized timer for turns between players.
Inheritance: MonoBehaviour
Show file Open project: eleurent/KestrelFPV Class Usage Examples

Public Properties

Property Type Description
BreakDuration int
TurnDuration int

Public Methods

Method Description
OnJoinedRoom ( ) : void

Called by PUN when this client entered a room (no matter if joined or created).

OnMasterClientSwitched ( PhotonPlayer, newMasterClient ) : void In theory, the client which created the room might crash/close before it sets the start time. Just to make extremely sure this never happens, a new masterClient will check if it has to start a new round.
OnPhotonCustomRoomPropertiesChanged ( Hashtable, propertiesThatChanged ) : void

Called by PUN when new properties for the room were set (by any client in the room).

Start ( ) : void
Update ( ) : void

Private Methods

Method Description
StartRoundNow ( ) : void

Method Details

OnJoinedRoom() public method

Called by PUN when this client entered a room (no matter if joined or created).
public OnJoinedRoom ( ) : void
return void

OnMasterClientSwitched() public method

In theory, the client which created the room might crash/close before it sets the start time. Just to make extremely sure this never happens, a new masterClient will check if it has to start a new round.
public OnMasterClientSwitched ( PhotonPlayer, newMasterClient ) : void
newMasterClient PhotonPlayer,
return void

OnPhotonCustomRoomPropertiesChanged() public method

Called by PUN when new properties for the room were set (by any client in the room).
public OnPhotonCustomRoomPropertiesChanged ( Hashtable, propertiesThatChanged ) : void
propertiesThatChanged Hashtable,
return void

Start() public method

public Start ( ) : void
return void

Update() public method

public Update ( ) : void
return void

Property Details

BreakDuration public property

public int BreakDuration
return int

TurnDuration public property

public int TurnDuration
return int