本文整理汇总了C#中Match.AdvancePlayer方法的典型用法代码示例。如果您正苦于以下问题:C# Match.AdvancePlayer方法的具体用法?C# Match.AdvancePlayer怎么用?C# Match.AdvancePlayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Match
的用法示例。
在下文中一共展示了Match.AdvancePlayer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public override void Apply(Match match)
{
if (!this.IsValid(match))
{
return;
}
var playerTiles = match.Players[_playerIndex].Tiles;
//Draw new tile.
Tile newTile = match.AvailableTiles.Dequeue();
playerTiles.Add(newTile);
Console.WriteLine(" Drawing tile for [{0}] - {1}", match.Players[_playerIndex].Member.Name, newTile.Description);
//Advance player index.
match.AdvancePlayer();
match.CurrentPhase = MatchPhase.WaitingForMove;
}
示例2: Apply
public override void Apply(Match match)
{
if (!this.IsValid(match))
{
return;
}
var playerTiles = match.Players[_playerIndex].Tiles;
Tile playedTile = playerTiles.Find(t => t.Sequence == _tileId);
playerTiles.Remove(playedTile);
match.PlayedTiles.Add(playedTile);
//Find list of spaces adjacent to played tile.
List<Tile> adjacentTiles = match.GetAdjacentTiles(_tileId);
Console.WriteLine(" {0} adjacent tiles on board", adjacentTiles.Count);
if (adjacentTiles.Count > 0)
{
//Check for adjacent chains.
List<Chain> adjacentChains = new List<Chain>();
Console.Write("Adjacent Tiles: ");
foreach (var t in adjacentTiles)
{
Console.Write(" {0}", t.Description);
Chain c = match.Chains.FirstOrDefault(ch => ch.Tiles.Contains(t));
if (c != null && !adjacentChains.Contains(c))
{
adjacentChains.Add(c);
}
if (adjacentTiles.IndexOf(t) < adjacentTiles.Count) Console.Write(" | ");
}
Console.WriteLine();
if (adjacentChains.Count == 0) //No existing chains, new one created.
{
Console.WriteLine("New chain created.");
Chain c = new Chain();
c.Tiles.Add(playedTile);
c.Tiles.AddRange(adjacentTiles);
//TODO: Handle pseudo-chains from draw for first move.
match.Chains.Add(c);
match.PendingDecisions.Enqueue(new Decision
{
PlayerIndex = match.CurrentPlayerIndex,
Type = DecisionType.ChooseNewStock
//Data = match.AvailableStock.Where(s => !match.Chains.Select(ch => ch.Company).Contains(s.Key))
});
//match.Players[match.CurrentPlayerIndex].AddStock(match.AvailableStock)
}
else if (adjacentChains.Count == 1) //Tile extends existing chain.
{
Chain c = adjacentChains.Single();
c.Tiles.Add(playedTile);
c.Tiles.AddRange(adjacentTiles.Where(t => !c.Tiles.Contains(t)));
}
else //Tile creates a merger.
{
adjacentChains.Sort(delegate(Chain a, Chain b)
{
return a.Tiles.Count.CompareTo(b.Tiles.Count);
});
match.PendingDecisions.Enqueue(new Decision
{
PlayerIndex = match.CurrentPlayerIndex,
Type = DecisionType.ChooseMergeOrder
});
}
}
match.PendingDecisions.Enqueue(new Decision
{
PlayerIndex = match.CurrentPlayerIndex,
Type = DecisionType.PurchaseStock
});
if (match.PendingDecisions.Count > 0)
{
match.CurrentPhase = MatchPhase.HandlingDecisions;
}
else
{
match.AdvancePlayer();
}
}