예제 #1
0
    /// <summary>
    /// If forced a roll
    /// </summary>
    /// <param name="node"></param>
    private IEnumerator ForcedWayAction(TileNode node)
    {
        PieceMove requestedMove = new PieceMove(firstSelection, new MoveSet.Move(firstSelection, false, node), moves);

        if (requestedMove.Execute())
        {
            moveHistory.Add(requestedMove);
            GameObject.Find("MoveHistoryPanel").GetComponent <MoveHistoryHandler>().addMove(moveHistory[moveHistory.Count - 1]);

            // unhighlight the way moves
            foreach (TileNode moveTile in moves)
            {
                moveTile.unhighlight();
            }

            if (requestedMove.Result == PieceMove.ResultType.Win)
            {
                SceneManager.LoadScene("EndMenu");
            }

            // Wait for overstack
            yield return(new WaitUntil(() => OverstackUI.done));

            state          = State.Playing;
            firstSelection = null;
            NextTurn();
        }
    }
예제 #2
0
    /// <summary>
    /// if playing state then this is called
    /// </summary>
    /// <param name="node">A selected tilenode</param>
    private void PlayingAction(TileNode node)
    {
        // no tile selected
        if (firstSelection == null)
        {
            #region first Selection
            // check if the selected tower is valid for the player's turn
            if (node.tower != null && node.tower.owningColour == players[turnIndex].colour)
            {
                firstSelection = node;

                // for a valid tower, highlight the legal moves for it.
                foreach (TileNode moveTile in node.tower.GetMoves().Destinations)
                {
                    moveTile.highlight();
                }
            }
            #endregion

            // player has selected a tower already (first selection)
        }
        else
        {
            #region second selection

            // fix attempt for mystery firstSelection not clearing
            TileNode cfirstSelection = this.firstSelection;
            this.firstSelection = null;

            PieceTower tower = cfirstSelection.tower;
            moves = tower.GetMoves().Destinations;

            // unhighlights the legal moves from the first selected tower
            foreach (TileNode moveTile in moves)
            {
                moveTile.unhighlight();
            }

            // request move to the next selected tile.
            PieceMove requestedMove = new PieceMove(cfirstSelection, tower.GetMoves().GetMoveObject(node), moves);

            // requestMove.Execute() both validates and execute it.
            if (requestedMove.Execute() == true)
            {
                // add the requested move (its a legal move) to the history
                moveHistory.Add(requestedMove);
                GameObject.Find("MoveHistoryPanel").GetComponent <MoveHistoryHandler>().addMove(moveHistory[moveHistory.Count - 1]);

                // Tower came off of the edge tile
                if (cfirstSelection.type == TileNode.Type.Edge && requestedMove.dest.type != TileNode.Type.Edge)
                {
                    placementTiles.Add(cfirstSelection);
                }

                StartCoroutine(HandleRequestResult(requestedMove.GetResult(), node, tower));
            }

            // reset the selection
            firstSelection = null;

            #endregion
        }
    }
예제 #3
0
파일: CastleMove.cs 프로젝트: Beeboh/Chess
 public override void Execute()
 {
     PieceMove.Execute();
     RookMove.Execute();
 }