/// <summary> /// gets the player's finished turn (from the ROOM properties) /// </summary> /// <returns>The finished turn index</returns> /// <param name="player">Player reference</param> public static int GetFinishedTurn(this PhotonPlayer player) { PUNRoom room = PhotonNetwork.room; if (room == null || room.CustomProperties == null || !room.CustomProperties.ContainsKey(TurnPropKey)) { return(0); } string propKey = FinishedTurnPropKey + player.ID; return((int)room.CustomProperties[propKey]); }
/// <summary> /// Sets the player's finished turn (in the ROOM properties) /// </summary> /// <param name="player">Player Reference</param> /// <param name="turn">Turn Index</param> public static void SetFinishedTurn(this PhotonPlayer player, int turn) { PUNRoom room = PhotonNetwork.room; if (room == null || room.CustomProperties == null) { return; } string propKey = FinishedTurnPropKey + player.ID; Hashtable finishedTurnProp = new Hashtable(); finishedTurnProp[propKey] = turn; room.SetCustomProperties(finishedTurnProp); }
/// <summary> /// Sets the turn. /// </summary> /// <param name="room">Room reference</param> /// <param name="turn">Turn index</param> /// <param name="setStartTime">If set to <c>true</c> set start time.</param> public static void SetTurn(this PUNRoom room, int turn, bool setStartTime = false) { if (room == null || room.CustomProperties == null) { return; } Hashtable turnProps = new Hashtable(); turnProps[TurnPropKey] = turn; if (setStartTime) { turnProps[TurnStartPropKey] = PhotonNetwork.ServerTimestamp; } room.SetCustomProperties(turnProps); }