示例#1
0
 public void MakePiecePartOfMe(Piece piece, Vector2Int gridSlot)
 {
     m_pieces[gridSlot.x, gridSlot.y] = piece;
     piece.Attach();
     if (piece.socket != null)
     {
         piece.socket.m_piece = null;
         piece.socket         = null;
     }
     piece.isConnectedToHelm = true;
     if (piece.HasNorthConnector())
     {
         Vector2Int northSlot  = new Vector2Int(gridSlot.x, gridSlot.y + 1);
         Piece      otherPiece = GetPieceAt(northSlot);
         if (otherPiece != null)
         {
             piece.NoteConnectorStatus("North", otherPiece.HasSouthConnector());
             otherPiece.NoteConnectorStatus("South", otherPiece.HasSouthConnector());
         }
     }
     if (piece.HasSouthConnector())
     {
         Vector2Int southSlot  = new Vector2Int(gridSlot.x, gridSlot.y - 1);
         Piece      otherPiece = GetPieceAt(southSlot);
         if (otherPiece != null)
         {
             piece.NoteConnectorStatus("South", otherPiece.HasNorthConnector());
             otherPiece.NoteConnectorStatus("North", otherPiece.HasNorthConnector());
         }
     }
     if (piece.HasEastConnector())
     {
         Vector2Int eastSlot   = new Vector2Int(gridSlot.x + 1, gridSlot.y);
         Piece      otherPiece = GetPieceAt(eastSlot);
         if (otherPiece != null)
         {
             piece.NoteConnectorStatus("East", otherPiece.HasWestConnector());
             otherPiece.NoteConnectorStatus("West", otherPiece.HasWestConnector());
         }
     }
     if (piece.HasWestConnector())
     {
         Vector2Int westSlot   = new Vector2Int(gridSlot.x - 1, gridSlot.y);
         Piece      otherPiece = GetPieceAt(westSlot);
         if (otherPiece != null)
         {
             piece.NoteConnectorStatus("West", otherPiece.HasEastConnector());
             otherPiece.NoteConnectorStatus("East", otherPiece.HasEastConnector());
         }
     }
 }