Facebook
From NoMossStudios, 3 Years ago, written in C#.
Embed
Download Paste or View Raw
Hits: 465
  1.     //This bad boy is responsible for keeping track of book deliveries
  2.     public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
  3.     {
  4.         if (stream.IsWriting)
  5.         {
  6.             //We own this -> send the book order status
  7.             string json = JsonUtility.ToJson(new BookOrders(currentBookOrders));
  8.             stream.SendNext(json);
  9.  
  10.             //Send the game time
  11.             stream.SendNext(remainingLevelTime);
  12.  
  13.             //Send the game gold
  14.             stream.SendNext(remainingLevelGold);
  15.  
  16.             //Send the customer spawn time
  17.             stream.SendNext(customerSpawnTimer);
  18.  
  19.             //Send Pregame timer
  20.             stream.SendNext(preGameCountdownRemainingTime);
  21.  
  22.             //Send customer queue
  23.             string queueJson = JsonUtility.ToJson(queuedCustomers);
  24.             stream.SendNext(queueJson);
  25.         }
  26.         else
  27.         {
  28.             //We are receiving the book status
  29.             string bookStatus = (string)stream.ReceiveNext();
  30.             currentBookOrders = BookOrders.Deserialize(bookStatus);
  31.  
  32.             //Receive game time
  33.             remainingLevelTime = (float)stream.ReceiveNext();
  34.  
  35.             //Receive game gold
  36.             remainingLevelGold = (int)stream.ReceiveNext();
  37.  
  38.             //Receive customer spawn time
  39.             customerSpawnTimer = (float)stream.ReceiveNext();
  40.  
  41.             //Receive pre-game timer
  42.             preGameCountdownRemainingTime = (float)stream.ReceiveNext();
  43.  
  44.             //Receive our customer queue
  45.             string queueJson = (string)stream.ReceiveNext();
  46.             queuedCustomers = JsonUtility.FromJson<QueuedCustomers>(queueJson);
  47.         }
  48.  
  49.         UpdateGameTime(remainingLevelTime);
  50.         UpdateGameGold(remainingLevelGold);
  51.         UpdatePreGameTime(preGameCountdownRemainingTime);
  52.     }