public void RemoveCard(string cardName) { Debug.Log("Remove card from deck:" + cardName); DeckTableControllerComponent.RemoveCardFromDeck(CardsBaseComponent.GetIdByName(cardName).ToString()); CardsInDeckNames.Remove(cardName); foreach (GameObject findedPanelOb in PanelsInDeckList) { if (findedPanelOb != null) { CardPanel findedPanel = findedPanelOb.GetComponent <CardPanel> (); if (findedPanel != null) { if (findedPanel.PanelCardName == cardName) { findedPanel.CardsNumber--; findedPanel.RefreshCardsNumber(); if (findedPanel.CardsNumber < 1) { findedPanel.DestroyPanel(); PanelsInDeckList.Remove(findedPanelOb); break; } } } else { CardViewPanel panel = findedPanelOb.GetComponent <CardViewPanel> (); if (panel != null) { if (panel.PanelPawn.GetComponent <Pawn> ().Name == cardName) { PanelsInDeckList.Remove(findedPanelOb); //Destroy (findedPanelOb); break; } } } } } }
/*private void SaveDecksListLocal(DeckFromDeckBase[] Decks) { * BinaryFormatter BFormatter = new BinaryFormatter (); * FileStream file = File.Create (Application.persistentDataPath + "/gamedata.dat"); * * DeckData[] DecksData = new DeckData[DecksNumberMax]; * for (int i = 0; i < DecksNumberMax; i++) { * DecksData [i] = new DeckData (); * }; * DecksNumber = 0; * for (int i = 0; i < DecksNumberMax-1; i++) { * if (!(Decks [i].DeckName.Equals ("empty"))) * DecksNumber++; * } * for (int i = 0; i < Decks.Length; i++) { * Debug.Log ("Serialize deck name " + Decks [i].DeckName + " with hero " + Decks [i].HeroName); * DecksData [i].file_version = CurrentFileVersion; * DecksData [i].deck_name = Decks [i].DeckName; * DecksData [i].hero_name = Decks [i].HeroName; * for (int j = 0; j < Deck.deckSize; j++) { * DecksData [i].card_names[j] = Decks [i].CardsNames[j]; * } * DecksData [i].decks_number = DecksNumber; * } * BFormatter.Serialize (file, DecksData); * file.Close (); * }*/ public void SaveDecksList() //to server { DecksNumber = 0; waitForDataScreen(true); DataSaved = true; Debug.Log("Saving decks to server"); for (int i = 0; i < DecksNumberMax - 1; i++) { if (!(MyDecks [i].DeckName.Equals("empty"))) { DecksNumber++; } } for (int i = 0; i < DecksNumber; i++) { if (!MyDecks [i].DeckName.Equals("empty")) { UpdateUserDataRequest request = new UpdateUserDataRequest(); request.Data = new Dictionary <string, string> (); string cardsInDeckName = ""; request.Data.Add("Deck" + i + "Name", MyDecks [i].DeckName); request.Data.Add("Deck" + i + "Hero", MyDecks [i].HeroName); for (int j = 0; j < Deck.deckSize; j++) { int cardID = CardsBaseComponent.GetIdByName(MyDecks [i].CardsNames [j]); if (cardID != -1) { cardsInDeckName += cardID.ToString() + separators [0]; } else { Debug.LogWarning("Cannot find card :" + MyDecks [i].CardsNames [j]); } } request.Data.Add("Deck" + i + "Cards", cardsInDeckName); //Debug.Log ("save deck cards: " + cardsInDeckName); PlayFabClientAPI.UpdateUserData(request, PlayerDataSaved, OnPlayFabError); } } UpdateUserDataRequest req = new UpdateUserDataRequest(); req.Data = new Dictionary <string, string> (); req.Data.Add("DecksNumber", DecksNumber.ToString()); PlayFabClientAPI.UpdateUserData(req, PlayerDataSavedLast, OnPlayFabError); DataSaved = true; }