// +1 Action // +1 Card // Each player (including you) reveals the top card of his deck and either discards it or puts it back, // your choice. private void ResolveCardSpy(Player activePlayer, Card cardToResolve) { activePlayer.DrawCards(1); activePlayer.AddAction(1); using (var loop = new LoopEnumerator <Player>(players, activePlayerIndex, 1)) { loop.Reset(); while (loop.MoveNext()) { var player = loop.Current; if (player == activePlayer || !TryDefendAttack(player)) { var revealedCard = player.RevealTopCardFromDeck(); if (revealedCard != null) { writer.WriteLine("{0} revealed {1}", player.Name, revealedCard.Info.CardName); writer.Write("Would you like to discard it?"); if (Texts.ParseBoolean(reader.ReadLine()) ?? true) { player.DiscardRevealCard(revealedCard); } else { player.UnrevealCardToTopDeck(revealedCard); } } } } } }
private void WriteGeometry(XmlTextWriter writer, Part part, Model myModel) { if (part != null) { WorkPlaneHandler planeHandler = myModel.GetWorkPlaneHandler(); TransformationPlane CurrentPlane = planeHandler.GetCurrentTransformationPlane(); writer.WriteStartElement("Part", null); writer.WriteAttributeString("id", part.Identifier.ID.ToString()); writer.WriteElementString("name", part.Name); writer.WriteElementString("material", part.Material.MaterialString); writer.WriteStartElement("profile", null); writer.WriteElementString("name", part.Profile.ProfileString); writer.WriteEndElement(); Solid solid = part.GetSolid() as Solid; FaceEnumerator myFaceEnum = solid.GetFaceEnumerator(); writer.WriteStartElement("Solid", null); while (myFaceEnum.MoveNext()) { Face myFace = myFaceEnum.Current as Face; if (myFace != null) { writer.WriteStartElement("Face", null); LoopEnumerator myLoopEnum = myFace.GetLoopEnumerator(); while (myLoopEnum.MoveNext()) { Loop myLoop = myLoopEnum.Current as Loop; if (myLoop != null) { writer.WriteStartElement("Loop", null); VertexEnumerator myVertexEnum = myLoop.GetVertexEnumerator() as VertexEnumerator; while (myVertexEnum.MoveNext()) { Point myVertex = myVertexEnum.Current as Point; if (myVertex != null) { writer.WriteStartElement("Vertex", null); writer.WriteElementString("X", myVertex.X.ToString("#.##")); writer.WriteElementString("Y", myVertex.Y.ToString("#.##")); writer.WriteElementString("Z", myVertex.Z.ToString("#.##")); writer.WriteEndElement(); // End Vertex } } writer.WriteEndElement(); // End Loop } } writer.WriteEndElement(); // End Face } } writer.WriteEndElement(); // End Solid planeHandler.SetCurrentTransformationPlane(CurrentPlane); writer.WriteEndElement(); } }
public static List <Loop> ToList(this LoopEnumerator loopEnumerator) { var loops = new List <Loop>(); while (loopEnumerator.MoveNext()) { var loop = loopEnumerator.Current; loops.Add(loop); } return(loops); }
internal static Dictionary <Plane, Face> GetGeometricPlane(Solid solid) { FaceEnumerator FaceEnum = solid.GetFaceEnumerator(); Dictionary <Plane, Face> Planes = new Dictionary <Plane, Face>(); while (FaceEnum.MoveNext()) { List <Point> PlaneVertexes = new List <Point>(); Face face = FaceEnum.Current as Face; LoopEnumerator Loops = face.GetLoopEnumerator(); while (Loops.MoveNext()) { Loop loop = Loops.Current as Loop; VertexEnumerator vertexes = loop.GetVertexEnumerator(); while (vertexes.MoveNext()) { Point Vertex = vertexes.Current as Point; if (!PlaneVertexes.Contains(Vertex)) { if (PlaneVertexes.Count != 3 || (PlaneVertexes.Count == 3 && !ArePointAligned(PlaneVertexes[0], PlaneVertexes[1], Vertex))) { PlaneVertexes.Add(Vertex); } if (PlaneVertexes.Count == 3) { Vector Vector1 = new Vector(PlaneVertexes[1].X - PlaneVertexes[0].X, PlaneVertexes[1].Y - PlaneVertexes[0].Y, PlaneVertexes[1].Z - PlaneVertexes[0].Z); Vector Vector2 = new Vector(PlaneVertexes[2].X - PlaneVertexes[0].X, PlaneVertexes[2].Y - PlaneVertexes[0].Y, PlaneVertexes[2].Z - PlaneVertexes[0].Z); Plane plane = new Plane { Origin = PlaneVertexes[0], AxisX = Vector1, AxisY = Vector2 }; Planes.Add(plane, face); break; } } } break; } } return(Planes); }
internal static Dictionary <Plane, Face> GetGeometricPlanes(Solid solid) { // Face(삼각면) FaceEnumerator faceEnum = solid.GetFaceEnumerator(); Dictionary <Plane, Face> planes = new Dictionary <Plane, Face>(); while (faceEnum.MoveNext()) { List <Point> planeVertexes = new List <Point>(); Face face = faceEnum.Current as Face; LoopEnumerator loops = face.GetLoopEnumerator(); while (loops.MoveNext()) { Loop loop = loops.Current as Loop; VertexEnumerator vertexes = loop.GetVertexEnumerator(); while (vertexes.MoveNext()) { Point vertex = vertexes.Current as Point; if (!planeVertexes.Contains(vertex)) { //Three Points form a plane and they cannot be aligned. if (planeVertexes.Count != 3 || (planeVertexes.Count == 3 && !ArePointAligned(planeVertexes[0], planeVertexes[1], vertex))) { planeVertexes.Add(vertex); } if (planeVertexes.Count == 3) { Vector vector1 = new Vector(planeVertexes[1].X - planeVertexes[0].X, planeVertexes[1].Y - planeVertexes[0].Y, planeVertexes[1].Z - planeVertexes[0].Z); Vector vector2 = new Vector(planeVertexes[2].X - planeVertexes[0].X, planeVertexes[2].Y - planeVertexes[0].Y, planeVertexes[2].Z - planeVertexes[0].Z); Plane plane = new Plane(); plane.Origin = planeVertexes[0]; plane.AxisX = vector1; plane.AxisY = vector2; planes.Add(plane, face); break; } } } break; } } return(planes); }
// +1 Buy // +4 Cards // Each other player draws a card private void ResolveCardCouncilRoom(Player activePlayer, Card cardToResolve) { activePlayer.DrawCards(4); activePlayer.AddBuy(1); using (var loop = new LoopEnumerator <Player>(players, activePlayerIndex, 1)) { loop.Reset(); while (loop.MoveNext()) { var player = loop.Current; if (player != activePlayer) { player.DrawCards(1); } } } }
// +2 Coins // Each other player discards down to 3 cards in his hand. private void ResolveCardMilitia(Player activePlayer, Card cardToResolve) { activePlayer.AddCoinBonus(2); using (var loop = new LoopEnumerator <Player>(players, activePlayerIndex, 1)) { loop.Reset(); while (loop.MoveNext()) { var player = loop.Current; if (player != activePlayer && !TryDefendAttack(player)) { player.DisplayInfo(writer); while (player.HandCardsCount > 3) { writer.Write("{0}, choose {1} cards to discard:", player.Name, player.HandCardsCount - 3); String discardCards; if (player is AIPlayer) { discardCards = SpecialActionAI.ResolveCardMilitiaAI(player); writer.Write(discardCards); writer.WriteLine(); } else { discardCards = reader.ReadLine(); } var cardsToDiscard = player.FindCardsOnHand(Texts.SplitCsv(discardCards)); if (cardsToDiscard.Length == player.HandCardsCount - 3) { player.DiscardHandCards(cardsToDiscard); } else { writer.WriteLine("You must choose exactly {0} cards to discard", player.HandCardsCount - 3); } } } } } }
// +2 Cards // Each other player gains a Curse private void ResolveCardWitch(Player activePlayer, Card cardToResolve) { activePlayer.DrawCards(2); using (var loop = new LoopEnumerator <Player>(players, activePlayerIndex, 1)) { loop.Reset(); while (loop.MoveNext()) { var player = loop.Current; if (player != activePlayer && !TryDefendAttack(player)) { var cardToGain = supply.GetCard(CardCentral.Shared.GetCardInfo("Curse")); if (cardToGain != null) { player.GainCard(cardToGain); } } } } }
private static void DrawMesh(Face face) { GraphicsDrawer graphicsDrawer = new GraphicsDrawer(); Mesh mesh = new Mesh(); LoopEnumerator loops = face.GetLoopEnumerator(); loops.MoveNext(); Loop loop = loops.Current as Loop; VertexEnumerator vertexes = loop.GetVertexEnumerator(); while (vertexes.MoveNext()) { mesh.AddPoint(vertexes.Current as Point); } for (int index = 0; index < mesh.Points.Count - 2; index++) { mesh.AddTriangle(index, index + 1, index + 2); mesh.AddTriangle(index + 2, index + 1, index); } graphicsDrawer.DrawMeshSurface(mesh, new Color(1, 0, 0)); }
// Gain a silver. Put it on top of your deck // Each other player reveals a Victory card from his hand and puts it on his deck // (or reveals a hand with no Victory cards) private void ResolveCardBureaucrat(Player activePlayer, Card cardToResolve) { var cardToGain = supply.GetCard(CardCentral.Shared.GetCardInfo("Silver")); if (cardToGain != null) { activePlayer.GainCardOnDeck(cardToGain); } using (var loop = new LoopEnumerator <Player>(players, activePlayerIndex, 1)) { loop.Reset(); while (loop.MoveNext()) { var player = loop.Current; if (player != activePlayer && !TryDefendAttack(player)) { player.DisplayInfo(writer); Card cardToReveal; do { writer.Write("{0}, select a victory card to reveal (empty to skip and reveal the whole hand):", player.Name); var cardNameToReveal = Texts.Trim(reader.ReadLine()); if (string.IsNullOrEmpty(cardNameToReveal)) { cardToReveal = null; if (!player.HasVictoryCardOnHand()) { break; } writer.Write("You cannot skip as you have victory cards in hand"); } else { cardToReveal = player.FindCardOnHand(cardNameToReveal); if (cardToReveal == null) { writer.WriteLine("{0} is not in your hand", cardNameToReveal); } else if (!cardToReveal.Info.IsVictoryCard) { writer.WriteLine("{0} is not a victory card", cardToReveal.Info.CardName); cardToReveal = null; } } } while (cardToReveal == null); if (cardToReveal != null) { player.RevealHandCard(cardToReveal); player.DisplayRevealCards(writer); player.UnrevealCardToTopDeck(cardToReveal); } else { var handCards = player.RevealAllHandCards(); player.DisplayRevealCards(writer); player.UnrevealCardsToHand(handCards); } } } } }
// Each other player reveals the top 2 cards of his deck. // If they revealed any Treasure cards, they trash one of them that you choose. // You may gain any or all of these trashed cards. They discard the other revealed cards. private void ResolveCardThief(Player activePlayer, Card cardToResolve) { var tempTrashCards = new List <Card>(); using (var loop = new LoopEnumerator <Player>(players, activePlayerIndex, 1)) { loop.Reset(); while (loop.MoveNext()) { var player = loop.Current; if (player != activePlayer && !TryDefendAttack(player)) { var treasureCards = new List <Card>(); var revealedCards = new List <Card>(2); while (revealedCards.Count < 2) { var revealedCard = player.RevealTopCardFromDeck(); if (revealedCard == null) { break; } revealedCards.Add(revealedCard); if (revealedCard.Info.IsTreasureCard) { treasureCards.Add(revealedCard); } } if (treasureCards.Count > 0) { writer.Write("{0} has revealed {1} treasure cards:", player.Name, treasureCards.Count); foreach (var card in treasureCards) { writer.Write(card.Info.CardName); writer.Write(", "); } writer.WriteLine(); Card cardToTrash; do { writer.Write("Choose one to trash:"); var cardNameToTrash = Texts.Trim(reader.ReadLine()); cardToTrash = Card.FindCard(cardNameToTrash, treasureCards); if (cardToTrash == null) { writer.WriteLine("{0} is not in the options", cardNameToTrash); } } while (cardToTrash == null); player.TrashRevealCard(cardToTrash, tempTrashCards); revealedCards.Remove(cardToTrash); } player.DiscardRevealCards(revealedCards.ToArray()); } } } if (tempTrashCards.Count > 0) { writer.Write("Trash cards to gain:"); foreach (var card in tempTrashCards) { writer.Write(card.Info.CardName); writer.Write(", "); } writer.WriteLine(); writer.Write("Choose which to gain (type all to gain all):"); var cardNamesToGain = Texts.SplitCsv(reader.ReadLine()); Card[] cardsToGain; if (cardNamesToGain.Length == 1 && "all".Equals(cardNamesToGain[0], StringComparison.OrdinalIgnoreCase)) { cardsToGain = tempTrashCards.ToArray(); } else { cardsToGain = Card.FindCards(cardNamesToGain, tempTrashCards); } activePlayer.GainCards(cardsToGain); tempTrashCards.RemoveRange(cardsToGain); } trashCards.AddRange(tempTrashCards); }