// Load the cards that are saved in PlayerPrefs and link them to the cards available // This is caused for the CardField to organize flow public void LoadCards() { int[] CardsIndex = PlayerPrefsManager.ReturnDeckIndex(); string[] CardsType = PlayerPrefsManager.ReturnDeckType(); CardSummon[] summonCardsOut = FindObjectsOfType <CardSummon>(); CardSpell[] spellCardsOut = FindObjectsOfType <CardSpell>(); cardLUT = FindObjectOfType <CardLUT>(); totalPowerCount = FindObjectOfType <TotalPowerCount>(); if (CardsIndex.Length == 20) { for (int i = 0; i < CardsIndex.Length; i++) { GameObject CardFound = null; if (CardsType[i] == "CardSummon") { GameObject card = cardLUT.SummonCards[CardsIndex[i]]; foreach (CardSummon summonCardOut in summonCardsOut) { if (summonCardOut.cardSummonName == card.GetComponent <CardSummon>().cardSummonName) { Debug.Log(summonCardOut); CardFound = summonCardOut.gameObject; } } } else if (CardsType[i] == "CardSpell") { GameObject card = cardLUT.SpellCards[CardsIndex[i]]; foreach (CardSpell spellCardOut in spellCardsOut) { if (spellCardOut.cardSpellName == card.GetComponent <CardSpell>().cardSpellName) { Debug.Log(spellCardOut); CardFound = spellCardOut.gameObject; } } } else { Debug.LogError("Card Stored neither Summon nor spell"); } Debug.Log(CardsType[i]); Debug.Log(CardsIndex[i]); Debug.Log(CardFound); AddCard(CardFound.GetComponent <Card>()); } } else { foreach (CardPosition CP in CardPositionArray) { CP.GetComponent <Text>().text = ""; } } }
private void OnEnable() { SummonCards_Prop = serializedObject.FindProperty("SummonCards"); SummonCardsActive_Prop = serializedObject.FindProperty("SummonCardsActive"); SpellCards_Prop = serializedObject.FindProperty("SpellCards"); SpellCardsActive_Prop = serializedObject.FindProperty("SpellCardsActive"); SummonsVisible = new List <bool>(); SpellsVisible = new List <bool>(); cardLUT = (CardLUT)target; }
List <Card> CheckSavedCards() { List <Card> cards = new List <Card>(); int[] CardsIndex = PlayerPrefsManager.ReturnDeckIndex(); string[] CardsType = PlayerPrefsManager.ReturnDeckType(); CardLUT cardLUT = FindObjectOfType <CardLUT>(); if (CardsIndex.Length == 20) { for (int i = 0; i < CardsIndex.Length; i++) { GameObject CardFound = null; if (CardsType[i] == "CardSummon") { GameObject card = cardLUT.SummonCards[CardsIndex[i]]; Debug.Log(card.GetComponent <CardSummon>().cardSummonName); foreach (CardSummon summonCardOut in summonCardsOut) { Debug.Log(summonCardOut.cardSummonName); if (summonCardOut.cardSummonName == card.GetComponent <CardSummon>().cardSummonName) { CardFound = summonCardOut.gameObject; } } } else if (CardsType[i] == "CardSpell") { GameObject card = cardLUT.SpellCards[CardsIndex[i]]; foreach (CardSpell spellCardOut in spellCardsOut) { if (spellCardOut.cardSpellName == card.GetComponent <CardSpell>().cardSpellName) { Debug.Log(spellCardOut); CardFound = spellCardOut.gameObject; } } } else { Debug.LogError("Card Stored neither Summon nor spell"); } Debug.Log(CardsIndex[i]); Debug.Log(CardFound); cards.Add(CardFound.GetComponent <Card>()); } } return(cards); }
// 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(); }
void Awake() { CardsInDeck.Clear(); int[] CardsIndex = PlayerPrefsManager.ReturnDeckIndex(); string[] CardsType = PlayerPrefsManager.ReturnDeckType(); cardLUT = FindObjectOfType <CardLUT>(); for (int i = 0; i < CardsIndex.Length; i++) { if (CardsType[i] == "CardSummon") { int CardIndex = CardsIndex[i]; AddCardtoDeck(cardLUT.SummonCards[CardIndex]); } else if (CardsType[i] == "CardSpell") { int CardIndex = CardsIndex[i]; AddCardtoDeck(cardLUT.SpellCards[CardIndex]); } else { Debug.LogError("Card Stored neither Summon nor spell"); } } }