/// <summary> /// Downloads the pets identifier. /// </summary> /// <returns>The pets identifier.</returns> /// <param name="user">User.</param> public static ServerPacketDownloadPetsID DownloadPetsID(PLFUser user) { //get user id int userID = user.ID; //create new client packet download pets id ClientPacketDownloadPetsID clientPacketDownloadPetsID = new ClientPacketDownloadPetsID(userID); //send packet to the server ServerPacketDownloadPetsID serverPacketDownloadPetsID = TCPClient.SendPacket(clientPacketDownloadPetsID) as ServerPacketDownloadPetsID; //if null answer, return vanilla packet if (serverPacketDownloadPetsID == null) { return(new ServerPacketDownloadPetsID(new int[0], new int[0])); } //return packet return(serverPacketDownloadPetsID); }
/// <summary> /// Loads the user pet list. /// </summary> /// <param name="user">User.</param> public void LoadUserPetList(PLFUser user) { //clear actual petlist userPets.Clear(); //send download pets id packet ServerPacketDownloadPetsID serverPacketDownloadPetsID = ServerHelper.DownloadPetsID(user); userPetsID = serverPacketDownloadPetsID.IdList; //foreach user own pets id foreach (var id in userPetsID) { //download pet infos from server PLFPet pet = ServerHelper.DownloadPet(id).Pet; //if pet isn't null if (pet != null) { userPets.Add(pet); } } //get shared pets id int[] sharePetsId = serverPacketDownloadPetsID.SharedIdList; //foreach user share pets id foreach (var id in sharePetsId) { //download shared pet infos from server PLFPet pet = ServerHelper.DownloadPet(id, true).Pet; //if pet isn't null if (pet != null) { userPets.Add(pet); } } }