Example #1
0
 //Compute a score for the player indicated
 public int computePlayerScore(int inScore, PlayerE currPlayer)
 {
     foreach (GameObject p in whiteList)
     {
         inScore += (((Piece)p.GetComponent("Piece")).getPieceScore() + ((Piece)p.GetComponent("Piece")).canMoveList().Count);
     }
     foreach (GameObject p in blackList)
     {
         inScore -= (((Piece)p.GetComponent("Piece")).getPieceScore() + ((Piece)p.GetComponent("Piece")).canMoveList().Count);
     }
     return(inScore);
 }
Example #2
0
    public void generatePiece(PlayerE player, Point p, Piece.PieceTypeE piece, GameObject prefab, string str)
    {
        GameObject go;

        if (piece == Piece.PieceTypeE.KING)
        {
            go = Instantiate(prefab, new Vector3(p.turnToWorld()[0], 0.45f, p.turnToWorld()[1] + .35f), Quaternion.identity);
            ((Piece)go.GetComponent(str)).initialize((int)player, p, this, piece);
        }

        else if (piece == Piece.PieceTypeE.QUEEN)
        {
            go = Instantiate(prefab, new Vector3(p.turnToWorld()[0], 0.65f, p.turnToWorld()[1]), Quaternion.identity);
            ((Piece)go.GetComponent(str)).initialize((int)player, p, this, piece);
        }

        else if (piece == Piece.PieceTypeE.BISHOP)
        {
            go = Instantiate(prefab, new Vector3(p.turnToWorld()[0], 0.6f, p.turnToWorld()[1]), Quaternion.identity);
            ((Piece)go.GetComponent(str)).initialize((int)player, p, this, piece);
        }

        else if (piece == Piece.PieceTypeE.KNIGHT)
        {
            go = Instantiate(prefab, new Vector3(p.turnToWorld()[0], 0.55f, p.turnToWorld()[1]), Quaternion.identity);
            ((Piece)go.GetComponent(str)).initialize((int)player, p, this, piece);
        }

        else if (piece == Piece.PieceTypeE.ROOK)
        {
            go = Instantiate(prefab, new Vector3(p.turnToWorld()[0], 0.75f, p.turnToWorld()[1]), Quaternion.identity);
            ((Piece)go.GetComponent(str)).initialize((int)player, p, this, piece);
        }
        else
        {
            go = Instantiate(prefab, new Vector3(p.turnToWorld()[0], 0.5f, p.turnToWorld()[1]), Quaternion.identity);
            ((Piece)go.GetComponent(str)).initialize((int)player, p, this, piece);
        }
        if (piece == Piece.PieceTypeE.KING)
        {
            go.transform.localScale = new Vector3(2f, 2f, 2f);
        }
        else if (piece == Piece.PieceTypeE.KNIGHT)
        {
            go.transform.localScale = new Vector3(3f, 3f, 3f);
        }
        else
        {
            go.transform.localScale = new Vector3(4f, 4f, 4f);
        }
        boardPieces[p.getX(), p.getY()] = go;
        if (player == PlayerE.White)
        {
            whiteList.Add(boardPieces[p.getX(), p.getY()]);
        }
        else
        {
            blackList.Add(boardPieces[p.getX(), p.getY()]);
        }
        if (piece == Piece.PieceTypeE.KING)
        {
            if (player == PlayerE.White)
            {
                kings[0] = boardPieces[p.getX(), p.getY()];
            }
            else
            {
                kings[1] = boardPieces[p.getX(), p.getY()];
            }
        }
    }