private void Awake() { gameMode = GameMode.Game; backgroundSoundtrack = GameObject.Find("BackgroundSoundtrack").GetComponent <AudioSource>(); nextTetramino = new Tetramino(); field = new GameObject[Height, Width]; for (int i = 0; i < Height; i++) { for (int j = 0; j < Width; j++) { field[i, j] = new GameObject("Field: (" + i.ToString() + ", " + j.ToString() + ")", typeof(SpriteRenderer)); field[i, j].transform.position = new Vector3(j * BLOCK_SIZE, (Height - 1 - i) * BLOCK_SIZE, 0); Vector3 offset = new Vector3(Width * BLOCK_SIZE / 2 - BLOCK_SIZE / 2, Height * BLOCK_SIZE / 2 - BLOCK_SIZE / 2, 0); field[i, j].transform.position -= offset; SpriteRenderer renderer = field[i, j].GetComponent <SpriteRenderer>(); renderer.sprite = Resources.Load <Sprite>("Sprites/block"); field[i, j].SetActive(false); } } borders = new GameObject[Height, BORDERS_COUNT]; for (int i = 0; i < Height; i++) { for (int j = 0; j < BORDERS_COUNT; j++) { borders[i, j] = new GameObject("Borders: (" + i.ToString() + ", " + j.ToString() + ")", typeof(SpriteRenderer)); borders[i, j].transform.position = new Vector3(j * Width * BLOCK_SIZE, (Height - 1 - i) * BLOCK_SIZE, 0); Vector3 offset = new Vector3(Width * BLOCK_SIZE / 2, Height * BLOCK_SIZE / 2 - BLOCK_SIZE / 2, 0); borders[i, j].transform.position -= offset; borders[i, j].transform.position += (j == 0 ? -1 : 1) * new Vector3(BORDERS_PADDING, 0, 0); SpriteRenderer renderer = borders[i, j].GetComponent <SpriteRenderer>(); renderer.sprite = Resources.Load <Sprite>("Sprites/border"); } } NewTetramino(); tetramino.SetActive(field, true); }