public void Okay() { CardSystem.BoosterPackReader packReader = GameObject.FindObjectOfType <CardSystem.BoosterPackReader>(); GameObject newDeck = new GameObject(); newDeck.transform.name = "DeckTransfer " + thisPlayerIndex.ToString(); newDeck.AddComponent <DeckTransfer>(); List <CardSystem.Card> cards = new List <CardSystem.Card>(); Dictionary <Enums.Element, int> map = new Dictionary <Enums.Element, int>(); for (int i = 0; i < selectedPacks.Count; i++) { cards.AddRange(packReader.BoosterPacks[selectedPacks[i]].GetCards()); Enums.Element key = elementMap[selectedPacks[i]]; if (!map.ContainsKey(key)) { map.Add(key, 1); } else { int value = 0; map.TryGetValue(key, out value); map[key] = value + 1; } } Enums.Element playerType = Enums.Element.None; int max = 0; foreach (KeyValuePair <Enums.Element, int> entry in map) { if (entry.Value > max) { max = entry.Value; playerType = entry.Key; } } CardSystem.Deck deck = new CardSystem.Deck(cards); DeckTransfer t = newDeck.GetComponent <DeckTransfer>(); t.Deck = deck; t.Element = playerType; DontDestroyOnLoad(newDeck); // Load loading screen, correct level should already be stored from Main Menu LoadingScreen.instance.LoadLevel(LoadingScreen.LevelToLoad); }
public void Okay() { CardSystem.BoosterPackReader packReader = GameObject.FindObjectOfType<CardSystem.BoosterPackReader>(); GameObject newDeck = new GameObject(); newDeck.transform.name = "DeckTransfer " + thisPlayerIndex.ToString(); newDeck.AddComponent<DeckTransfer>(); List<CardSystem.Card> cards = new List<CardSystem.Card>(); Dictionary<Enums.Element, int> map = new Dictionary<Enums.Element, int>(); for (int i = 0; i < selectedPacks.Count; i++) { cards.AddRange(packReader.BoosterPacks[selectedPacks[i]].GetCards()); Enums.Element key = elementMap[selectedPacks[i]]; if (!map.ContainsKey(key)) map.Add(key, 1); else { int value = 0; map.TryGetValue(key, out value); map[key] = value + 1; } } Enums.Element playerType = Enums.Element.None; int max = 0; foreach (KeyValuePair<Enums.Element, int> entry in map) { if(entry.Value > max) { max = entry.Value; playerType = entry.Key; } } CardSystem.Deck deck = new CardSystem.Deck(cards); DeckTransfer t = newDeck.GetComponent<DeckTransfer>(); t.Deck = deck; t.Element = playerType; DontDestroyOnLoad(newDeck); // Load loading screen, correct level should already be stored from Main Menu LoadingScreen.instance.LoadLevel(LoadingScreen.LevelToLoad); }