public void BeginMuligan(int numberOfCards) { gameManager = GameObject.Find("GameManager").GetComponent <GameManager>(); decks = gameManager.Decks; json = GameObject.Find("GameManager").GetComponent <ParseFromJSON>(); numCards = numberOfCards; for (int i = 0; i < numberOfCards; i++) { int whatCard = Random.Range(0, decks[0].Count); c = json.loadFile(decks[0][whatCard]); if (c.card_type.ToLower() == "spell") { mulCards.Add(Instantiate(spellCard, transform, false) as GameObject); mulCards[i].transform.GetChild(0).GetComponent <SpellCardGenerator>().GenerateCard(c); } else { mulCards.Add(Instantiate(creatureCard, transform, false) as GameObject); mulCards[i].transform.GetChild(0).GetComponent <CardGenerator>().GenerateCard(c); } muliganSelectors[i] = Instantiate(muliganSelctor, mulCards[i].transform, false); muliganSelectors[i].transform.localPosition = new Vector3(0, 0, 0); muliganSelectors[i].GetComponent <MuliganSelector>().id = i; mulCards[i].GetComponent <Draggable>().enabled = false; decks[0].RemoveAt(whatCard); } AiMul(); }
public void CardDraw(int playerIndex) { if (gameManager.Decks[playerIndex].Count > 0) { json = GameObject.Find("GameManager").GetComponent <ParseFromJSON>(); int whatCard = Random.Range(0, gameManager.Decks[playerIndex].Count); c = json.loadFile(gameManager.Decks[playerIndex][whatCard]); GameObject g; //if (c.card_type.ToLower() == "spell") //{ // g = (Instantiate(spellCard, playerHands[playerIndex].transform, false) as GameObject); // g.transform.GetChild(0).GetComponent<SpellCardGenerator>().GenerateCard(c); //} //else { g = (Instantiate(creatureCard, playerHands[playerIndex].transform, false) as GameObject); g.transform.GetChild(0).GetComponent <CardGenerator>().GenerateCard(c); } if (playerIndex == 1) { g.BroadcastMessage("DisableTexts"); g.transform.GetChild(0).GetComponent <CardClass>().OwnerId = 1; g.transform.GetComponent <Draggable>().enabled = false; } gameManager.Decks[playerIndex].RemoveAt(whatCard); } else { OverDraw(playerIndex); } }
void AiMul() { for (int i = 0; i < 3 + (4 - numCards); i++) { int whatAiCard = Random.Range(0, decks[1].Count); c = json.loadFile(decks[1][whatAiCard]); aiCards.Add(c); print(c.card_name); decks[1].RemoveAt(whatAiCard); } foreach (CARDS card in aiCards) { if (card.mana > 4) { aiMul.Add(card); } } if (aiMul.Count > 0) { foreach (CARDS mul in aiMul) { decks[1].Add(mul.card_id); aiCards.Remove(mul); } foreach (CARDS mul in aiMul) { int whatAiCard = Random.Range(0, decks[1].Count); aiCards.Add(json.loadFile(decks[1][whatAiCard])); decks[1].RemoveAt(whatAiCard); } } }