Esempio n. 1
0
    public void ToNextStep(Piece[,] board, int[,] quantums)
    {
        showTheBoard(board, quantums);

        PieceSelection goTo = GetComponent <PieceSelection>();

        goTo.Activate();
    }
Esempio n. 2
0
    private void Cancel()
    {
        Disactivate();

        PieceSelection goTo = GetComponent <PieceSelection>();

        goTo.Activate();
    }
    void addEventListeners()
    {
        mainController = GameObject.Find("Maincontroller");
        pieceSelection = mainController.GetComponent <PieceSelection>();

        pieceSelection.onPieceClicked += BeginMovement;
        pieceSelection.onPieceDropped += PieceDropped;
    }
Esempio n. 4
0
        private void _selectCursorPiece(PieceColor currentPlayer)
        {
            var coordinates          = _cursor.getCoordinates();
            var piece                = _grid[coordinates.Item1, coordinates.Item2];
            var isCurrentPlayerPiece = piece.Color == currentPlayer;

            if (isCurrentPlayerPiece)
            {
                var validMoveOptions = _filterValidMoves(piece);
                PieceSelection = new PieceSelection(piece, validMoveOptions);
            }
            else
            {
                PieceSelection = NullPieceSelection.GetInstance();
            }
        }
Esempio n. 5
0
    public override GameAction act()
    {
        //if ( Input.GetMouseButtonDown(0) )
        if ( Input.touches.Length == 1 )
        {
          Touch touchedFinger = Input.touches[0]; // Get input of touches
          if ( touchedFinger.phase == TouchPhase.Ended )
          //if ( true )
          {
            m_Ray = Camera.main.ScreenPointToRay( touchedFinger.position );
            //m_Ray = Camera.main.ScreenPointToRay ( Input.mousePosition );

            if (Physics.Raycast(m_Ray.origin, m_Ray.direction,
                                    out m_RayCastHit, Mathf.Infinity))
            {
                GameAction incoming = null;
                switch (m_RayCastHit.transform.tag)
                {
                    case "Attacker":
                        Piece touchedAttacker = m_RayCastHit.collider.gameObject.GetComponent<Piece>();
                        incoming = new PieceSelection(touchedAttacker.index, true);
                        break;

                    case "Defender":
                    case "King":
                        Piece touchedDefender = m_RayCastHit.collider.gameObject.GetComponent<Piece>();
                        incoming = new PieceSelection(touchedDefender.index, false);
                        break;

                    case "Square":
                        if (Game.turnState == TurnState.PIECE_SELECTED)
                        {
                            Square touchedSquare = m_RayCastHit.collider.gameObject.GetComponent<Square>();
                            incoming = new PieceMove(touchedSquare.coord);
                        }else
                            Game.audio.playError ();
                        break;
                }
                return incoming;
            }else
                Game.audio.playError ();
          }
        }
        return null;
    }
Esempio n. 6
0
 void Start()
 {
     this.pieceSelection   = this.gameObject.GetComponent <PieceSelection> ();
     this.actionResolution = this.gameObject.GetComponent <ActionResolution> ();
 }
Esempio n. 7
0
    public override GameAction act()
    {
        // Do RayCast
        m_Ray = new Ray (m_Camera.position, m_Camera.forward);
        //m_Ray = Camera.main.ScreenPointToRay ( Input.mousePosition );

        Selectable newSelectable = null;
        if ( Physics.Raycast ( m_Ray.origin, m_Ray.direction, out m_RayCastHit, Mathf.Infinity ) )
            newSelectable = m_RayCastHit.collider.gameObject.GetComponent<Selectable>();

            // Check change of pointed object
        if ( (selectablePointed && ! selectablePointed.Equals ( newSelectable )) ||
             (! selectablePointed && newSelectable ) 							 )
        {
            if ( validHit )
                selectablePointed.rollOver ( false ); // Reset previous Selectable (if any)

            validHit = false;
            if ( newSelectable )
            {
                if ( newSelectable.tag != "Square" )
                    validHit = true;
                else if ( Game.turnState == TurnState.PIECE_SELECTED )
                {
                    Square sqrPointed = (Square)newSelectable;
                    if ( sqrPointed.state == SquareState.VALID || sqrPointed.state == SquareState.VALID_TRACED )
                        validHit = true;
                }
                if ( validHit )
                    newSelectable.rollOver ( true ); // Call RollOver according to "Hit" and "TurnState"
            }
            selectablePointed = newSelectable; // Assign selectablePointed
        }

        if ( Input.touches.Length == 1 ) // Check cardboard's button input (for v2.0)
        //if ( true )
        {
            Touch touchedFinger = Input.touches[0]; // Get input of touches
            GameAction incoming = null;
            if ( touchedFinger.phase == TouchPhase.Ended )
            //if ( Input.GetMouseButtonDown(0) )
            {
                if  ( validHit )
                {
                    switch ( selectablePointed.tag )
                    {
                    case "Attacker":
                        incoming = new PieceSelection ( ((Piece)selectablePointed).index, true );
                        break;

                    case "Defender":
                    case "King":
                        incoming = new PieceSelection ( ((Piece)selectablePointed).index, false );
                        break;

                    case "Square":
                        incoming = new PieceMove ( ((Square)selectablePointed).coord );
                        break;
                    }
                    selectablePointed.rollOver (false);
                    selectablePointed = null;
                    validHit = false;
                    return incoming; // Create and return GameAction according to "Hit" & "TurnState"
                }
                else
                    Game.audio.playError ();
            }
        }
        return null;
    }
 public ChessBoardChange(int horizontalLocation, int verticalLocation, PieceSelection pieceSelection)
 {
     Location  = new ChessBoardLocation(horizontalLocation, verticalLocation);
     Selection = pieceSelection;
 }
Esempio n. 9
0
        /// <summary>
        /// Will start a new game and go to piece selection page
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void NewGame(object sender, RoutedEventArgs e)
        {
            PieceSelection pieceSelection = new PieceSelection();

            this.NavigationService.Navigate(pieceSelection);
        }