コード例 #1
0
    void OnMouseOver()
    {
        if (Input.GetMouseButtonDown(0) && _player == playerColor.WHITE && manager.playerTurn)
        {
            moves.Clear();
            GameObject[] objects = GameObject.FindGameObjectsWithTag("Highlight");
            foreach (GameObject o in objects)
            {
                Destroy(o);
            }

            moves = factory.GetMoves(this, position);
            foreach (Move move in moves)
            {
                if (move.pieceKilled == null)
                {
                    GameObject instance = Instantiate(Resources.Load("MoveCube")) as GameObject;
                    instance.transform.position = new Vector3(-move.secondPosition.Position.x, 0, move.secondPosition.Position.y);
                    instance.GetComponent <Container>().move = move;
                }
                else if (move.pieceKilled != null)
                {
                    GameObject instance = Instantiate(Resources.Load("KillCube")) as GameObject;
                    instance.transform.position = new Vector3(-move.secondPosition.Position.x, 0, move.secondPosition.Position.y);
                    instance.GetComponent <Container>().move = move;
                }
            }
            GameObject i = Instantiate(Resources.Load("CurrentPiece")) as GameObject;
            i.transform.position = this.transform.position;
        }
    }
コード例 #2
0
    List <Move> _GetMoves(Piece.pieceWork color)
    {
        List <Move> turnMove = new List <Move>();
        List <Tile> pieces   = new List <Tile>();

        if (color == Piece.pieceWork.BWORK)
        {
            pieces = _blackPieces;
        }
        else if (color == Piece.pieceWork.WWORK)
        {
            pieces = _whitePieces;
        }

        foreach (Tile tile in pieces)
        {
            MoveFactory factory    = new MoveFactory(_board);
            List <Move> pieceMoves = factory.GetMoves(tile.CurrentPiece, tile.Position);

            foreach (Move move in pieceMoves)
            {
                Move newMove = _CreateMove(move.firstPosition, move.secondPosition);
                turnMove.Add(newMove);
            }
        }
        return(turnMove);
    }
コード例 #3
0
    List <Move_new> _GetMoves(Piece_new.playerColor color)
    {
        List <Move_new> turnMove = new List <Move_new>();
        List <Tile_new> pieces   = new List <Tile_new>();

        if (color == Piece_new.playerColor.BLACK)
        {
            pieces = _blackPieces;
        }
        else
        {
            pieces = _whitePieces;
        }

        foreach (Tile_new tile in pieces)
        {
            MoveFactory     factory    = new MoveFactory(_board);
            List <Move_new> pieceMoves = factory.GetMoves(tile.CurrentPiece, tile.Position);

            foreach (Move_new move in pieceMoves)
            {
                Move_new newMove = _CreateMove(move.firstPosition, move.secondPosition);
                turnMove.Add(newMove);
            }
        }
        return(turnMove);
    }
コード例 #4
0
    public void Selected()
    {
        moves.Clear();
        GameObject[] objects = GameObject.FindGameObjectsWithTag("Highlight");
        foreach (GameObject o in objects)
        {
            Destroy(o);
        }

        moves = factory.GetMoves(this, position);

        foreach (Move_new move in moves)
        {
            //Debug.Log(move.secondPosition.Position.x);
            //Debug.Log(move.secondPosition.Position.y);

            if (move.pieceKilled == null)
            {
                GameObject instance = Instantiate(Resources.Load("MoveCube")) as GameObject;
                instance.transform.position = new Vector3(-move.secondPosition.Position.x, 0, move.secondPosition.Position.y);
                instance.GetComponent <Container>().move = move;
                instance.name = move.secondPosition.Position.x.ToString() + move.secondPosition.Position.y.ToString();
            }
            else if (move.pieceKilled != null)
            {
                GameObject instance = Instantiate(Resources.Load("KillCube")) as GameObject;
                instance.transform.position = new Vector3(-move.secondPosition.Position.x, 0, move.secondPosition.Position.y);
                instance.GetComponent <Container>().move = move;
                instance.name = move.secondPosition.Position.x.ToString() + move.secondPosition.Position.y.ToString();
            }
        }
        GameObject i = Instantiate(Resources.Load("CurrentPiece")) as GameObject;

        i.transform.position = this.transform.position;
    }