Exemplo n.º 1
0
    public void SelectChessman(int x, int y)
    {
        if (Chessmans[x, y] == null)
        {
            return;
        }

        if (Chessmans[x, y].isWhite != isWhiteTurn)
        {
            return;
        }
        print("Select");
        audioSource.PlayOneShot(pickSound, 0.2f);
        selectedChessman = Chessmans[x, y];
        Vector3    pos = selectedChessman.transform.position;
        Quaternion rot = selectedChessman.transform.rotation;

        pos.y = .6f;
        selectedChessman.transform.position = pos;
        selectedChessman.transform.rotation = Quaternion.Euler(12f, rot.eulerAngles.y, 0f);


        this.allowedMoves = selectedChessman.PossibleMoves();
        BoardHighlightsOffline.Instace.HighlightAllowedMoves(allowedMoves);
    }
Exemplo n.º 2
0
    public void PreviewMove(int x, int y)
    {
        //if (selectedChessman.PossibleMove(x, y) || (x == selectedChessman.CurrentX && y == selectedChessman.CurrentY))
        //{
        bool[,] moves = selectedChessman.PossibleMoves();

        int   closestX    = x;
        int   closestY    = y;
        float closestDist = 16f;

        for (int i = 0; i < 8; i++)
        {
            for (int j = 0; j < 8; j++)
            {
                if (moves[i, j] || (i == selectedChessman.CurrentX && j == selectedChessman.CurrentY))
                {
                    //int dist = Mathf.Abs(x-i) + Mathf.Abs(y-j);
                    float dist = Mathf.Sqrt((x - i) * (x - i) + (y - j) * (y - j));
                    if (dist < closestDist)
                    {
                        closestDist = dist;
                        closestX    = i;
                        closestY    = j;
                    }
                }
            }
        }

        Vector3 pos = GetTileCenter(closestX, closestY);

        pos.y = selectedChessman.transform.position.y;
        selectedChessman.transform.position = pos;
        //}
    }
Exemplo n.º 3
0
    public void SelectChessman(int x, int y)
    {
        if (Chessmans[x, y] == null)
        {
            return;
        }

        if (Chessmans[x, y].isWhite != isWhiteTurn)
        {
            return;
        }
        print("Select");
        selectedChessman = Chessmans[x, y];
        allowedMoves     = selectedChessman.PossibleMoves();
        BoardHighlights.Instace.HighlightAllowedMoves(allowedMoves);
    }
Exemplo n.º 4
0
    private void SelectChessman()
    {
        // if no chessman is on the clicked tile
        if (Chessmans[selectionX, selectionY] == null)
        {
            return;
        }
        // if it is not the turn of the selected chessman's team
        if (Chessmans[selectionX, selectionY].isWhite != isWhiteTurn)
        {
            return;
        }

        // Selecting chessman with yellow highlight
        SelectedChessman = Chessmans[selectionX, selectionY];
        BoardHighlights.Instance.SetTileYellow(selectionX, selectionY);

        // Allowed moves highlighted in blue and enemy in Red
        allowedMoves = SelectedChessman.PossibleMoves();
        BoardHighlights.Instance.HighlightPossibleMoves(allowedMoves, isWhiteTurn);
    }