Пример #1
0
 public void OnBirth(int row, int col, int layer)
 {
     if (!initialized)
     {
         xy_off    = Constant.Instance.CoverStepL;
         cd        = Constant.Instance.CoverCD;
         z_off     = Constant.Instance.CoverOffset;
         vfx_hub   = VFXHub.Instance;
         num_col   = col;
         num_row   = row;
         num_layer = layer;
         layers    = new int[col * row];
         for (int i = 0; i < layers.Length; ++i)
         {
             layers[i] = num_layer;
         }
         blocks = new Block[col * row];
         covers = new GameObject[col * row];
         keymap = Constant.Instance.KeyMap;
         for (int i = 0; i < col; ++i)
         {
             for (int j = 0; j < row; ++j)
             {
                 covers[i + j * col] = Instantiate(cover);
                 covers[i + j * col].transform.parent        = transform;
                 covers[i + j * col].transform.localPosition = new Vector3(xy_off * (i - (col - 1) * 0.5f), xy_off * (j - (row - 1) * 0.5f));
                 covers[i + j * col].transform.localRotation = Quaternion.Euler(new Vector3(0, 180, 180));
                 blocks[i + j * col] = new Block();
                 int   index = Random.Range(0, models.Length - 1);
                 Block block = new Block();
                 block.button = Instantiate(models[index]);
                 block.id     = index;
                 block.button.transform.parent        = gameObject.transform;
                 block.button.transform.localRotation = Quaternion.identity;
                 block.button.transform.localPosition = new Vector3(xy_off * (i - (col - 1) * 0.5f), xy_off * (j - (row - 1) * 0.5f), z_off);
                 blocks[i + j * col] = block;
             }
         }
     }
     initialized = true;
 }