當前位置: 首頁>>代碼示例>>C#>>正文


C# CardCollection.TrashedBy方法代碼示例

本文整理匯總了C#中CardCollection.TrashedBy方法的典型用法代碼示例。如果您正苦於以下問題:C# CardCollection.TrashedBy方法的具體用法?C# CardCollection.TrashedBy怎麽用?C# CardCollection.TrashedBy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CardCollection的用法示例。


在下文中一共展示了CardCollection.TrashedBy方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Trash

		internal void Trash(DeckLocation location, CardCollection cards)
		{
			if (cards.Count == 0)
				return;

			TrashEventArgs tea = null;

			if (Trashing != null)
			{
				do
				{
					tea = new TrashEventArgs(this, cards);
					Trashing(this, tea);

					Boolean isAnyRequired = false;
					List<String> options = new List<String>();
					IEnumerable<Type> cardTypes = tea.Actions.Keys;
					foreach (Type key in cardTypes)
					{
						options.Add(tea.Actions[key].Text);
						isAnyRequired |= tea.Actions[key].IsRequired;
					}

					if (options.Count > 0)
					{
						options.Sort();
						Choice choice = new Choice(String.Format("You are trashing {0} cards", cards.Count), null, cards, options, this, tea, false, isAnyRequired ? 1 : 0, 1);
						ChoiceResult result = this.MakeChoice(choice);

						if (result.Options.Count > 0)
							tea.Actions.First(kvp => kvp.Value.Text == result.Options[0]).Value.Method(this, ref tea);
					}
				} while (Trashing != null && tea.HandledBy.Count > 0);
			}

			this.MoveToTrashStart(location, cards);
			if (CurrentTurn != null)
				CurrentTurn.Trashed(cards);

			if (Trashed != null)
			{
				List<Object> handledBy = new List<Object>();
				Boolean actionPerformed = false;
				do
				{
					actionPerformed = false;

					tea = new TrashEventArgs(this, cards);
					tea.HandledBy.AddRange(handledBy);
					Trashed(this, tea);
					handledBy = tea.HandledBy;

					IEnumerator<Player> enumerator = this._Game.GetPlayersStartingWithEnumerator(this);
					while (enumerator.MoveNext())
					{
						Boolean isAnyRequired = false;
						List<String> options = new List<String>();
						IEnumerable<Type> cardTypes = tea.Actions.Keys;
						foreach (Type key in cardTypes)
						{
							if (enumerator.Current == tea.Actions[key].Player)
							{
								options.Add(tea.Actions[key].Text);
								isAnyRequired |= tea.Actions[key].IsRequired;
							}
						}
						if (options.Count > 0)
						{
							options.Sort();
							Choice choice = new Choice(String.Format("{0} trashed {1}", this == enumerator.Current ? "You" : this.ToString(), Utilities.StringUtility.Plural("card", cards.Count)), null, cards, options, this, tea, false, isAnyRequired ? 1 : 0, 1);
							ChoiceResult result = enumerator.Current.MakeChoice(choice);

							if (result.Options.Count > 0)
							{
								tea.Actions.First(kvp => kvp.Value.Text == result.Options[0]).Value.Method(enumerator.Current, ref tea);
								actionPerformed = true;
							}
						}
					}
				} while (Trashed != null && actionPerformed);
			}

			cards.TrashedBy(this);
			Lose(cards);

			if (TrashedFinished != null)
			{
				tea = new TrashEventArgs(this, cards);
				TrashedFinished(this, tea);
			}

			cards.RemovedFrom(location, this);
		}
開發者ID:micahpaul,項目名稱:dominion_net_multi,代碼行數:93,代碼來源:Player.cs


注:本文中的CardCollection.TrashedBy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。