private void ExitState() { this.enabled = false; tileHighlight.SetActive(false); GameManager.instance.DeselectPiece(movingPiece); movingPiece = null; TileSelector selector = GetComponent <TileSelector>(); GameManager.instance.NextPlayer(); selector.EnterState(); }
private void ExitState() { this.enabled = false; numOfAttackTiles = 0; tileHighlight.SetActive(false); GameManager.instance.DeselectPiece(movingPiece); movingPiece = null; availableMoves.Clear(); TileSelector selector = GetComponent <TileSelector>(); selector.EnterState(); }
private void CancelMove() { enabled = false; foreach (GameObject highlight in locationHighlights) { Destroy(highlight); } TileSelector selector = GetComponent <TileSelector>(); selector.EnterState(); }
private void CancelMove() { this.enabled = false; foreach (GameObject highlight in locationHighlights) { Destroy(highlight); } GameManager.instance.DeselectPiece(movingPiece); TileSelector selector = GetComponent <TileSelector>(); selector.EnterState(); }
void ExitState() { this.enabled = false; tileHighlight.SetActive(false); GameManager.instance.DeselectPiece(movingPiece); movingPiece = null; TileSelector selector = GetComponent <TileSelector>(); GameManager.instance.NextPlayer(); selector.EnterState(); foreach (GameObject hightlight in localtionHighlights) { Destroy(hightlight); } }
// cleans up current state private void ExitState() { this.enabled = false; attackHighlight.SetActive(false); foreach (GameObject highlight in attackLocationHighlights) { Destroy(highlight); } TileSelector selector = GetComponent <TileSelector>(); // switch turns, then go back to selecting GameManager.instance.NextPlayer(); selector.EnterState(); }
private void ExitState() { this.enabled = false; tileHighlight.SetActive(false); GameManager.instance.DeselectPiece(movingPiece); movingPiece = null; //below two lines are calling on the tile selector .cs file, getting the component and telling it to enter the 'select tile' state. TileSelector selector = GetComponent <TileSelector>(); GameManager.instance.NextPlayer(); selector.EnterState(); foreach (GameObject highlight in locationHighlights) { Destroy(highlight); } }
private void ReturnToSelect(int tileCheck = 0) { enabled = false; tileHighlight.SetActive(false); GameManager.instance.DeselectPiece(movingPiece); movingPiece = null; if (tileCheck != -1) { myTileSelector.EnterState(); } else { otherTileSelector.EnterState(); } foreach (GameObject highlight in locationHighlights) { Destroy(highlight); } }
public void InitiateChase(GameObject pieceToCapture) { GameState = GameStates.CHASE; chaseOrigin = Geometry.GridFromPoint(pieceToCapture.transform.position); chessPieces = pieces; chasePieces = new GameObject[8, 8]; //Turn all chess pieces off ToggleActivePieces(); defender = pieceToCapture; if (currentPlayer.playerNumber == 1) { attacker = p1CurrentlySelected; } else { attacker = p2CurrentlySelected; } attackerOrigin = Geometry.GridFromPoint(attacker.transform.position); SetChaseLocation(attacker, currentPlayer.playerNumber); SetChaseLocation(defender, otherPlayer.playerNumber); SetSurvivalPieces(attacker, defender); SetPieces(); //Turn on only survival piecesS ToggleActivePieces(); player1TileSelector.EnterState(); player2TileSelector.EnterState(); StartCoroutine(ChaseCountDown()); }
// Update is called once per frame void Update() { //think of this like a light ray that extends out from the point of the camera. //The great thing about this is that whatever you see through that camera, is the same as these rays extending from it. //when you find the ray that intersects with the mouse position, you are essentially clicking on the exact thing that //it looks like the mouse is hovering over, from your perspective. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; //if the ray hits an object if (Physics.Raycast(ray, out hit)) { Vector3 point = hit.point; Vector2Int gridPoint = Geometry.GridFromPoint(point); tileHighlight.SetActive(true); tileHighlight.transform.position = Geometry.PointFromGrid(gridPoint); if (Input.GetMouseButtonDown(0)) { //here is where I need to select the deselector for pieces. //two tasks. 1 is to correctly initiate an if only when the current piece is selected. //two is to reset selection position to what it was before I was in move selector area. //one way of doing part one would be to add it as a move option, but if true, instead of moving, you do a different if? //Checks to see if the gridpoint of the piece clicked on matchess the gridpoint of the current piece if (gridPoint == GameManager.instance.GridForPiece(movingPiece)) { Debug.Log("Much success"); this.enabled = false; tileHighlight.SetActive(false); GameManager.instance.DeselectPiece(movingPiece); movingPiece = null; //below two lines are calling on the tile selector .cs file, getting the component and telling it to enter the 'select tile' state. TileSelector selector = GetComponent <TileSelector>(); selector.EnterState(); foreach (GameObject highlight in locationHighlights) { Destroy(highlight); } } else { if (!moveLocations.Contains(gridPoint)) { return; } if (GameManager.instance.PieceAtGrid(gridPoint) == null) { //if moving to empty point GameManager.instance.Move(movingPiece, gridPoint); } else { //if moving to point with enemy piece, capture it GameManager.instance.CapturePieceAt(gridPoint); GameManager.instance.Move(movingPiece, gridPoint); } ExitState(); } //alternatively it should be above all the below if statements, and it should be a direct check of gridpoint against gridpoint of currentpiece } } else { tileHighlight.SetActive(false); } }