public void SaveDeck()
 {
     deckHolder.Cards = CardsInDeck.ToArray();
     DeckHolder.SaveDeck(deckHolder, deckNameInputField.text);
     LoadAllDecks();
     LoadPage();
 }
예제 #2
0
    private void OnEnable()
    {
        DeckManager = GameObject.FindGameObjectWithTag("DeckManager");

        //gets the array of decks
        var savedDecksScriptArray = DeckManager.GetComponent <SavedDecks>().decks;

        //have the name and contents of the deck updated each time loaded
        currentDeckNumber = SavedDecks.Instance.DeckNumber;
        var currentDeck = savedDecksScriptArray[currentDeckNumber - 1];

        defaultNameText.text = currentDeck.name;

        for (int i = 0; i < currentDeck.cards.Count; i++)
        {
            //deckContentArea.transform.GetChild(i).GetComponent<DeckCardDisplay>().card = currentDeck.cards[i];

            if (currentDeck.cards[i])
            {
                draggedCardToDeck = Instantiate(deckCard);
                draggedCardToDeck.transform.SetParent(deckContentArea.transform, true);
                draggedCardToDeck.transform.localScale = deckContentArea.transform.localScale;
                draggedCardToDeck.GetComponent <DeckCardDisplay>().card = currentDeck.cards[i];
            }
        }
        DeckHolder deckHolderScript = deckBuilderManager.GetComponent <DeckHolder>();

        deckHolderScript.cardAmount = deckContentArea.transform.childCount;
        deckCardAmount.text         = deckContentArea.transform.childCount + "/30";
    }
 public static void SaveDeck(DeckHolder deck, string name)
 {
     Directory.CreateDirectory(DeckPath);
     using (Stream stream = File.Open(Path.Combine(DeckPath, name + ".dat"), FileMode.OpenOrCreate)) {
         BinaryFormatter bf = new BinaryFormatter();
         bf.Serialize(stream, deck);
     }
 }
    private void Start()
    {
        levelmanager   = FindObjectOfType <LevelManager>();
        deckHolder     = FindObjectOfType <DeckHolder>();
        questionScreen = FindObjectOfType <QuestionScreen>();
        questionScreen.gameObject.SetActive(false);

        // TO DO may need to organize when to grab these cards in case they are disabled before reaching them
    }
 public void NewDeck()
 {
     CardsInDeck.Clear();
     deckHolder = new DeckHolder(new string[] { });
     deckNameInputField.text = "Untitled";
     ClearDeckHolderPanel();
     LoadPage();
     SetViewDeck();
 }
예제 #6
0
 void Awake()
 {
     // Check if there's a Deck Holder object in this scene, if so load the cards from that list into the players deck
     instance = GameManager.FindObjectOfType <DeckHolder>();
     if (instance != null)
     {
         // Set the cards to the deck
         cards = instance.myDeck;
     }
     // If not, don't load anything, it'll take in the premade list I made in the scene just in case a bug happens / for the AI.
 }
예제 #7
0
    private DeckHolder instance;     // the instance of deck holder


    public void Start()
    {
        pageNumber    = 1;                                                // make sure page starts off at 1
        maxPageNumber = (cardTemplates.Length / displaySlots.Length) + 1; // Finding out how many pages are needed to display all the cards. | Add one for safety.

        pageDisplay.text = (pageNumber + "/" + maxPageNumber);            // display this

        DisplayNewCards(pageNumber);

        instance = GameObject.FindObjectOfType <DeckHolder>();        // assign deck holder to instance
    }
    public static DeckHolder LoadDeck(string name)
    {
        Directory.CreateDirectory(DeckPath);
        DeckHolder deck = null;

        using (Stream stream = File.Open(Path.Combine(DeckPath, name + ".dat"), FileMode.Open)) {
            BinaryFormatter bf = new BinaryFormatter();
            deck = (DeckHolder)bf.Deserialize(stream);
        }
        return(deck);
    }
    private void LoadDeckHolder(string deckName)
    {
        deckHolder = null;
        Button deck = Instantiate(deckHolderPrefab, DeckHolderPanel);

        deck.GetComponentsInChildren <Button>()[1].onClick.AddListener(() => {
            DeleteDeck(deckName);
            Destroy(deck.gameObject);
        });
        deck.GetComponentInChildren <Text>().text = deckName;
        deck.onClick.AddListener(() => LoadDeck(deckName));
    }
예제 #10
0
    private static DeckHolder Instance;    // instance of this script


    void Awake()
    {
        if (Instance != null)
        {
            GameObject.Destroy(this);
        }
        else
        {
            Instance = this;
            DontDestroyOnLoad(this);
        }
    }
 public void LoadDeck(string deckName)
 {
     ClearDeckHolderPanel();
     deckHolder = DeckHolder.LoadDeck(deckName);
     deckNameInputField.text = deckName;
     CardsInDeck.Clear();
     CardsInDeck.AddRange(deckHolder.Cards);
     for (int i = 0; i < deckHolder.Cards.Length; i++)
     {
         Card       card       = (Card)Activator.CreateInstance(Type.GetType("DuelMasters.Cards." + deckHolder.Cards[i]), fakeGame.CurrentDuelistTurn);
         GameObject cardInDeck = Instantiate(cardInDeckPrefab, DeckHolderPanel);
         cardInDeck.GetComponentsInChildren <Image>()[1].sprite = Resources.Load <Sprite>("Cards/Artwork/" + card.OriginalName);
         cardInDeck.GetComponentInChildren <Text>().text        = card.OriginalName;
         DeckRemoveableCard removeableCard = cardInDeck.AddComponent <DeckRemoveableCard>();
         removeableCard.Collection = this;
         removeableCard.Name       = card.GetType().Name;
     }
     LoadPage();
     SetViewDeck();
 }
 private void CmdSetReady(bool value, string[] cards)
 {
     DeckHolder = new DeckHolder(cards);
     ready      = value;
     if (ready)
     {
         DMNetworkManager dm = (DMNetworkManager)NetworkManager.singleton;
         if (dm.numPlayers > 1)
         {
             foreach (Player player in dm.AllPlayers)
             {
                 if (!player.ready)
                 {
                     return;
                 }
             }
             dm.ServerChangeScene("Game");
         }
     }
 }
예제 #13
0
    // Place Objects from LUT on Screen in correct positions
    void Awake()
    {
        cardLut          = FindObjectOfType <CardLUT>();
        deckHolder       = FindObjectOfType <DeckHolder>();
        deckBuildManager = FindObjectOfType <DeckBuildManager>();

        int summonIndex = 0;

        for (int i = 0; i < CardSummonPositions.Length; i++)
        {
            if (cardLut.SummonCardsActive[i] && cardLut.SummonCards.Length > i)
            {
                GameObject card = Instantiate(cardLut.SummonCards[i], CardSummonPositions[summonIndex].transform.position, Quaternion.identity);
                card.transform.SetParent(CardSummonPositions[summonIndex].transform);
                card.GetComponent <DeckBuildInterface>().SetUpCard();
                card.name = cardLut.SummonCards[i].name;
                summonIndex++;
            }
        }

        int spellIndex = 0;

        for (int i = 0; i < CardSpellPositions.Length; i++)
        {
            if (cardLut.SpellCardsActive[i] && cardLut.SpellCards.Length > i)
            {
                GameObject card = Instantiate(cardLut.SpellCards[i], CardSpellPositions[spellIndex].transform.position, Quaternion.identity);
                card.transform.SetParent(CardSpellPositions[spellIndex].transform);
                card.GetComponent <DeckBuildInterface>().SetUpCard();
                card.name = cardLut.SpellCards[i].name;
                spellIndex++;
            }
        }

        deckHolder.LoadCards();
        deckBuildManager.LoadCards();
    }
예제 #14
0
 void Start()
 {
     deckHolder = FindObjectOfType <DeckHolder>();
 }
 public void DeleteDeck(string deckName)
 {
     DeckHolder.DeleteDeck(deckName);
 }
예제 #16
0
    // Update is called once per frame
    void AddCard()
    {
        DeckHolder DH = FindObjectOfType <DeckHolder>();

        DH.AddCard(GetComponentInParent <Card>());
    }