Photon Unity Networking 2 2.45

Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Events | List of all members
CountdownTimer Class Reference

This is a basic, network-synced CountdownTimer based on properties. More...

Inherits MonoBehaviourPunCallbacks.

Public Member Functions

delegate void CountdownTimerHasExpired ()
 OnCountdownTimerHasExpired delegate. More...
 
void Start ()
 
override void OnEnable ()
 
override void OnDisable ()
 
void Update ()
 
override void OnRoomPropertiesUpdate (Hashtable propertiesThatChanged)
 Called when a room's custom properties changed. The propertiesThatChanged contains all that was set via Room.SetCustomProperties. More...
 
- Public Member Functions inherited from MonoBehaviourPunCallbacks
virtual void OnConnected ()
 Called to signal that the raw connection got established but before the client can call operation on the server. More...
 
virtual void OnLeftRoom ()
 Called when the local user/client left a room, so the game's logic can clean up it's internal state. More...
 
virtual void OnMasterClientSwitched (Player newMasterClient)
 Called after switching to a new MasterClient when the current one leaves. More...
 
virtual void OnCreateRoomFailed (short returnCode, string message)
 Called when the server couldn't create a room (OpCreateRoom failed). More...
 
virtual void OnJoinRoomFailed (short returnCode, string message)
 Called when a previous OpJoinRoom call failed on the server. More...
 
virtual void OnCreatedRoom ()
 Called when this client created a room and entered it. OnJoinedRoom() will be called as well. More...
 
virtual void OnJoinedLobby ()
 Called on entering a lobby on the Master Server. The actual room-list updates will call OnRoomListUpdate. More...
 
virtual void OnLeftLobby ()
 Called after leaving a lobby. More...
 
virtual void OnDisconnected (DisconnectCause cause)
 Called after disconnecting from the Photon server. It could be a failure or intentional More...
 
virtual void OnRegionListReceived (RegionHandler regionHandler)
 Called when the Name Server provided a list of regions for your title. More...
 
virtual void OnRoomListUpdate (List< RoomInfo > roomList)
 Called for any update of the room-listing while in a lobby (InLobby) on the Master Server. More...
 
virtual void OnJoinedRoom ()
 Called when the LoadBalancingClient entered a room, no matter if this client created it or simply joined. More...
 
virtual void OnPlayerEnteredRoom (Player newPlayer)
 Called when a remote player entered the room. This Player is already added to the playerlist. More...
 
virtual void OnPlayerLeftRoom (Player otherPlayer)
 Called when a remote player left the room or became inactive. Check otherPlayer.IsInactive. More...
 
virtual void OnJoinRandomFailed (short returnCode, string message)
 Called when a previous OpJoinRandom call failed on the server. More...
 
virtual void OnConnectedToMaster ()
 Called when the client is connected to the Master Server and ready for matchmaking and other tasks. More...
 
virtual void OnPlayerPropertiesUpdate (Player targetPlayer, Hashtable changedProps)
 Called when custom player-properties are changed. Player and the changed properties are passed as object[]. More...
 
virtual void OnFriendListUpdate (List< FriendInfo > friendList)
 Called when the server sent the response to a FindFriends request. More...
 
virtual void OnCustomAuthenticationResponse (Dictionary< string, object > data)
 Called when your Custom Authentication service responds with additional data. More...
 
virtual void OnCustomAuthenticationFailed (string debugMessage)
 Called when the custom authentication failed. Followed by disconnect! More...
 
virtual void OnWebRpcResponse (OperationResponse response)
 Called when the response to a WebRPC is available. See LoadBalancingClient.OpWebRpc. More...
 
virtual void OnLobbyStatisticsUpdate (List< TypedLobbyInfo > lobbyStatistics)
 Called when the Master Server sent an update for the Lobby Statistics. More...
 
virtual void OnErrorInfo (ErrorInfo errorInfo)
 Called when the client receives an event from the server indicating that an error happened there. More...
 

Static Public Member Functions

static bool TryGetStartTime (out int startTimestamp)
 
static void SetStartTime ()
 

Public Attributes

float Countdown = 5.0f
 
Text Text
 

Static Public Attributes

const string CountdownStartTime = "StartTime"
 

Events

static CountdownTimerHasExpired OnCountdownTimerHasExpired
 Called when the timer has expired. More...
 

Additional Inherited Members

- Properties inherited from MonoBehaviourPun
PhotonView photonView [get]
 A cached reference to a PhotonView on this GameObject. More...
 

Detailed Description

This is a basic, network-synced CountdownTimer based on properties.

In order to start the timer, the MasterClient can call SetStartTime() to set the timestamp for the start. The property 'StartTime' then contains the server timestamp when the timer has been started.

In order to subscribe to the CountdownTimerHasExpired event you can call CountdownTimer.OnCountdownTimerHasExpired += OnCountdownTimerIsExpired; from Unity's OnEnable function for example. For unsubscribing simply call CountdownTimer.OnCountdownTimerHasExpired -= OnCountdownTimerIsExpired;.

You can do this from Unity's OnEnable and OnDisable functions.

Member Function Documentation

◆ CountdownTimerHasExpired()

delegate void CountdownTimerHasExpired ( )

OnCountdownTimerHasExpired delegate.

◆ OnRoomPropertiesUpdate()

override void OnRoomPropertiesUpdate ( Hashtable  propertiesThatChanged)
virtual

Called when a room's custom properties changed. The propertiesThatChanged contains all that was set via Room.SetCustomProperties.

Since v1.25 this method has one parameter: Hashtable propertiesThatChanged.
Changing properties must be done by Room.SetCustomProperties, which causes this callback locally, too.

Parameters
propertiesThatChanged

Reimplemented from MonoBehaviourPunCallbacks.

Event Documentation

◆ OnCountdownTimerHasExpired

CountdownTimerHasExpired OnCountdownTimerHasExpired
static

Called when the timer has expired.