public void RemovePlayerPiece(PlayerPiece playerPiece_) { if (playerPiecesList.Contains(playerPiece_)) { playerPiecesList.Remove(playerPiece_); } }
void Start() { //maxHealth = playerBlockParent.childCount; MovementComp = GetComponent <Movement>(); BlockHealthCheck(); highlightSprite = highlightIndicator.GetComponent <SpriteRenderer>(); highlightColor = highlightSprite.color; if (health < maxHealth) { playerPieceLookingForBoy = MovementComp.pieces[(int)health].GetBlockThatGrabsMe(); } SetHighlight(); // Make the throwing indicator invisable before the game starts if (health == 1 && rotationIndicatorIcon.activeSelf == true) { rotationIndicatorIcon.SetActive(false); } else if (health > 1 && rotationIndicatorIcon.activeSelf == false) { rotationIndicatorIcon.SetActive(true); } //instanciate FMOD sound variables/events fModGetPieceEvent = FMODUnity.RuntimeManager.CreateInstance(getPiecesound); }
private void takeWithAiPiece(RaycastHit hit, int moveToXPos, int moveToZPos) { destroyPiece((int)hit.transform.position.x, (int)hit.transform.position.z, moveToXPos, moveToZPos); PlayerPiece piece = gameBoard.returnPlayerPiece((int)hit.transform.position.x, (int)hit.transform.position.z); setPieceHeightAfterMove(piece, (int)hit.transform.position.x, (int)hit.transform.position.z); }
public void MovePieceToNode(PlayerPiece piece, MapNode node) { piece.display.transform.position = node.display.transform.position; piece.currentNode = node; pieces.currentPiece = piece; piece.Visisble = true; }
public void Reset(PlayerPiece firstPlayer) { turnNumber = 1; xTurn.SetActive(true); oTurn.SetActive(false); currentState = firstPlayer; }
public bool FollowForKill(int num, PlayerPiece playerPiece, int followNO) { if (playerPiece.isReady) { _index = GetIndex(playerPiece); for (int i = _index; i <= _index + 6; i++) { if (_index + followNO < pathsParents.redPathPoints.Length) { if (pathsParents.redPathPoints[i].playerPiecesList.Count > 0) { if (pathsParents.redPathPoints[i].playerPiecesList[0].tag == _Blue) { if (num < i - _index) { return(true); } } } } } } _step4 = true; return(false); }
public void MovePieceToNode(Pieces piece, int node_id) { PlayerPiece thePiece = pieces.GetPiece(piece); MapNode node = map.NodeForId(node_id); MovePieceToNode(thePiece, node); }
/// <summary> /// Add player's move to the game board. /// </summary> /// <param name="gameboardPosition"></param> /// <param name="PlayerPiece"></param> public void SetPlayerPiece(GameboardPosition gameboardPosition, PlayerPiece PlayerPiece) { // // Row and column value adjusted to match array structure // Note: gameboardPosition converted to array index by subtracting 1 // switch (gameboardPosition.Layer) { case 1: _firstBoard[gameboardPosition.Row - 1, gameboardPosition.Column - 1] = PlayerPiece; break; case 2: _secondBoard[gameboardPosition.Row - 1, gameboardPosition.Column - 1] = PlayerPiece; break; case 3: _thirdBoard[gameboardPosition.Row - 1, gameboardPosition.Column - 1] = PlayerPiece; break; } // // Change game board state to next player // SetNextPlayer(); }
/// <summary> /// Count linear consecutive pieces /// </summary> private int ConsecutivePieces(PlayerPiece piece, GameboardPosition gameboardPosition, PositionMovement[] movements) { //Max number of pieces to check in any direction from last move const int piecesTocheck = 3; int counter = 1; //Check consecutive linear pieces in each direction for (int j = 0; j < movements.Length; j++) { if (movements[j] != PositionMovement.None) { for (int i = 0; i < piecesTocheck; i++) { if (CheckNextPiece(piece, gameboardPosition, movements[j], i + 1)) { counter = counter + 1; } else { break; } } } } return(counter); }
/// <summary> /// Update the game board state if a player wins or a cat's game happens. /// </summary> public void UpdateGameboardState(int column, Sound applause) { //Get the row index of the most recent move in the column int row = LastMoveInColumn(column); //Create a gameboard position for the most recent move GameboardPosition gameboardPosition = new GameboardPosition(row, column); //Get the piece (X or O) of the most recent move PlayerPiece piece = GetPlayerPieceByGameBoardPosition(gameboardPosition); //Check for a win if (FourInARow(piece, gameboardPosition)) { applause.playSound(); if (piece == PlayerPiece.X) { _currentRoundState = GameboardState.PlayerXWin; } else { _currentRoundState = GameboardState.PlayerOWin; } } //Check if all positions are filled else if (IsCatsGame()) { _currentRoundState = GameboardState.CatsGame; } }
private void move(int tempx, int tempz) { PlayerPiece piece = gameBoard.returnPlayerPiece(startPosX, startPosZ); interactionPiece.transform.position = new Vector3(startPosX, 0.1f, startPosZ); if (MoveDownAndRightRangeCheck(tempx, tempz) && logic.canMoveDownAndRight(startPosX, startPosZ, gameBoard)) { moveDownAndRight(startPosX, startPosZ, interactionPiece); setPieceHeightAfterMove(piece, tempx, tempz); } else if (moveDownAndLeftRangeCheck(tempx, tempz) && logic.canMoveDownAndLeft(startPosX, startPosZ, gameBoard)) { moveDownAndLeft(startPosX, startPosZ, interactionPiece); setPieceHeightAfterMove(piece, tempx, tempz); } else if (moveUpAndRightRangeCheck(tempx, tempz) && logic.canMoveUpAndRight(startPosX, startPosZ, gameBoard)) { moveUpAndRight(startPosX, startPosZ, interactionPiece); setPieceHeightAfterMove(piece, tempx, tempz); } else if (moveUpAndLeftRangeCheck(tempx, tempz) && logic.canMoveUpAndLeft(startPosX, startPosZ, gameBoard)) { moveUpAndLeft(startPosX, startPosZ, interactionPiece); setPieceHeightAfterMove(piece, tempx, tempz); } else { interactionPiece.transform.position = new Vector3(startPosX, 0.1f, startPosZ); setPieceHeightAfterMove(piece, startPosX, startPosZ); } }
public bool DeletePawn(PlayerPiece _P, int num) { if (_P.isReady) { _index = GetIndex(_P); _index = _index + num; if (currentPathPoint != null && currentPathPoint.tag != "Home") { if (_index <= pathsParent.redPathPoints.Length) { if (pathsParent.bluePathPoints[_index].playerPiecesList.Count == 1) { if (pathsParent.bluePathPoints[_index].playerPiecesList[0].tag == "Red" && pathsParent.bluePathPoints[_index].tag != "SafeState") { ResetToken(pathsParent.bluePathPoints[_index].playerPiecesList[0], pathsParent.bluePathPoints[_index]); //StartCoroutine(StartBlue(3, false)); return(true); } } } } } return(false); }
public void SetPiece(PlayerPiece piece, Material mat) { ownerMesh.material = mat; playerPiece = piece; hasPiece = true; animator.SetBool("HasOwner", true); }
public void FlipPiece(int x, int y, int newPlayerCode) { Debug.Assert(pieces[x, y] != null); PlayerPiece p = pieces[x, y]; var punchTween = p.transform.DOScale(new Vector3(0, 1.5f, 1f), 0.15f); // //After the punch make sure it resets to the original scale. punchTween.OnComplete(() => { if (newPlayerCode == 0) { p.mainSprite.color = playerOneColor; p.outlineSprite.color = playerOneAccent; } else { p.mainSprite.color = playerTwoColor; p.outlineSprite.color = playerTwoAccent; } p.SetShape(newPlayerCode); p.transform.DOScale(Vector3.one, 0.15f); }); }
public void Focus() { focusOnSlot = true; List <Slot> possibleSlots = new List <Slot>(); for (int i = 0; i < GameManager.gm.gridSize; i++) { for (int j = 0; j < GameManager.gm.gridSize; j++) { Slot slot = GameManager.gm.grid.GetSlot(i, j, 0); if (!slot.IsVacant) { possibleSlots.Add(slot); } } } if (possibleSlots.Count > 0) { Slot choosenSlot = possibleSlots[Random.Range(0, possibleSlots.Count)]; desiredPosition = choosenSlot.pieceCenter.position; desiredPosition.y = alienShip.position.y; absorbedPiece = choosenSlot.GetPlayerPiece(); } else { ResumeAnimation(); } }
private void onMovePathDone() { PlayerPiece currentPiece = team.getActivePiece(); // TODO: treasures on path PlayersManager.Instance.onPlayerTurnDone(); }
public void sortPath(PlayerPiece piece) { BoardCell currentCell = piece.currentCell; List <BoardCell> remainingCells = new List <BoardCell>(piece.moveCells); List <BoardCell> orderedCells = new List <BoardCell>(); while (!remainingCells.IsEmpty()) { IEnumerable <BoardCell> adjCells = remainingCells.Where(c => (c.leftCell == currentCell) || (c.rightCell == currentCell) || (c.upCell == currentCell) || (c.downCell == currentCell)); if (adjCells.Count() == 0) { break; } currentCell = adjCells.First(); if (currentCell == null) { break; } remainingCells.Remove(currentCell); orderedCells.Add(currentCell); } piece.moveCells = orderedCells; }
public void CheckForAIMove() { int count = 0; foreach (PlayerPiece _p in blueHome.playerPieces) { if (_p.canMove && _p.isReady) { if (isPathPointsAvailableToMove(blueHomeRollingDice.numberGot, _p.numberOfStepsAlreadyMoved, pathsParent.bluePathPoints)) { temp = _p; count += 1; } } } if (count == 1 && isReady) { if (isPathPointsAvailableToMove(blueHomeRollingDice.numberGot, numberOfStepsAlreadyMoved, pathsParent.bluePathPoints)) { MoveSteps(pathsParent.bluePathPoints); } } else if (count == 0 && diceManager.AreHome(blueHome.playerPieces) == true) { movementDone = true; GameManager.gm.State(this); } }
/// <summary> /// Update the game board state if a player wins or a cat's game happens. /// </summary> /// <param name="winner">The winning player of the game.</param> public void UpdateGameboardState(out PlayerPiece winner) { // // Player X has won // if (ThreeInARow(PlayerPiece.X)) { _currentRoundState = GameboardState.PlayerXWin; winner = PlayerPiece.X; } // // A player O has won // else if (ThreeInARow(PlayerPiece.O)) { _currentRoundState = GameboardState.PlayerOWin; winner = PlayerPiece.O; } // // All positions filled // else if (IsCatsGame()) { _currentRoundState = GameboardState.CatsGame; winner = PlayerPiece.None; } // Other situation else { winner = PlayerPiece.None; } }
/// <summary> /// sets the highlight visual to the next position available or hides it if it's not /// </summary> void SetHighlight() { if (!catchingIsStopped) { if (health >= maxHealth || health <= 0) { highlightIndicator.SetActive(false); // Set the indicator to invisable if the player is dead or if its at max health playerPieceLookingForBoy = null; pieceForThrow = MovementComp.pieces[(int)health - 1].GetBlockThatGrabsMe(); } else { highlightIndicator.SetActive(true); // set the indicator to be visable of there the player's health is not at max Transform nextBlock = playerBlockParent.GetChild((int)health); highlightIndicator.transform.position = nextBlock.position; // set the highlight to be placed at the position of the next block playerPieceLookingForBoy = MovementComp.pieces[(int)health].GetBlockThatGrabsMe(); pieceForThrow = MovementComp.pieces[(int)health - 1].GetBlockThatGrabsMe(); ChangeHighlightSprite(); } } else { highlightIndicator.SetActive(false); } }
public void InsertPieceData(int id, int position = 0) { try { Piece p = new Piece { Position = position, PlayerPieceID = id }; Context.Piece.Add(p); Context.SaveChanges(); PlayerPiece playerP = new PlayerPiece { PlayerId = PlayerId, //giving same player id to forein key PieceId = p.PieceID, // giving same piece id to foreign key }; Context.PlayerPiece.Add(playerP); Context.SaveChanges(); Console.Beep(500, 70); } catch (Exception) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("OBS, Pieces could not save in database\n"); Console.ResetColor(); Console.Beep(900, 900); } }
//killing pieces IEnumerator revertOnStart(PlayerPiece playerPiece_) { if (playerPiece_.name.Contains("Rose")) { GameManager.gm.roseOutPlayers -= 1; pathpointToMoveon_ = pathObjParent.rosePathPoint; Debug.Log("rose"); } else if (playerPiece_.name.Contains("Blue")) { GameManager.gm.blueOutPlayers -= 1; pathpointToMoveon_ = pathObjParent.bluePathPoint; Debug.Log("bleu"); } else if (playerPiece_.name.Contains("orange")) { GameManager.gm.orangeOutPlayers -= 1; pathpointToMoveon_ = pathObjParent.orangePathPoint; Debug.Log("orange"); } else if (playerPiece_.name.Contains("violet")) { GameManager.gm.violetOutPlayers -= 1; pathpointToMoveon_ = pathObjParent.violetPathPoint; Debug.Log("violet"); } for (int i = playerPiece_.numberOfStepsAlreadyMoved; i >= 0; i--) { playerPiece_.transform.position = pathpointToMoveon_[i].transform.position; yield return(new WaitForSeconds(0.02f)); } playerPiece_.transform.position = pathObjParent.BasePoint[BasePointPosition(playerPiece_.name)].transform.position; }
public bool AddPlayerPiece(PlayerPiece playerPiece_) { if (this.name == "CenterHomePoint") { Compled(playerPiece_); } if (this.name != "PathPoint" && this.name != "PathPoint (8)" && this.name != "PathPoint (13)" && this.name != "PathPoint (21)" && this.name != "PathPoint (26)" && this.name != "PathPoint (34)" && this.name != "PathPoint (39)" && this.name != "PathPoint (47)" && this.name != "CenterHomePoint") { if (playerPiecesList.Count == 1) { string preePlayerPiceName = playerPiecesList[0].name; string curntPlayerPiceName = playerPiece_.name; curntPlayerPiceName = curntPlayerPiceName.Substring(0, curntPlayerPiceName.Length - 4); if (!preePlayerPiceName.Contains(curntPlayerPiceName)) { playerPiecesList[0].isReady = false; StartCoroutine(revertOnStart(playerPiecesList[0])); playerPiecesList[0].numberOfStepsAlreadyMoved = 0; RemovePlayerPiece(playerPiecesList[0]); playerPiecesList.Add(playerPiece_); return(false); } } } AddPlayer(playerPiece_); return(true); }
private void Compled(PlayerPiece playerPiece_) { if (playerPiece_.name.Contains("Rose")) { GameManager.gm.roseCompletePlayers += 1; GameManager.gm.roseOutPlayers -= 1; if (GameManager.gm.roseCompletePlayers == 4) { ShowCelibration(); } } else if (playerPiece_.name.Contains("Blue")) { GameManager.gm.blueCompletePlayers += 1; GameManager.gm.blueOutPlayers -= 1; if (GameManager.gm.blueCompletePlayers == 4) { ShowCelibration(); } } else if (playerPiece_.name.Contains("Orange")) { GameManager.gm.orangeCompletePlayers += 1; GameManager.gm.orangeOutPlayers -= 1; if (GameManager.gm.orangeCompletePlayers == 4) { ShowCelibration(); } } else if (playerPiece_.name.Contains("Violet")) { GameManager.gm.violetCompletePlayers += 1; GameManager.gm.violetOutPlayers -= 1; if (GameManager.gm.violetCompletePlayers == 4) { ShowCelibration(); } } }
//move to piece back to its original location public void ResetPiece(PlayerPiece p) { if (p != null) { p.transform.position = pieceList[p.x][p.y].MoveToLocation.position; } }
private void moveUpAndLeft(int x, int y, GameObject playerPiece) { if (logic.canMoveUpAndLeft(x, y, gameBoard)) { PlayerPiece piece = gameBoard.returnPlayerPiece(x, y); updateGameBoardOnMove(x, y, -1, -1, piece.playerNo, playerPiece, piece); } }
private void transformPieceToKing(PlayerPiece piece, GameObject playerPiece) { piece.isKing = true; playerPiece.transform.localScale = new Vector3(1.0f, 0.4f, 1.0f); playerPiece.transform.localPosition = new Vector3(playerPiece.transform.localPosition.x, 0.4f, playerPiece.transform.localPosition.z); changePlayer(); pieceChangedToKing = true; }
private void Start() { temp = GetComponent <PlayerPiece>(); _movePcOnce = true; blueHome = GetComponentInParent <BlueHome>(); blueHomeRollingDice = blueHome.rollingDice; diceManager = GameObject.Find("DiceManager").GetComponent <DiceManager>(); }
/// <summary> /// Check for any three in a row. /// </summary> /// <param name="playerPieceToCheck">Player's game piece to check</param> /// <returns>true if a player has won</returns> private bool ThreeInARow(PlayerPiece playerPieceToCheck) { // // Check rows for player win // for (int row = 0; row < 3; row++) { if (_positionState[row, 0] == playerPieceToCheck && _positionState[row, 1] == playerPieceToCheck && _positionState[row, 2] == playerPieceToCheck && _positionState[row, 3] == playerPieceToCheck) { return(true); } } // // Check columns for player win // for (int column = 0; column < 3; column++) { if (_positionState[0, column] == playerPieceToCheck && _positionState[1, column] == playerPieceToCheck && _positionState[2, column] == playerPieceToCheck && _positionState[3, column] == playerPieceToCheck) { return(true); } } // // Check diagonals for player win // if ( (_positionState[0, 0] == playerPieceToCheck && _positionState[1, 1] == playerPieceToCheck && _positionState[2, 2] == playerPieceToCheck && _positionState[3, 3] == playerPieceToCheck) || (_positionState[0, 3] == playerPieceToCheck && _positionState[1, 2] == playerPieceToCheck && _positionState[2, 1] == playerPieceToCheck && _positionState[3, 0] == playerPieceToCheck) ) { return(true); } // // No Player Has Won // return(false); }
public void Add(PlayerPiece pp_) //Add a player by its playerID { size++; ContainingPieces[pp_.PlayerID] = pp_; pp_.CurrentBin = this; //Move the player peice here RefactorPeices(); }
public void Init( List<GameObject> piecePrefabs ) { pieces = new List<PlayerPiece> () ; for ( int i = 0; i < 5; i++ ) { GameObject display = Instantiate ( piecePrefabs [ i ] ) as GameObject ; PlayerPiece piece = new PlayerPiece () ; piece.Init ( (Pieces)i, display ) ; piece.Visisble = false ; pieces.Add ( piece ) ; } }
public void SetPlayerPiece(GameboardPosition gameboardPosition, PlayerPiece PlayerPiece) { // // Row and column value adjusted to match array structure // _positionState[gameboardPosition.Row - 1, gameboardPosition.Column - 1] = PlayerPiece; }
private bool ThreeInARow(PlayerPiece playerPieceToCheck) { // // Check rows for player win // for (int row = 0; row < 3; row++) { if (_positionState[row, 0] == playerPieceToCheck && _positionState[row, 1] == playerPieceToCheck && _positionState[row, 2] == playerPieceToCheck) { return true; } } // // Check columns for player win // for (int column = 0; column < 3; column++) { if (_positionState[0, column] == playerPieceToCheck && _positionState[1, column] == playerPieceToCheck && _positionState[2, column] == playerPieceToCheck) { return true; } } // // Check diagonals for player win // if ( (_positionState[0, 0] == playerPieceToCheck && _positionState[1, 1] == playerPieceToCheck && _positionState[2, 2] == playerPieceToCheck) || (_positionState[0, 2] == playerPieceToCheck && _positionState[1, 1] == playerPieceToCheck && _positionState[2, 0] == playerPieceToCheck) ) { return true; } // // No Player Has Won // return false; }
public PlayerPiece FindHighestInfulenceSurvivor(PlayerPiece[] excludingList) { return PlayerPositions.FindWithHighestInfluence(excludingList); }
/// <summary> /// Adds the player piece to the location, if applicaple. /// </summary> /// <returns><c>true</c>, if player piece was added, <c>false</c> otherwise.</returns> /// <param name="newPiece">New piece to add to this location.</param> public bool AddPlayerPiece(PlayerPiece newPiece) { return PlayerPositions.Queue(newPiece); }
/// <summary> /// Removes the survivor piece passed from the player positions. /// </summary> /// <param name="survivorToRemove">Survivor to remove from player positions.</param> /// <returns><c>true</c>, if survivor piece was removed, <c>false</c> otherwise.</returns> public bool RemoveSurvivorPiece(PlayerPiece survivorToRemove) { return PlayerPositions.Remove(survivorToRemove) != null; }