public static void ProcessGameStateResponse(ResponseEvent response) { if (response.action == null) { return; } if (response.action.ToLower().Trim().Equals("update")) { GameStateManager.ProcessMyGameStateResponse(response.data); } else if (response.action.ToLower().Trim().Equals("otherusers")) { GameStateManager.ProcessOtherUsersGameStateResponse(response.data); } else if (response.action.ToLower().Trim().Equals("syncerror")) { UserDataManager.ProcessSyncError(); } else if (response.action.ToLower().Trim().Equals("dropped")) { UserDataManager.ProcessDroppedResponse("Event dropped!"); } else if (response.action.ToLower().Trim().Equals("lockerror")) { UserDataManager.ProcessLockError(); } }
public static void ProcessPlayerDataResponse(ResponseEvent response) { WalletData receivedWallet = null; InventoryData receivedInventory = null; if (response.data.HasField("wallet")) { JSONObject walletJSON = response.data.GetField("wallet"); receivedWallet = new WalletData(); if (walletJSON.HasField("currencies")) { receivedWallet.currencies = new List <PlayerCurrencyData>(); JSONObject currenciesJSON = walletJSON.GetField("currencies"); for (int i = 0; i < currenciesJSON.Count; i++) { PlayerCurrencyData currency = new PlayerCurrencyData(); currency.id = (int)currenciesJSON.list[i].GetField("id").n; currency.currentBalance = (int)currenciesJSON.list[i].GetField("currentBalance").n; currency.delta = (int)currenciesJSON.list[i].GetField("delta").n; receivedWallet.currencies.Add(currency); } } receivedWallet.offset = (long)walletJSON.GetField("offset").n; receivedWallet.logic = walletJSON.GetField("logic").str; } if (response.data.HasField("inventory")) { JSONObject inventoryJSON = response.data.GetField("inventory"); receivedInventory = new InventoryData(); if (inventoryJSON.HasField("items")) { receivedInventory.items = new List <PlayerItemData>(); JSONObject itemsJSON = inventoryJSON.GetField("items"); for (int i = 0; i < itemsJSON.Count; i++) { PlayerItemData item = new PlayerItemData(); item.id = (int)itemsJSON.list[i].GetField("id").n; item.amount = (int)itemsJSON.list[i].GetField("amount").n; item.delta = (int)itemsJSON.list[i].GetField("delta").n; receivedInventory.items.Add(item); } } receivedInventory.offset = (long)inventoryJSON.GetField("offset").n; receivedInventory.logic = inventoryJSON.GetField("logic").str; } if (response.action.ToLower().Trim().Equals("update")) { SpilUnityEditorImplementation.pData.CalculatePlayerDataResponse(receivedWallet, receivedInventory, false); } else if (response.action.ToLower().Trim().Equals("syncerror")) { UserDataManager.ProcessSyncError(); } else if (response.action.ToLower().Trim().Equals("dropped")) { UserDataManager.ProcessDroppedResponse("Event dropped!"); } else if (response.action.ToLower().Trim().Equals("lockerror")) { UserDataManager.ProcessLockError(); } }