public void SetPawnAt(Field field, PawnColor color) { if (field.X > this.Size - 1) { throw new System.ArgumentException($"{field.X} is out of board bounds {this.Size}x{this.Size}"); } if (field.Y > this.Size - 1) { throw new System.ArgumentException($"{field.Y} is out of board bounds {this.Size}x{this.Size}"); } if (this.Position[field.X, field.Y] == "W" || this.Position[field.X, field.Y] == "b") { throw new System.ArgumentException($"{field} is already occupied by {this.Position[field.X, field.Y]}"); } if (field.Color() == FieldColor.White) { throw new System.ArgumentException($"{field} is white and pawns are allowed only on black fields"); } if (color == PawnColor.White) { this.Position[field.X, field.Y] = "W"; } else { this.Position[field.X, field.Y] = "b"; } }
void Start() { pname = ""; age = 0; height = 0; weight = 0; gender = Gender.None; color = new PawnColor(Color.clear, "", -1); playerHeader.text = "Speler " + (InformationManager.instance.getPlayerSize() + 1); nameError.enabled = false; ageError.enabled = false; heightError.enabled = false; weightError.enabled = false; genderError.enabled = false; colorError.enabled = false; foreach (Button b in colorButtons) { List <PawnColor> usedColors = InformationManager.instance.getUsedColors(); for (int i = 0; i < usedColors.Count; i++) { if (b.name == "Button" + usedColors[i].getColorString()) { b.gameObject.SetActive(false); } } } if ((InformationManager.instance.getPlayerCount() - 1) == InformationManager.instance.getPlayerSize()) { txtBtnNext.text = "Start Spel"; } }
public Pawn(Position position, PawnColor pawnColor, PawnType pawnType, IMoveStrategy moveStrategy) { Position = position; PawnColor = pawnColor; PawnType = pawnType; MoveStrategy = moveStrategy; }
public void ShowCurrentTurn(PawnColor turn, string name) { switch (turn) { case PawnColor.c_Blue: showTurn.text = (name == null || name == "") ? "Blues Turn" : name + " Turn"; showTurn.color = Color.blue; break; case PawnColor.c_Red: showTurn.text = (name == null || name == "") ? "Reds Turn" : name + " Turn"; showTurn.color = Color.red; break; case PawnColor.c_Yellow: showTurn.text = (name == null || name == "") ? "Yellows Turn" : name + " Turn"; showTurn.color = Color.yellow; break; case PawnColor.c_Green: showTurn.text = (name == null || name == "") ? "Greens Turn" : name + " Turn"; showTurn.color = Color.green; break; } }
void Start() { if (StoreColor == PawnColor.c_null) { StoreColor = PlayerSelection.playerColor; } }
public void OnDropConnection(PawnColor col) { int indexOfColor = gm.totalPlayers.IndexOf(col); gm.totalPlayers.Remove(col); gm.playerNames.RemoveAt(indexOfColor); switch (col) { case PawnColor.c_Blue: gm.BlueGameObject.SetActive(false); break; case PawnColor.c_Green: gm.GreenGameObject.SetActive(false); break; case PawnColor.c_Red: gm.RedGameObject.SetActive(false); break; case PawnColor.c_Yellow: gm.YellowGameObject.SetActive(false); break; } if (gm.currentPlayerTurn == col) { SetNextTurn(); } if (gm.totalPlayers.Count < 2) { SceneManager.LoadScene(0); } }
public Board(Board otherBoard, Field from, int toX, int toY) { this.Size = otherBoard.Size; this.Position = otherBoard.Position.Clone() as string[, ]; this.Turn = otherBoard.Turn; this.MakeMove(from.X, from.Y, toX, toY); }
public FieldInfo(PawnColor color, Dot loc, FieldAct fieldAct, bool isDame = false) { Color = color; Loc = loc; IsDame = isDame; FieldAct = fieldAct; }
public Player(string name, string avatarPath, PawnColor pawn) { Name = name; AvatarPath = avatarPath; Pawn = pawn; PawnImagePath = "/CARCASONNE/" + "pawn" + pawn.ToString().ToLower() + ".png"; }
public void run() { Move tmp; while (winner() == PawnColor.NULL) { tmp = white.play(); board.move(tmp); gui.update(); lastPlayerColor = PawnColor.WHITE; lastMove = tmp; ++moves; if (winner() != PawnColor.NULL) { break; } tmp = black.play(); board.move(tmp); gui.update(); lastPlayerColor = PawnColor.BLACK; lastMove = tmp; ++moves; Console.WriteLine("SHIT"); break; } }
private void GeneratePawn(int columnIndex, int rowIndex, PawnColor pawnColor) { Transform tileTransform = tileGetter.GetTile(columnIndex, rowIndex).transform; GameObject instantiatedPawn = Instantiate(Pawn, tileTransform.position, Pawn.transform.rotation, tileTransform); instantiatedPawn.GetComponent <IPawnProperties>().PawnColor = pawnColor; }
public void ShowDiceValues(PawnColor turn, string value) { rolledDiceNumber.gameObject.SetActive(true); rolledDiceNumber.text = value; //showTurn.text = "Rolled :" + value; //diceValImage.SetActive(true); //diceValImage.GetComponent<Image>().sprite = diceValues[int.Parse(value)]; // // // switch (turn) // { // case PawnColor.c_Blue: // showTurn.color = Color.blue; // diceValImage.GetComponent<Image> ().color = Color.blue; // break; // case PawnColor.c_Red: // showTurn.color = Color.red; // break; // case PawnColor.c_Yellow: // showTurn.color = Color.yellow; // break; // case PawnColor.c_Green: // showTurn.color = Color.green; // break; // } }
private void PutPlayerOnBoard(PawnColor color, Board board) { switch (color) { case PawnColor.RED: board.BoardList[0].Red.Visibility = Visibility.Visible; break; case PawnColor.GREEN: board.BoardList[0].Green.Visibility = Visibility.Visible; break; case PawnColor.BLUE: board.BoardList[0].Blue.Visibility = Visibility.Visible; break; case PawnColor.PURPLE: board.BoardList[0].Purple.Visibility = Visibility.Visible; break; case PawnColor.ORANGE: board.BoardList[0].Orange.Visibility = Visibility.Visible; break; case PawnColor.YELLOW: board.BoardList[0].Yellow.Visibility = Visibility.Visible; break; default: break; } }
private void MakeNewPlayer(string name, string avatar, PawnColor pawn) { Player player = new Player(name, avatar, pawn); _playerList.Add(player); _boardData.StartSidebar.PlayersDisplay.Add(player); }
public void SetNextTurn() { Debug.Log("Setting Next Turn"); lockedplayers = 0; if (playerIndex < 0) { playerIndex = totalPlayers.IndexOf(currentPlayerTurn); } if (playerIndex < totalPlayers.Count - 1) { playerIndex = totalPlayers.IndexOf(currentPlayerTurn); playerIndex++; } else { playerIndex = 0; } currentPlayerTurn = totalPlayers[playerIndex]; if (!CheckAITurn()) { ui_m.ActivateSpinButton(); } ui_m.ShowCurrentTurn(currentPlayerTurn, playerNames[playerIndex]); }
public void Browse(PawnColor _color) { string initDirectory = WhitePlayer.ImageSource; if (_color == PawnColor.Black) { initDirectory = BlackPlayer.ImageSource; } var file = new FileInfo(initDirectory); if (!file.Exists) { initDirectory = ""; } var ofd = new OpenFileDialog { Filter = "PNG|*.png", InitialDirectory = initDirectory }; ofd.ShowDialog(); if (ofd.FileName.Length > 1) { if (_color == PawnColor.Black) { BlackPlayer.ImageSource = ofd.FileName; } else { WhitePlayer.ImageSource = ofd.FileName; } } }
private IEnumerable <GameObject> GetPawnsToCheck(TreeNode <Move> treeNode) { GameObject pawn = GetPawnFromTreeNode(treeNode); PawnColor pawnColor = GetPawnColor(pawn); var pawnsToCheck = pawnColor == PawnColor.White ? blackPawns : whitePawns; //Opposite pawns should be checked. return(pawnsToCheck.OrderBy(element => Random.value)); }
public Board() { this.Size = DEFAULT_SIZE; this.Position = new string[this.Size, this.Size]; this.ColorFields(); this.PlaceStartingPawns(3); this.Turn = PawnColor.White; }
/// <summary>Określ kolor przeciwnika dla podanego koloru</summary> /// <param name="pc">Kolor</param> /// <returns>Kolor przeciwnika</returns> public static PawnColor GetOpponentColor(PawnColor pc) { if (pc == PawnColor.Black) return PawnColor.White; if (pc == PawnColor.White) return PawnColor.Black; return PawnColor.None; }
/// <summary>Zwróć piona dla podanego koloru</summary> /// <param name="pc">Kolor</param> /// <returns>Pion w danym kolorze</returns> public static PawnType GetPawnByColor(PawnColor pc) { if (pc == PawnColor.Black) return PawnType.BlackPawn; if (pc == PawnColor.White) return PawnType.WhitePawn; return PawnType.None; }
public void NewGame(PawnColor cpu_color, IBoard board) { /* TODO: Kod startowy nowej gry Kod uruchamiany jest każdorazowo podczas rozpoczynania nowej gry. */ this.plansza = board; }
public void SelectHumanPlayer(GameObject overlay) { if (!isPlayerSelected) { overlay.SetActive(false); isPlayerSelected = true; playerColor = overlay.GetComponentInParent <SetPlayerInfo>().playerColor; } }
private static Board CreateBoard(PawnColor player1color) { BlackPawnsAlive = new List <Pawn>(); WhitePawnsAlive = new List <Pawn>(); Console.WriteLine($"\nYou Chose {player1color}\n"); Board board = new Board(player1color); for (int y = 0; y < 3; y++) { //Setting The Pawns On The Black Tiles // Even Rows = x % 2 == y % 2 == 0 // Odd Rows = x % 2 == y % 2 != 0 for (int x = y % 2; x < board.Tiles.GetLength(1); x++) { if (y % 2 == x % 2) { board.Tiles[y, x] = new Pawn { Color = PawnColor.Black }; BlackPawnsAlive.Add(board.Tiles[y, x]); } else { board.Tiles[y, x] = null; } } } //Setting Player2 On The Board for (int y = 5; y < board.Tiles.GetLength(0); y++) { //Setting The Pawns On The Black Tiles // Even Rows = x % 2 == y % 2 == 0 // Odd Rows = x % 2 == y % 2 != 0 for (int x = y % 2; x < board.Tiles.GetLength(1); x += 2) { if (y % 2 == x % 2) { board.Tiles[y, x] = new Pawn { Color = PawnColor.White }; WhitePawnsAlive.Add(board.Tiles[y, x]); } else { board.Tiles[y, x] = null; } } } return(board); }
protected void AddPawnList(IReadOnlyCollection <Pawn> rList, PawnColor pawnColor) { foreach (var pawn in rList) { Dot pawnPos = pawn.GetPosition(); pawnList[pawnPos.X, pawnPos.Y] = pawn; pawnColorList[pawnPos.X, pawnPos.Y] = pawnColor; } }
void OnDestroy() { if (SceneManager.GetActiveScene().name == "LobbyScene") { isSelected = false; color = PawnColor.c_null; //playerValue = -100; } }
public void NextTurn() { turn = turn == PawnColor.White ? PawnColor.Black : PawnColor.White; TurnTextChanger.ChangeTurnText(turn); if (isGameVsCPU && turn == PawnColor.Black) { cpuPlayer.DoCPUMove(); } }
/// <summary> /// Porównanie dwóch pionów ze względu na ich kolor (z pominięciem typu) /// </summary> public static bool EqualColor(PawnColor pc, PawnType pt) { if (pc == PawnColor.Black && (pt == PawnType.BlackPawn || pt == PawnType.BlackQueen)) return true; if (pc == PawnColor.White && (pt == PawnType.WhitePawn || pt == PawnType.WhiteQueen)) return true; return false; }
// Use this for initialization void Awake() { col = PlayerSelection.playerColor; gm = GameObject.Find("GameManager").GetComponent <GameManager>(); nm = GameObject.Find("NetWork Manager"); gm.nm_server = this; }
private IEnumerable <TileIndex> GetPawnMoves(GameObject pawn) { PawnColor pawnColorToCheck = GetPawnColor(pawn); bool pawnsHaveCapturingMove = moveChecker.PawnsHaveCapturingMove(pawnColorToCheck); var pawnMoves = pawnsHaveCapturingMove ? moveChecker.GetPawnCapturingMoves(pawn) : moveChecker.GetPawnNoncapturingMoves(pawn); return(pawnMoves.OrderBy(element => Random.value)); }
protected void SwapPawnColor() { if (pawnColor == PawnColor.WHITE) { pawnColor = PawnColor.BLACK; } else if (pawnColor == PawnColor.BLACK) { pawnColor = PawnColor.WHITE; } }
private bool isPawnColorInArray(List <PawnColor> array, PawnColor value) { foreach (PawnColor pc in array) { if (pc.Equals(value)) { return(true); } } return(false); }
private void printTurn(PawnColor color) { if (color == PawnColor.BLACK) { Console.Write("BLACK"); } else if (color == PawnColor.WHITE) { Console.Write("WHITE"); } }
public void InitializeGame() { totalPlayers.Clear(); playerNames.Clear(); Debug.Log(SelectPlayField.whichBoard); mat.mainTexture = boardTexture[SelectPlayField.whichBoard]; print("from manager : " + PlayerSelection.playerInfo.Count); for (int i = 0; i < PlayerSelection.playerInfo.Count; i++) { totalPlayers.Add(PlayerSelection.playerInfo[i].color); playerNames.Add(PlayerSelection.playerInfo[i].name); } for (int i = 0; i < totalPlayers.Count; i++) { switch (totalPlayers[i]) { case PawnColor.c_Blue: BlueGameObject.SetActive(true); break; case PawnColor.c_Red: RedGameObject.SetActive(true); break; case PawnColor.c_Green: GreenGameObject.SetActive(true); break; case PawnColor.c_Yellow: YellowGameObject.SetActive(true); break; } } if (!PlayerSelection.isNetworkedGame) { int randIndex = Random.Range(0, totalPlayers.Count); currentPlayerTurn = totalPlayers[randIndex]; if (!CheckAITurn()) { ui_m.ActivateSpinButton(); } ui_m.ShowCurrentTurn(currentPlayerTurn, playerNames[randIndex]); Debug.Log("Non Networked"); } else { Debug.Log("Networked"); nm_server.GetStartingTurn(totalPlayers.Count); } ui_m.RemoveLoadingScreen(); }
public void ShowCurrentTurn(PawnColor turn, string name) { //HideDiceImage (); rolledDiceNumber.gameObject.SetActive(false); switch (turn) { case PawnColor.c_Blue: showTurn.text = (name == null || name == "") ? "Blues Turn" : name + "'s Turn"; showTurn.color = blue; Blue.ShowSelectableAnimation(); Red.StopSelectableAnimation(); Yellow.StopSelectableAnimation(); Green.StopSelectableAnimation(); //diceValImage.GetComponent<Image> ().color = Color.blue; rolledDiceNumber.color = Color.blue; break; case PawnColor.c_Red: showTurn.text = (name == null || name == "") ? "Reds Turn" : name + "'s Turn"; showTurn.color = red; Blue.StopSelectableAnimation(); Red.ShowSelectableAnimation(); Yellow.StopSelectableAnimation(); Green.StopSelectableAnimation(); //diceValImage.GetComponent<Image> ().color = Color.red; rolledDiceNumber.color = Color.red; break; case PawnColor.c_Yellow: showTurn.text = (name == null || name == "") ? "Yellows Turn" : name + "'s Turn"; showTurn.color = yellow; Blue.StopSelectableAnimation(); Red.StopSelectableAnimation(); Yellow.ShowSelectableAnimation(); Green.StopSelectableAnimation(); //diceValImage.GetComponent<Image> ().color = Color.yellow; rolledDiceNumber.color = Color.yellow; break; case PawnColor.c_Green: showTurn.text = (name == null || name == "") ? "Greens Turn" : name + "'s Turn"; showTurn.color = green; Blue.StopSelectableAnimation(); Red.StopSelectableAnimation(); Yellow.StopSelectableAnimation(); Green.ShowSelectableAnimation(); //diceValImage.GetComponent<Image> ().color = Color.green; rolledDiceNumber.color = Color.green; break; } turnColorIndicator.color = rolledDiceNumber.color; }
public Pawn(PawnColor color, PawnType type) : base("MasterMindPawn") { _effect = new Particle.ParticleSystem("light"); _effect.SetLifeTime(10, 20); _effect.SetParent(this.EntityId); _effect.SetSize(0.2f, 0.2f); _effect.SetSpread(Helpers.PhysicsAndPositions.PI * 2); _effect.SetRandomSpeed(true, 0.05f); SetPawnColor(color); SetPawnType(type); SetTexture("pawn"); Selected = false; }
public MainWindow() { InitializeComponent(); this.Text = this.Text + " - Wersja " + Application.ProductVersion.ToString(); this.random = new Random(); this.dbg = new DebugWindow(); this.btnShowDebugWindow_Click(null, null); this.pawn_matrix = new PawnType[8, 8]; this.field_matrix = new Label[8, 8]; this.selected_color_matrix = new Color[8, 8]; this.normal_color_matrix = new Color[8, 8]; this.selected_field = PointExt.Invalid; for (int r = 0; r < 8; r++) for (int c = 0; c < 8; c++) { string cname = string.Format("p{0}{1}", (char)('A' + r), 1 + c); this.field_matrix[r, c] = this.panel1.Controls[cname] as Label; this.normal_color_matrix[r, c] = (r + c) % 2 == 0 ? Color.White : Color.Silver; this.selected_color_matrix[r, c] = (r + c) % 2 == 0 ? Color.FromArgb(255 - 50, 255, 255 - 50) : Color.FromArgb(192 - 50, 192, 192 - 50); this.field_matrix[r, c].BackColor = this.normal_color_matrix[r, c]; } this.current_turn = PawnColor.None; this.cpu_color = PawnColor.None; this.human_color = PawnColor.None; this.ShowGameState(); // uruchomienie bota this.bot = new MojBot(); this.lblBotAuthor.Text = this.bot.GetAuthor(); this.lblBotDescription.Text = this.bot.GetDescripion(); try { this.bot.Initialize(); } catch (Exception ex) { MessageBox.Show(string.Format("Wyjątek podczas uruchamiania metody Bot.Initialize():\n{0}", ex.Message), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static byte[] ConvertPawnColor(PawnColor color) { switch(color){ case PawnColor.None: return new byte[3] { 0, 0, 0 }; break; case PawnColor.Red: return new byte[3] { 255, 0, 0 }; break; case PawnColor.Green: return new byte[3] { 0, 255, 0 }; break; case PawnColor.Blue: return new byte[3] { 0, 0 ,255}; break; case PawnColor.Orange: return new byte[3] { 255, 100, 0 }; break; case PawnColor.Yellow: return new byte[3] { 255, 255, 0 }; break; case PawnColor.Purple: return new byte[3] { 255, 0, 255 }; break; case PawnColor.Brown: return new byte[3] { 200, 110, 110 }; break; case PawnColor.Black: return new byte[3] { 0, 0, 0 }; break; case PawnColor.White: return new byte[3] { 255, 255, 255 }; break; default: return new byte[3] { 0, 0, 0 }; break; } }
public void SetPawnColor(PawnColor color) { _pawnColor = color; SetColor(ConvertPawnColor(color)); _effect.SetColor(ConvertPawnColor(color)); }
/// <summary> /// Porównanie dwóch pionów ze względu na ich kolor /// </summary> /// <param name="pc1">Kolor pionu pierwszego</param> /// <param name="pc2">Kolor pionu drugiego</param> /// <returns>Zwraca true jeśli kolory są zgodne</returns> static bool EqualColor(PawnColor pc1, PawnColor pc2) { return pc1 == pc2; }
public static bool IsNone(PawnColor pc) { return pc == PawnColor.None; }
private void EndTurn(bool new_game) { // test bool test = false; test |= move_count == 1 && capture_count == 0; // był tylko ruch test |= move_count == 0 && capture_count >= 1; // było jedno lub więcej bić test |= !(move_count > 0 && move_count > 0); // niemozliwe: ruch i bicie Debug.Assert(test); if (new_game) { // przygotowania do nowej gry this.current_turn = PawnColor.White; this.white_score = 0; this.black_score = 0; } else { // zakończenie kolejnej tury w ramach danej gry // jeśli pion przeciwnika jest na pierwszym polu (najbliżej gracza) to awansuj go na damę foreach (PawnColor pc in new PawnColor[] { PawnColor.Black, PawnColor.White }) for (int c = 0; c < 8; c++) { Point p = PointExt.Invalid; if (pc == PawnColor.Black) p = new Point(c, 0); else p = new Point(c, 7); bool coronation = false; if (Pawn.GetColor(this.GetPawn(p)) == pc && Pawn.IsNormalPawn(this.GetPawn(p))) { this.InternalSetPawn(p, Pawn.GetQueenByColor(pc)); coronation = true; } if (coronation) AddPlayerLog(string.Format("Koronacja na {0}", Pawn.PointToFieldAddress(p))); } // podlicz punkty int points = 0; if (this.move_count == 0 && this.capture_count == 0) { // człowiek lub bot nie wykonali żadnego ruchu - poddali ruch points = -1; } else { if (this.capture_count == 1) // jedno bicie points += 2; if (this.capture_count > 1) // wiele bić :) points += 5 * this.capture_count; } if (this.current_turn == PawnColor.Black) this.black_score += points; else this.white_score += points; // zmiana tury this.current_turn = this.current_turn == PawnColor.Black ? PawnColor.White : PawnColor.Black; } this.capture_count = 0; this.move_count = 0; this.DeselectPawn(); this.ShowGameState(); }
private bool isPawnColorInArray(List<PawnColor> array, PawnColor value) { foreach(PawnColor pc in array){ if(pc.Equals(value)){ return true; } } return false; }