Esempio n. 1
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("PlaceAbleBlock"))
     {
         _placeAbleBlock = other.gameObject.GetComponent <PlaceAbleBlock>();
         CheckForPlacement();
     }
 }
Esempio n. 2
0
 //конвертирует ячейки на поле в двумерный массив
 public void ConvertPlaceAbleObjectsIntoArray(int Row, int Column)
 {
     _row            = Row;
     _column         = Column;
     _blocksOnScene  = FindObjectsOfType <PlaceAbleBlock>();
     GameFieldBlocks = new PlaceAbleBlock[_row, _column];
     for (int i = 0; i < _row; i++)
     {
         float MinNum = 3000;
         for (int j = 0; j < _blocksOnScene.Length; j++)
         {
             if (_blocksOnScene[j] != null && _blocksOnScene[j].transform.position.y < MinNum)
             {
                 MinNum = _blocksOnScene[j].transform.position.y;
             }
         }
         int YCounter = 0;
         for (int k = 0; k < _blocksOnScene.Length; k++)
         {
             if (_blocksOnScene[k] != null && _blocksOnScene[k].transform.position.y == MinNum)
             {
                 GameFieldBlocks[i, YCounter] = _blocksOnScene[k];
                 _blocksOnScene[k]            = null;
                 YCounter++;
             }
         }
         for (int u = 0; u < _column; u++)
         {
             for (int m = 0; m < _column; m++)
             {
                 if (GameFieldBlocks[i, u].transform.position.x < GameFieldBlocks[i, m].transform.position.x)
                 {
                     PlaceAbleBlock temp = GameFieldBlocks[i, u];
                     GameFieldBlocks[i, u] = GameFieldBlocks[i, m];
                     GameFieldBlocks[i, m] = temp;
                 }
             }
         }
     }
     for (int i = 0; i < _row; i++)
     {
         for (int j = 0; j < _column; j++)
         {
             GameFieldBlocks[i, j].RowNum    = i;
             GameFieldBlocks[i, j].ColumnNum = j;
         }
     }
 }