//index = valeur contenue dans le curent_tab selectionné public void Add_Card(int index) { if (count >= 45) { return; } Data_Card current = Data_All.data_tab[index]; if (current.Rarity == (int)Rarity.Infinite) { if (count_infinite < 5) { count_infinite++; } else { return; } } foreach (KeyValuePair <int, int> card in Deck_cards) { if (card.Key == index) { if (current.Rarity == (int)Rarity.Infinite) { count_infinite--; return; } if (current.Rarity == (int)Rarity.Krosmique) { return; } if (card.Value < 3) { Deck_cards[index] += 1; count++; } return; } if (current.Rarity == (int)Rarity.Infinite && Data_All.data_tab[card.Key].Rarity == (int)Rarity.Infinite) { string current_name = current.Name.Split('_')[0]; if (Data_All.data_tab[card.Key].Name.Contains(current_name) == true) { count_infinite--; return; } } } Deck_cards.Add(index, 1); count++; }
public void Delete_Card(int index) { Data_Card current = Data_All.data_tab[index]; if (current.Rarity == (int)Rarity.Infinite) { count_infinite--; } Deck_cards[index] = Deck_cards[index] - 1; if (Deck_cards[index] == 0) { Deck_cards.Remove(index); } count--; }
public void Init_data() { data_tab = new Data_Card[SIZE_TAB]; TextAsset[] files = Resources.LoadAll <TextAsset>("data"); int i = 0; foreach (TextAsset card in files) { string str = card.text; var N = JSON.Parse(str); Data_Card data = new Data_Card(); data.Id = N["Id"].AsInt; data.Name = N["Name"].Value; data.CardType = N["CardType"].Value; data.CostAP = N["CostAP"].AsInt; data.Life = N["Life"].AsInt; data.Attack = N["Attack"].AsInt; data.MovementPoint = N["MovementPoint"].AsInt; //data.Families = N["Families"] data.IsToken = N["IsToken"].AsBool; data.Rarity = N["Rarity"].AsInt; data.GodType = N["GodType"].AsInt; data.Extension = N["Extension"].AsInt; data.Texts = new Texts(); var T = JSON.Parse(N["Texts"].ToString()); data.Texts.NameFR = T["NameFR"].ToString(); data.Texts.NameFR = data.Texts.NameFR.Remove(0, 1); data.Texts.NameFR = data.Texts.NameFR.Remove(data.Texts.NameFR.Length - 1); data.Texts.DescFR = T["DescFR"].ToString(); if (data.Texts.DescFR.Length > 2) { data.Texts.DescFR = data.Texts.DescFR.Remove(0, 1); data.Texts.DescFR = data.Texts.DescFR.Remove(data.Texts.DescFR.Length - 1); } data_tab[i] = data; i++; } }