public static async Task LoadSpellCardsFromFolder(List <SpellCard> spellCardList, StorageFolder parentFolder) { foreach (var item in await parentFolder.GetFilesAsync()) { if ((item as StorageFile).FileType == ".txt" && (item as StorageFile).Name != "List.txt") { SpellCard newSpellCard = await LoadSpellCardFromFile(item as StorageFile); spellCardList.Add(newSpellCard); } } }
private static int _SortCardListByCost(SpellCard a, SpellCard b) { if (a.Cost > b.Cost) { return(1); } if (a.Cost < b.Cost) { return(-1); } return(0); }
}//将随从牌添加至GridView控件(中等) public static void AddCardToGridView_Middle(GridView gridView, SpellCard addSpellCard) { Grid cardPanel = new Grid() { Name = addSpellCard.Name, Height = 235, Width = 150, Margin = new Thickness(5, 5, 0, 0), DataContext = addSpellCard, IsRightTapEnabled = true, }; Image cardImage = new Image() { Source = new BitmapImage(new Uri(addSpellCard.ImagePath)), VerticalAlignment = VerticalAlignment.Top }; TextBlock cardCost = new TextBlock() { Text = addSpellCard.Cost.ToString(), Foreground = new SolidColorBrush(Colors.Blue), FontSize = 24, Margin = new Thickness(0, 152, 0, 0), HorizontalAlignment = HorizontalAlignment.Center }; TextBlock cardName = new TextBlock() { Text = addSpellCard.Name, Foreground = new SolidColorBrush(Colors.White), FontSize = 26, Margin = new Thickness(0, 176, 0, 0), HorizontalAlignment = HorizontalAlignment.Center }; if (cardName.Text.Length > 8) { cardName.FontSize = 22; cardName.Margin = new Thickness(0, 180, 0, 0); } if (cardName.Text.Length > 14) { cardName.FontSize = 18; cardName.Margin = new Thickness(0, 184, 0, 0); } cardPanel.Children.Add(cardImage); cardPanel.Children.Add(cardCost); cardPanel.Children.Add(cardName); gridView.Items.Add(cardPanel); }//将法术牌添加至GridView控件(中等)
}//将随从牌添加至ListView控件 public static void AddCardToListView(ListView listView, SpellCard addSpellCard) { Grid cardPanel = new Grid() { Name = addSpellCard.Name, Height = 50, Width = 190, Margin = new Thickness(5, 5, 0, 0), DataContext = addSpellCard, IsRightTapEnabled = true, }; Image cardImage = new Image() { Source = new BitmapImage(new Uri(addSpellCard.ImagePath)), VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Left }; TextBlock cardCost = new TextBlock() { Text = addSpellCard.Cost.ToString(), Foreground = new SolidColorBrush(Colors.Blue), FontSize = 20, Margin = new Thickness(5, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Right }; TextBlock cardName = new TextBlock() { Text = addSpellCard.Name, Foreground = new SolidColorBrush(Colors.White), FontSize = 20, Margin = new Thickness(15, 0, 0, 0), VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; if (cardName.Text.Length > 8) { cardName.FontSize = 16; } cardPanel.Children.Add(cardImage); cardPanel.Children.Add(cardCost); cardPanel.Children.Add(cardName); listView.Items.Add(cardPanel); }//将随从牌添加至ListView控件
public static async void SaveSpellCardToFile(SpellCard spellCard, StorageFile item) { using (Stream fileStream = await item.OpenStreamForWriteAsync()) { using (StreamWriter write = new StreamWriter(fileStream)) { write.WriteLine(spellCard.Cost); write.WriteLine(spellCard.Name); write.WriteLine(spellCard.Description); Effect aimEffect = spellCard.SpellEffect; switch (aimEffect.Category) { case EffectCategory.Spell: { write.WriteLine("#SpellEffect"); break; } } if (aimEffect.EffectAim.playerMinion) { write.Write('1'); } else { write.Write('0'); } if (aimEffect.EffectAim.enemyMinion) { write.Write('1'); } else { write.Write('0'); } if (aimEffect.EffectAim.playerHero) { write.Write('1'); } else { write.Write('0'); } if (aimEffect.EffectAim.enemyHero) { write.Write('1'); } else { write.Write('0'); } write.WriteLine(""); for (int j = 0; j < aimEffect.Requirements.Count; j++) { write.WriteLine("*Requirement"); write.WriteLine(aimEffect.Requirements[j]); write.WriteLine(aimEffect.RequirementValues[j]); } for (int j = 0; j < aimEffect.Results.Count; j++) { write.WriteLine("*Result"); write.WriteLine(aimEffect.Results[j]); write.WriteLine(aimEffect.ResultValues[j]); } for (int j = 0; j < aimEffect.AimRequirements.Count; j++) { write.WriteLine("*AimRequirement"); write.WriteLine(aimEffect.AimRequirements[j]); write.WriteLine(aimEffect.AimRequirementValues[j]); } write.WriteLine("#End"); } } }
public static async Task <SpellCard> LoadSpellCardFromFile(StorageFile item) { int cost; string name, description; bool a, b, c, d; string p, q; using (Stream fileStream = await item.OpenStreamForReadAsync()) { using (StreamReader read = new StreamReader(fileStream)) { cost = int.Parse(read.ReadLine()); name = read.ReadLine(); description = read.ReadLine(); SpellCard tmpSpellCard = new SpellCard(cost, name, description); while (true) { p = read.ReadLine(); if (p == "#End" || p == null) { break; } switch (p) { case "#SpellEffect": { q = read.ReadLine(); if (q[0] == '1') { a = true; } else { a = false; } if (q[1] == '1') { b = true; } else { b = false; } if (q[2] == '1') { c = true; } else { c = false; } if (q[3] == '1') { d = true; } else { d = false; } tmpSpellCard.SetEffect(new Effect("Spell", a, b, c, d)); break; } case "*Requirement": { q = read.ReadLine(); tmpSpellCard.SpellEffect.AddRequirement(q); q = read.ReadLine(); tmpSpellCard.SpellEffect.AddRequirementValue(q); break; } case "*Result": { q = read.ReadLine(); tmpSpellCard.SpellEffect.AddResult(q); q = read.ReadLine(); tmpSpellCard.SpellEffect.AddResultValue(q); break; } case "*AimRequirement": { q = read.ReadLine(); tmpSpellCard.SpellEffect.AddAimRequirement(q); q = read.ReadLine(); tmpSpellCard.SpellEffect.AddAimRequirementValue(q); break; } } } return(tmpSpellCard); } } }
public static void ShuffleIntoDeck(SpellCard card, PlayerData player) { player.CurrentDeck.SpellCard.Add(card); }