示例#1
0
 // Start is called before the first frame update
 void Start()
 {
     main           = GameObject.Find("MainCode").GetComponent <Main>();
     king           = transform.Find((name == "Black" ? "Black" : "White") + "_King").GetComponent <King_Piece>();
     isBlack        = name[0] == 'B';
     canCastleShort = true;
     canCastleLong  = true;
 }
示例#2
0
    void Start()
    {
        piece = GetComponent <Chess_Piece>();

        //determine piece type
        switch (transform.name[6])
        {
        case 'P':
            PieceTypeID = 1;
            pawn        = transform.GetComponent <Pawn_Piece>();
            break;

        case 'R':
            PieceTypeID = 2;
            rook        = transform.GetComponent <Rook_Piece>();
            break;

        case 'B':
            PieceTypeID = 3;
            bishop      = transform.GetComponent <Bishop_Piece>();
            break;

        case 'H':
            PieceTypeID = 4;
            horse       = transform.GetComponent <Horse_Piece>();
            break;

        case 'Q':
            PieceTypeID = 5;
            queen       = transform.GetComponent <Queen_Piece>();
            break;

        case 'K':
            PieceTypeID = 6;
            king        = transform.GetComponent <King_Piece>();
            break;

        default:
            break;
        }

        if (transform.parent.name == "Black")
        {
            PieceTypeID += 6;
        }
    }