Exemplo n.º 1
0
    private int CurrentDeckMenu_GetNextDeckId()
    {
        XDocument doc = XDocument.Load(GamesManager.GetApplicationPath() + "/Configuration/Configuration.xml");
        int       id  = int.Parse(doc.XPathSelectElement("root/DeckID").Value);           //nadi id

        doc.XPathSelectElement("root/DeckID").SetValue(id + 1);                           //povecaj ga za jedan

        doc.Save(GamesManager.GetApplicationPath() + "/Configuration/Configuration.xml"); //spremi novi id
        return(id);                                                                       //vrati id
    }
Exemplo n.º 2
0
    private void CurrentDeckMenu_CreateDeckConfigDat()
    {
        XDocument doc = new XDocument(
            new XElement("root",
                         new XElement("DeckID", 0)
                         )
            );

        Directory.CreateDirectory(GamesManager.GetApplicationPath() + "/Configuration");
        string configPath = GamesManager.GetApplicationPath() + "/Configuration/Configuration.xml";

        File.WriteAllText(configPath, doc.ToString());
    }
Exemplo n.º 3
0
    private void CurrentDeckMenu_SaveDeckToXml(string deckName)
    {
        int deckId = CurrentDeckMenu_GetNextDeckId();

        XElement deck = new XElement("Deck");

        deck.SetAttributeValue("deckName", deckName);
        deck.SetAttributeValue("deckID", deckId);

        foreach (Card card in Deck.Cards)
        {
            XElement cardId = new XElement("Card", card.StaticIdCard);
            cardId.SetAttributeValue("name", card.Name);
            deck.Add(cardId);
        }

        XDocument doc  = new XDocument(deck);
        string    path = GamesManager.GetApplicationPath() + "/Decks/" + deckName + ".xml";

        File.WriteAllText(path, doc.ToString());
    }
Exemplo n.º 4
0
    //--- CURRENT DECK MENU ---
    public void CurrentDeckMenu_SaveAndUseBtn()
    {
        string deckName = currentDeckName.text;

        if (CurrentDeckMenu_CheckDeckName(deckName))
        {
            StartCoroutine(CurrentDeckMenu_ShowError("Deck name cannot contain '.'"));
            return;
        }
        if (!Directory.Exists(GamesManager.GetApplicationPath() + "/Decks"))
        {
            CurrentDeckMenu_CreateSaveDirectory();
            CurrentDeckMenu_CreateDeckConfigDat();
        }

        Deck.DeckType         = Enumerations.DeckEnums.Saved;
        Deck.DeckName         = deckName;
        mainMenuDeckType.text = Deck.DeckName;
        CurrentDeckMenu_SaveDeckToXml(deckName);

        LoadMenu(MainMenu);
    }
Exemplo n.º 5
0
 private string[] SavedDeckMenu_GetAllSavedDecks()
 {
     return(Directory.GetFiles(GamesManager.GetApplicationPath() + "/Decks/"));
 }
Exemplo n.º 6
0
 private void CurrentDeckMenu_CreateSaveDirectory()
 {
     Directory.CreateDirectory(GamesManager.GetApplicationPath() + "/Decks");
 }