/// <summary> /// Highlights the list of tiles in a caboose. /// </summary> public void HighlightCaboose( CabooseList l ) { //Highlight caboose foreach ( Tile t in l.list ) t.HighlightSelectedAbilityPiece ( ); //Highlight destination l.destination.HighlightSelectedMove ( ); }
/// <summary> /// Uses the Caboose ability by moving each piece in the caboose forward. /// </summary> public void UseCaboose( CabooseList l, Info info ) { //Store animation Sequence s = DOTween.Sequence ( ); //Move each piece in the caboose for ( int i = l.list.Count - 1; i > -1; i-- ) { //Store destination Tile t = l.list [ i ]; Tile d = l.list [ i ].neighbors [ l.direction ]; //Update tile and piece references t.currentPiece.currentTile = d; d.currentPiece = t.currentPiece; t.currentPiece = null; //Move the piece s.Insert ( 0, d.currentPiece.transform.DOMove ( d.transform.position, ANIMATE_TIME ) ); } //End turn s.OnComplete ( () => { //Clear caboose info info.cabooseList.Clear ( ); info.selectedCaboose = null; info.multiCabooseTile = false; //End turn info.EndTurn ( ); } ); }
/// <summary> /// Check if there is a viable setup for using the Caboose ability. /// </summary> public void GetCaboose( Info info ) { //Clear caboose list info.cabooseList.Clear ( ); //Find the current player's pieces foreach ( Tile t in info.board ) { //Check for the player's pieces if ( t.currentPiece == null || t.currentPiece.owner != info.currentPlayer || t.currentPiece.color == PieceColor.White ) continue; //Store direction int start, end; //Check player if ( t.currentPiece.owner == info.player1 ) { //Section off tiles to move right start = 2; end = 6; } else { //Section off tiles to move left start = 0; end = 4; } //Check each direction for ( int i = start; i < end; i++ ) { //Check for tile if ( t.neighbors [ i ] == null || t.neighbors [ i ].currentPiece == null || t.neighbors [ i ].currentPiece.owner == info.opponent || t.neighbors [ i ].currentPiece.color == PieceColor.White ) continue; //Store the number of friendly pieces in a line int count = CabooseNeighborChecker ( t.neighbors [ i ], i , info.currentPlayer, 1 ); //Check count if ( count > 1 ) { //Check if the front of the line has a open space for movement switch ( count ) { case 2: //Check tile if ( t.neighbors [ i ].neighbors [ i ].neighbors [ i ] != null && t.neighbors [ i ].neighbors [ i ].neighbors [ i ].currentPiece == null ) { //Store caboose CabooseList l = new CabooseList ( ); l.list.Add ( t ); l.list.Add ( t.neighbors [ i ] ); l.list.Add ( t.neighbors [ i ].neighbors [ i ] ); //Store direction l.direction = i; //Store destination l.destination = t.neighbors [ i ].neighbors [ i ].neighbors [ i ]; //Add caboose to list info.cabooseList.Add ( l ); //Highlight tile t.HighlightAbilityPieceSelection ( ); } break; case 3: //Check tile if ( t.neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ] != null && t.neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ].currentPiece == null ) { //Store caboose CabooseList l = new CabooseList ( ); l.list.Add ( t ); l.list.Add ( t.neighbors [ i ] ); l.list.Add ( t.neighbors [ i ].neighbors [ i ] ); l.list.Add ( t.neighbors [ i ].neighbors [ i ].neighbors [ i ] ); //Store direction l.direction = i; //Store destination l.destination = t.neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ]; //Add caboose to list info.cabooseList.Add ( l ); //Highlight tile t.HighlightAbilityPieceSelection ( ); } break; case 4: //Check tile if ( t.neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ] != null && t.neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ].currentPiece == null ) { //Store caboose CabooseList l = new CabooseList ( ); l.list.Add ( t ); l.list.Add ( t.neighbors [ i ] ); l.list.Add ( t.neighbors [ i ].neighbors [ i ] ); l.list.Add ( t.neighbors [ i ].neighbors [ i ].neighbors [ i ] ); l.list.Add ( t.neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ] ); //Store direction l.direction = i; //Store destination l.destination = t.neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ]; //Add caboose to list info.cabooseList.Add ( l ); //Highlight tile t.HighlightAbilityPieceSelection ( ); } break; case 5: //Check tile if ( t.neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ] != null && t.neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ].currentPiece == null ) { //Store caboose CabooseList l = new CabooseList ( ); l.list.Add ( t ); l.list.Add ( t.neighbors [ i ] ); l.list.Add ( t.neighbors [ i ].neighbors [ i ] ); l.list.Add ( t.neighbors [ i ].neighbors [ i ].neighbors [ i ] ); l.list.Add ( t.neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ] ); l.list.Add ( t.neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ] ); //Store direction l.direction = i; //Store destination l.destination = t.neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ].neighbors [ i ]; //Add caboose to list info.cabooseList.Add ( l ); //Highlight tile t.HighlightAbilityPieceSelection ( ); } break; } } } } }