private static void AddPieceToRow(int row, PieceStyle pieceStyle, Rectangle location) { Dictionary <int, Piece> styleList; int nextPiece = 0; if (pieceRowsList.ContainsKey(row)) { styleList = pieceRowsList[row]; nextPiece = GetRowLength(row) + 1; } else { styleList = new Dictionary <int, Piece>(); pieceRowsList.Add(row, styleList); } float degrees = 0; for (int p = 0; p < 4; p++) { Sprite sprite = new Sprite(location, TextureSheet.MapObjects); sprite.rotation = MathHelper.ToRadians(degrees); sprite.scale = 0.7f; styleList.Add(nextPiece, new Piece(pieceStyle, sprite, nextPiece)); degrees += 90; if (degrees == 360) { degrees = 0; } nextPiece++; } }
public void SaveConfig(Stream outputStream) { if (null == outputStream) { throw new ArgumentNullException(nameof(outputStream)); } XmlWriterSettings settings = new XmlWriterSettings { Indent = true }; using (XmlWriter writer = XmlWriter.Create(outputStream, settings)) { writer.WriteStartElement("Mzinga.Viewer"); writer.WriteAttributeString("version", AppVM.FullVersion); writer.WriteAttributeString("date", DateTime.UtcNow.ToString()); writer.WriteElementString("EngineType", EngineType.ToString()); writer.WriteElementString("EngineCommandLine", EngineCommandLine); writer.WriteElementString("HexOrientation", HexOrientation.ToString()); writer.WriteElementString("NotationType", NotationType.ToString()); writer.WriteElementString("PieceStyle", PieceStyle.ToString()); writer.WriteElementString("PieceColors", PieceColors.ToString()); writer.WriteElementString("DisablePiecesInHandWithNoMoves", DisablePiecesInHandWithNoMoves.ToString()); writer.WriteElementString("DisablePiecesInPlayWithNoMoves", DisablePiecesInPlayWithNoMoves.ToString()); writer.WriteElementString("HighlightTargetMove", HighlightTargetMove.ToString()); writer.WriteElementString("HighlightValidMoves", HighlightValidMoves.ToString()); writer.WriteElementString("HighlightLastMovePlayed", HighlightLastMovePlayed.ToString()); writer.WriteElementString("BlockInvalidMoves", BlockInvalidMoves.ToString()); writer.WriteElementString("RequireMoveConfirmation", RequireMoveConfirmation.ToString()); writer.WriteElementString("AddPieceNumbers", AddPieceNumbers.ToString()); writer.WriteElementString("StackPiecesInHand", StackPiecesInHand.ToString()); writer.WriteElementString("PlaySoundEffects", PlaySoundEffects.ToString()); writer.WriteElementString("ShowBoardHistory", ShowBoardHistory.ToString()); writer.WriteElementString("ShowMoveCommentary", ShowMoveCommentary.ToString()); writer.WriteElementString("FirstRun", FirstRun.ToString()); writer.WriteElementString("CheckUpdateOnStart", CheckUpdateOnStart.ToString()); InternalGameEngineConfig?.SaveGameAIConfig(writer, "InternalGameAI", ConfigSaveType.BasicOptions); writer.WriteEndElement(); } }
private static void AddStandardRow(int row, PieceStyle pieceStyle, int numberOfPieces, bool addFlip) { int pieceIndex = 0; int indexLeft = 0; Dictionary <int, Piece> styleList = new Dictionary <int, Piece>(); float degrees = 0; SpriteEffects spriteEffect = SpriteEffects.None; for (int i = 0; i < numberOfPieces; i++) { for (int p = 0; p < 4; p++) { Rectangle location = new Rectangle((indexLeft * GroundLayerController.tileSize) + 1 + (indexLeft * 2), (row * GroundLayerController.tileSize) + 1 + (row * 2), GroundLayerController.tileSize, GroundLayerController.tileSize); Sprite sprite = new Sprite(location, TextureSheet.MapObjects); sprite.spriteEffect = spriteEffect; sprite.rotation = MathHelper.ToRadians(degrees); styleList.Add(pieceIndex, new Piece(pieceStyle, sprite, pieceIndex)); degrees += 90; if (degrees == 360) { degrees = 0; } pieceIndex++; } if (addFlip) { if (spriteEffect != SpriteEffects.FlipHorizontally) { spriteEffect = SpriteEffects.FlipHorizontally; i--; indexLeft--; } else { spriteEffect = SpriteEffects.None; } } indexLeft++; } pieceRowsList.Add(row, styleList); }
private void SwitchTurns() { //This is equivalent to: if currently X's turn, // make it O's turn, and vice-versa CurrentTurn = CurrentTurn == PieceStyle.X ? PieceStyle.O : PieceStyle.X; }
public GamePiece() { Style = PieceStyle.Blank; }
public Piece(PieceStyle pieceStyle, Sprite sprite, int pieceId) { this.pieceStyle = pieceStyle; this.sprite = sprite; this.pieceId = pieceId; }
public GamePiece(PieceStyle color) { Style = color; }
private void SwitchTurns() { //判断轮到哪方落子 CurrentTurn = CurrentTurn == PieceStyle.X ? PieceStyle.O : PieceStyle.X; }