private void But_Click(object sender, EventArgs e) { BoardButton but = sender as BoardButton; if (action == SizeAction.Remove) { if (but.BackColor != Color.Black) { but.BackColor = Color.Black; int row = but.Rows; int column = but.Columns; board[row, column] = 0; } } else { if (but.BackColor == Color.Black) { but.BackColor = Color.Transparent; int row = but.Rows; int column = but.Columns; board[row, column] = 3; } } }
private void But_Click(object sender, EventArgs e) { BoardButton but = sender as BoardButton; if (!CaroService.Winner.CheckExtist(but.Rows, but.Columns)) { but.BackColor = CaroService.Player.CurrentPlayerColor; CaroService.Winner.DrawCaroBoard(but.Rows, but.Columns); CaroService.Action.UpdateTurn(but); if (CaroService.Winner.IsWiner(but.Rows, but.Columns).Result) { Winner(but); } else if (CaroService.Winner.IsEndGame()) { EndGame(); } else { CaroService.Player.Turn = CaroService.Player.Turn + 1; CaroService.Winner.Turn = 1 - CaroService.Winner.Turn; CaroService.Timer.TurnTimer(); } } }
public void InitBoard(int x, int y) { board = new Entity[x, y]; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { if ((i == 0 && j == 0) || (i == 0 && j == y - 1) || (i == x - 1 && j == 0) || (i == x - 1 && j == y - 1)) { board[i, j] = new Entity(i, j, Direction.None, "background"); continue; } if (j == 0) { board[i, j] = new BoardButton(Direction.North, i, j); continue; } if (j == y - 1) { board[i, j] = new BoardButton(Direction.South, i, j); continue; } if (i == 0) { board[i, j] = new BoardButton(Direction.East, i, j); continue; } if (i == x - 1) { board[i, j] = new BoardButton(Direction.West, i, j); continue; } board[i, j] = new Entity(i, j); } } }
private void DrawSizeButtonPanel() { containerPnl = new Panel { Location = new Point(5, 5), Size = new Size(630, 330) }; resizePanel = new ResizePanel(false, true) { Location = new Point(5, 5), Size = new Size(620, 320), BorderStyle = BorderStyle.FixedSingle, MaximumSize = new Size(620, 320), MinimumSize = new Size(115, 115) }; resizePanel.SizeChanged += ResizePanel_SizeChanged; containerPnl.Controls.Add(resizePanel); int X = 20, Y = 20; for (int i = 0; i < Constants.MAX_ROW; i++) { for (int j = 0; j < Constants.MAX_COLUMN; j++) { MaterialFlatButton but = new MaterialFlatButton { Location = new Point(X, Y), Size = new Size(20, 20), Enabled = false }; containerPnl.Controls.Add(but); X += 20; } X = 20; Y += 20; } X = 14; Y = 14; for (int i = 0; i < 15; i++) { for (int j = 0; j < 30; j++) { BoardButton but = new BoardButton { Location = new Point(X, Y), Size = new Size(20, 20), Rows = i, Columns = j }; but.Click += But_Click; resizePanel.Controls.Add(but); X += 20; board[i, j] = 3; butList.Add(new BoardPosition(i, j), but); } X = 14; Y += 20; } this.Controls.Add(containerPnl); }
void Start() { db = FindObjectOfType <Database>(); bb = FindObjectOfType <BoardButton>(); ct = FindObjectOfType <Chattable>(); countDown = 0.3f; realCountDown = 0; lagiLoading = false; }
void Start() { dialogueVers = 0; db = FindObjectOfType <Database>(); bb = FindObjectOfType <BoardButton>(); ac = FindObjectOfType <AudioControls>(); doneTalking = false; StartCoroutine(Type(0)); db.talkedWith = new bool[db.staffCount]; }
public MainWindow() { InitializeComponent(); MessageBoxResult choice = MessageBox.Show( "Want to play with Chess960 rules?", "Chess960", MessageBoxButton.YesNo, //button options MessageBoxImage.Question); this.boardModel = new Board(choice == MessageBoxResult.Yes); Debug.WriteLine(this.boardModel.ToString()); //REMOVE WHEN DONE this.mode = 0; //default start by chosing a piece this.turn = 0; //white starts this.ShowTurn(); this.UpdateDeadPiecesViews(); //initializing the buttonArray this.buttonArray = new BoardButton[Board.GameSize][]; //Change Game size for (int i = 0; i < this.buttonArray.Length; i++) { this.buttonArray[i] = new BoardButton[Board.GameSize]; } //creating the buttons for the board. for (int i = 0; i < this.buttonArray.Length; i++) { for (int j = 0; j < this.buttonArray.Length; j++) { string name = "space" + i + j; BoardSpace correspondingSpace = this.boardModel.GetBoardSpace(i, j); BoardButton presentButton = new BoardButton(i, j, name, correspondingSpace); this.buttonArray[i][j] = presentButton; if (!correspondingSpace.Occupied || correspondingSpace.Piece.Color != this.turn) { presentButton.IsEnabled = false; } int realJ = (j - this.buttonArray.Length + 1) * -1; //to fix grid y axis problem Grid.SetColumn(presentButton, i); Grid.SetRow(presentButton, realJ); this.boardGrid.Children.Add(presentButton); presentButton.AddHandler(BoardButton.ClickEvent, new RoutedEventHandler(boardButton_Click)); //Adding eventHandler } } }
private void UpdateView() { this.ShowTurn(); this.UpdateDeadPiecesViews(); //updating board. for (int i = 0; i < this.buttonArray.Length; i++) { for (int j = 0; j < this.buttonArray.Length; j++) { BoardButton presentButton = this.buttonArray[i][j]; BoardSpace presentSpace = this.boardModel.GetBoardSpace(i, j); //MAYBE REPLACE BY GETTER if (mode == 0) //if mode is now chose piece, we clear the possible destinations. { presentButton.ClearValue(BoardButton.BackgroundProperty); //clears background color presentSpace.IsPossibleDestination = false; } if (presentSpace.IsPossibleDestination) { presentButton.Background = Brushes.Red; } if (!presentSpace.IsPossibleDestination && (!presentSpace.Occupied || presentSpace.Piece.Color != this.turn)) { presentButton.IsEnabled = false; } else { presentButton.IsEnabled = true; } //Condition in case we're in chose destination mode //only destinations and the pressed button are enabled if (this.mode == 1 && !presentSpace.IsPossibleDestination && !presentButton.Equals(this.lastPressed)) { presentButton.IsEnabled = false; } presentButton.Content = presentSpace.GetBoardSpaceChar(); Debug.WriteLine(presentSpace.ToString());//REMOVE } } }
private void boardButton_Click(object sender, RoutedEventArgs e) { //throw new NotImplementedException(); BoardButton clickedButton = sender as BoardButton; Debug.WriteLine(clickedButton.Name);//REMOVE int x = clickedButton.PosX; int y = clickedButton.PosY; BoardSpace clickedSpace = this.boardModel.GetBoardSpace(x, y); if (this.mode == 0) //mode 0 --> chose piece { clickedSpace.Piece.SetDestinations(x, y); this.mode = (this.mode + 1) % 2; this.lastPressed = clickedButton; } else // other mode is chose destinations { if (!clickedButton.Equals(this.lastPressed)) //if button clicked is not the same as before { this.MovePiece(clickedSpace); this.lastPressed = null; //we promote pawns getting to the end fo board if ((y == 0 || y == 7) && clickedSpace.Piece.Type == "pawn") { this.Promote(clickedSpace); } clickedSpace.Piece.PlayedOnce(); //techically redundant, but no harm to efficiency. this.turn = (this.turn + 1) % 2; //. only change turn after destination chosen. } this.mode = (this.mode + 1) % 2; //always change mode. } this.UpdateView(); Debug.WriteLine(this.boardModel.ToString());//REMOVE int winner = this.GameWon(); this.AskForNewGame(winner); }
private void UpdateView() { this.ShowTurn(); this.UpdateDeadPiecesViews(); //aktualizowanie planszy for (int i = 0; i < this.buttonArray.Length; i++) { for (int j = 0; j < this.buttonArray.Length; j++) { BoardButton presentButton = this.buttonArray[i][j]; BoardSpace presentSpace = this.boardModel.GetBoardSpace(i, j); if (mode == 0) //pokazuje mozliwe miejsca docelowe figury. { presentButton.ClearValue(BoardButton.BackgroundProperty); presentSpace.IsPossibleDestination = false; } if (presentSpace.IsPossibleDestination) { presentButton.Background = Brushes.Green; } if (!presentSpace.IsPossibleDestination && (!presentSpace.Occupied || presentSpace.Piece.Color != this.turn)) { presentButton.IsEnabled = false; } else { presentButton.IsEnabled = true; } //w chwili wybrania figury //tylko przycisk i miejsca docelowe sa pokazane if (this.mode == 1 && !presentSpace.IsPossibleDestination && !presentButton.Equals(this.lastPressed)) { presentButton.IsEnabled = false; } presentButton.Content = presentSpace.GetBoardSpaceChar(); Debug.WriteLine(presentSpace.ToString()); } } }
public MainWindow() { InitializeComponent(); this.boardModel = new Board(); Debug.WriteLine(this.boardModel.ToString()); //usuń kiedy sie wykona this.mode = 0; this.turn = 0; //białe zaczynają 0 this.ShowTurn(); this.UpdateDeadPiecesViews(); //initializing the buttonArray this.buttonArray = new BoardButton[Board.GameSize][]; //Change Game size for (int i = 0; i < this.buttonArray.Length; i++) { this.buttonArray[i] = new BoardButton[Board.GameSize]; } //inicjowanie przycisku na planszy. for (int i = 0; i < this.buttonArray.Length; i++) { for (int j = 0; j < this.buttonArray.Length; j++) { string name = "space" + i + j; BoardSpace correspondingSpace = this.boardModel.GetBoardSpace(i, j); BoardButton presentButton = new BoardButton(i, j, name, correspondingSpace); this.buttonArray[i][j] = presentButton; if (!correspondingSpace.Occupied || correspondingSpace.Piece.Color != this.turn) { presentButton.IsEnabled = false; } int realJ = (j - this.buttonArray.Length + 1) * -1; Grid.SetColumn(presentButton, i); Grid.SetRow(presentButton, realJ); this.boardGrid.Children.Add(presentButton); presentButton.AddHandler(BoardButton.ClickEvent, new RoutedEventHandler(boardButton_Click)); } } }
private void boardButton_Click(object sender, RoutedEventArgs e) { //throw new NotImplementedException(); BoardButton clickedButton = sender as BoardButton; Debug.WriteLine(clickedButton.Name);//REMOVE int x = clickedButton.PosX; int y = clickedButton.PosY; BoardSpace clickedSpace = this.boardModel.GetBoardSpace(x, y); if (this.mode == 0) { clickedSpace.Piece.SetDestinations(x, y); this.mode = (this.mode + 1) % 2; this.lastPressed = clickedButton; } else { if (!clickedButton.Equals(this.lastPressed)) { this.MovePiece(clickedSpace); this.lastPressed = null; //zmiana piona po dojsciu do konca planszy if ((y == 0 || y == 7) && clickedSpace.Piece.Type == "pawn") { this.Promote(clickedSpace); } clickedSpace.Piece.PlayedOnce(); this.turn = (this.turn + 1) % 2;//zmiana ruchu po wybraniu miejsca } this.mode = (this.mode + 1) % 2; } this.UpdateView(); Debug.WriteLine(this.boardModel.ToString()); int winner = this.GameWon(); this.AskForNewGame(winner); }
public void DrawCaroBoard() { caroBoardView.Controls.Clear(); caroBoardView.Enabled = true; caroBoard.Clear(); int count = 0; for (int i = 0; i < SettingConfig.Rows; i++) { for (int j = 0; j < SettingConfig.Columns; j++) { if (SettingConfig.BoardPattern[count] != Constants.VOID_POSITION) { BoardButton but = new BoardButton { Size = new Size(Constants.CHESS_WIDTH, Constants.CHESS_HEIGHT), Location = new Point(Constants.CHESS_WIDTH * j, Constants.CHESS_HEIGHT * i), Rows = i, Columns = j }; if (SettingConfig.BoardPattern[count] == Constants.PLAYER1_POSITION) { but.BackColor = CaroService.Player.PlayerColor1; } else if (SettingConfig.BoardPattern[count] == Constants.PLAYER2_POSITION) { but.BackColor = CaroService.Player.PlayerColor2; } but.Click += But_Click; caroBoard.Add(new BoardPosition(i, j), but); caroBoardView.Controls.Add(but); } count++; } } }
private void BuildBoardButton(string boardName, int buttonID) { bool userBoard = boardName.Contains(Database.delimiter); Debug.Log("Building board button " + buttonID + " with name " + boardName); // set GameObject properties GameObject newButton = Instantiate(boardButtonWide); newButton.name = boardName; BoardButton button = newButton.GetComponentInChildren <BoardButton>(); RectTransform trans = newButton.GetComponentInChildren <RectTransform>(); // set position, scale trans.SetParent(viewportContent, false); trans.anchoredPosition = new Vector2(boardButtonLeftPadding, -boardButtonTopPadding + (buttonID + tierButtonCount) * -boardButtonSpace); trans.localScale = Vector3.one; // set the boardname (data) and the display name string ownerUserID = ""; string boardID = ""; string displayName = ""; // get the board's display name and update it for the button displayName = State.GetBoardDisplayName(boardName); button.SetDisplayName(displayName); if (userBoard) { // this is a userboard string[] temp = boardName.Split(Database.delimiter[0]); ownerUserID = temp[0] + Database.delimiter + temp[1]; // 0 is region, 1 is identityID boardID = temp[2]; displayName = temp[3]; if (temp.Length > 4) { if (temp[4] != "") { button.SetStats(metricType.vote, temp[4]); } if (temp[5] != "") { button.SetStats(metricType.play, temp[5]); } if (temp[6] != "") { button.SetStats(metricType.win, temp[6]); } } boardName = boardID + Database.delimiter + displayName; } // update the button's board values button.SetBoardID(boardName); button.SetBoardIdentityID(ownerUserID); // set lock state and boardname for button // remote boards are never locked button.SetLocked(State.gameSource == GameSource.remote ? false : Boardlocked(boardName)); // removed stars (for now) // set the boards star count //if(State.gameSource == GameSource.local) // button.SetStars(BoardStars(boardName)); // removed this to remove ads // build the unlock tier button only when we are getting local boards (story boards) // also, do not build the tier button for players who have self-identified // as being under 15 years of age (don't want to show ads to kids) //if ((buttonID+2) % 4 == 0 && State.gameSource == GameSource.local && State.gameConnected && State.GetAgeFifteenOrOlder()) //{ // Debug.Log("Building Tier Button"); // tierButtonCount++; // GameObject tierButton = Instantiate(unlockTierButton); // tierButton.name = "UnlockTier" + buttonID.ToString() + "Button"; // RectTransform tierTrans = tierButton.GetComponentInChildren<RectTransform>(); // tierTrans.SetParent(viewportContent, false); // tierTrans.anchoredPosition = new Vector2(boardButtonLeftPadding, -boardButtonTopPadding + (buttonID + tierButtonCount) * -boardButtonSpace); // trans.localScale = Vector3.one; // UnlockTierButton unlock = tierButton.GetComponentInChildren<UnlockTierButton>(); // unlock.SetAdTierUnlocks(buttonID); //} }
public DashboardPage ClickBoardsButton() { Thread.Sleep(1000); BoardButton.Click(); return(this); }