public static void DeserialisePokemonData(object data, ushort senderID, Trainer trainer) { if (data is DarkRiftReader) { using (DarkRiftReader reader = (DarkRiftReader)data) { string[] strings = reader.ReadStrings(); int[] ints = reader.ReadInt32s(); PokemonData pokemonData = new PokemonData(strings[0], strings[1], strings[2], ints[0], ints[1], ints[2], ints[3], ints[4], ints[5], ints[6], ints[7], ints[8], ints[9], ints[10], ints[11], ints[12], ints[13], ints[14], ints[15], ints[16], ints[17], ints[18], ints[19], ints[20], ints[21], ints[22], ints[23], ints[24], ints[25], ints[26], ints[27], ints[28], ints[29], ints[30], ints[31], ints[32], reader.ReadBoolean()); double[] doubles = reader.ReadDoubles(); GameObject clone = Object.Instantiate(Resources.Load("Prefabs/Pokemon/" + pokemonData.pokemonName), new Vector3((float)doubles[0], (float)doubles[1], (float)doubles[2]), Quaternion.identity) as GameObject; PokemonComponents components = clone.GetComponent <PokemonComponents>(); components.pokemon.trainerName = strings[3]; components.pokemon.networkID = senderID; components.pokemon.nickname = pokemonData.nickname; components.pokemon.fromTrade = pokemonData.fromTrade; components.pokemon.level = pokemonData.level; components.pokemon.gender = (Genders)pokemonData.gender; components.pokemon.nature = (Natures)pokemonData.nature; components.hpPP.curMaxHP = pokemonData.curMaxHP; components.hpPP.curMaxPP = pokemonData.curMaxPP; components.stats.curMaxATK = pokemonData.curMaxATK; components.stats.curMaxDEF = pokemonData.curMaxDEF; components.stats.curMaxSPATK = pokemonData.curMaxSPATK; components.stats.curMaxSPDEF = pokemonData.curMaxSPDEF; components.stats.curMaxSPD = pokemonData.curMaxSPD; components.hpPP.curHP = pokemonData.curHP; components.hpPP.curPP = pokemonData.curPP; components.stats.curATK = pokemonData.curATK; components.stats.curDEF = pokemonData.curDEF; components.stats.curSPATK = pokemonData.curSPATK; components.stats.curSPDEF = pokemonData.curSPDEF; components.stats.curSPD = pokemonData.curSPD; components.hpPP.hpEV = pokemonData.hpEV; components.hpPP.ppEV = pokemonData.ppEV; components.stats.atkEV = pokemonData.atkEV; components.stats.defEV = pokemonData.defEV; components.stats.spatkEV = pokemonData.spatkEV; components.stats.spdefEV = pokemonData.spdefEV; components.stats.spdEV = pokemonData.spdEV; components.hpPP.hpIV = pokemonData.hpIV; components.hpPP.ppIV = pokemonData.ppIV; components.stats.atkIV = pokemonData.atkIV; components.stats.defIV = pokemonData.defIV; components.stats.spatkIV = pokemonData.spatkIV; components.stats.spdefIV = pokemonData.spdefIV; components.stats.spdIV = pokemonData.spdIV; components.pokemon.curEXP = pokemonData.curEXP; components.pokemon.equippedItem = pokemonData.equippedItem; components.pokemon.id = pokemonData.id; trainer.AssignPokemon(components.pokemon); components.pokemon.SetupExistingPokemon(); } } else { Debug.LogError("Should have recieved a DarkRiftReciever but didn't! (Got: " + data.GetType() + ")"); } }