C# Class InRoomRoundTimer, Droid-Soccer

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
Exibir arquivo Open project: repelex/Droid-Soccer Class Usage Examples

Public Properties

Property Type Description
SecondsPerTurn int
StartTime double
TextPos Rect
secondsbeforeend double
starting_severtime double
timetostart double

Public Methods

Method Description
OnGUI ( ) : void
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).

Update ( ) : void

Private Methods

Method Description
StartRoundNow ( ) : void

Method Details

OnGUI() public method

public OnGUI ( ) : void
return void

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

Update() public method

public Update ( ) : void
return void

Property Details

SecondsPerTurn public_oe property

public int SecondsPerTurn
return int

StartTime public_oe property

public double StartTime
return double

TextPos public_oe property

public Rect TextPos
return Rect

secondsbeforeend public_oe property

public double secondsbeforeend
return double

starting_severtime public_oe property

public double starting_severtime
return double

timetostart public_oe property

public double timetostart
return double