void ButtonClicked(ButtonXO bttn) { ButtonXO tl = boardUI[bttn.pos.X - 1, bttn.pos.Y - 1]; ButtonXO tr = boardUI[bttn.pos.X - 1, bttn.pos.Y + 1]; ButtonXO bl = boardUI[bttn.pos.X + 1, bttn.pos.Y - 1]; ButtonXO br = boardUI[bttn.pos.X + 1, bttn.pos.Y + 1]; if (!hasButtonBeenPicked) { //ControllerGameClient.singleton.SendPlayPacket(bttn.pos.X, bttn.pos.Y); ControllerGameClient.singleton.SendMoveCheck(bttn.pos.X, bttn.pos.Y, bttn.isKingged); previousBttn = boardUI[bttn.pos.X, bttn.pos.Y]; SetSelected(previousBttn.GetComponent <Button>()); hasButtonBeenPicked = true; } else { SetUnSelected(tl.GetComponent <Button>()); SetUnSelected(tr.GetComponent <Button>()); SetUnSelected(bl.GetComponent <Button>()); SetUnSelected(br.GetComponent <Button>()); SetUnSelected(previousBttn.GetComponent <Button>()); hasButtonBeenPicked = true; } }
private void BuildBoardUI() { boardUI = new ButtonXO[columns, rows];//instantiating array for buttons for (int x = 0; x < columns; x++) { for (int y = 0; y < rows; y++) { ButtonXO bttn = Instantiate(bttnPrefab, panelGameBoard); bttn.Init(new GridPOS(x, y), () => { ButtonClicked(bttn); });//we can control what this button does from the controller script where we instantiate the button boardUI[x, y] = bttn; } } }
void BuildBoardUI() { boardUI = new ButtonXO[columns, rows]; // instantiating array for buttons for (int x = 0; x < columns; x++) { for (int y = 0; y < rows; y++) { ButtonXO bttn = Instantiate(bttnPrefab, panelGameBoard); bttn.Init(new GridPOS(x, y), () => { ButtonClicked(bttn); }); boardUI[x, y] = bttn; } } }
private void BuildBoardUI() { boardUI = new ButtonXO[coloms, rows]; for (int x = 0; x < coloms; x++) { for (int y = 0; y < rows; y++) { ButtonXO bttn = Instantiate(bttnPrefab, panelGameboard); bttn.init(new GridPOS(x, y), () => ButtonClicked(bttn)); boardUI[x, y] = bttn; } } }
private void BuildBoardUI() { boardUI = new ButtonXO[columns, rows]; // instantiating array for buttons for (int x = 0; x < columns; x++) { for (int y = 0; y < rows; y++) { ButtonXO bttn = Instantiate(bttnPrefab, panelGameBoard); bttn.Init(new GridPOS(x, y), () => { ButtonClicked(bttn); }); // anonymous functions have access to all variables in their scope when declared boardUI[x, y] = bttn; } } }
int CheckForPlayerPuck(ButtonXO bttn) { int isPlayerPuckHere = 0; if (boardUI[bttn.pos.X, bttn.pos.Y].image.sprite == emptySpace) { return(isPlayerPuckHere = 0); } if (boardUI[bttn.pos.X, bttn.pos.Y].image.sprite == blackSpace) { return(isPlayerPuckHere = 1); } if (boardUI[bttn.pos.X, bttn.pos.Y].image.sprite == redSpace) { return(isPlayerPuckHere = 2); } return(isPlayerPuckHere); }
void ButtonClicked(ButtonXO bttn) { ControllerGameClient.singleton.SendPlayPacket(bttn.pos.X, bttn.pos.Y); }
void ButtonClicked(ButtonXO bttn) { //print("A BUTTON WAS CLICKED"); print($"a button was clicked{bttn.pos}"); ControllerGameClient.singleTon.SendPlayPacket(bttn.pos.X, bttn.pos.Y); }
void ButtonClicked(ButtonXO bttn) { //print($"a button was clicked {bttn.pos.X}, {bttn.pos.Y}"); ControllerGameClient.singleton.SendPlayPacket(bttn.pos.X, bttn.pos.Y); }
void ButtonClicked(ButtonXO bttn) { //print($"X:{bttn.pos.X} Y:{bttn.pos.Y} was clicked"); // print($"Button was clicked. {bttn.pos} "); ControllerGameClient.singleton.SendPlayPacket(bttn.pos.X, bttn.pos.Y); }