void CreateComplexBlock() { GameObject root = Instantiate(blockRootPrefab) as GameObject; int i; Vector3 pos = Vector3.zero; Color c = GetRandomColor(); int tr = Random.Range(0, templates.Length); TetrisBlockTemplate t = templates[tr]; t.length = t.template.Length / 2; if (t.length < 1) { Destroy(root); return; } t.maxX = 0; for (i = 0; i < t.template.Length; i++) { if (t.template[i]) { GameObject block = Instantiate(blockSinglePrefab) as GameObject; block.transform.parent = root.transform; block.transform.localScale = Vector3.one; block.transform.localPosition = pos; block.renderer.material.color = c; t.maxX = Mathf.Max(t.maxX, (int)pos.x + 1); } if (i == t.length - 1) { pos.y += 1; pos.x = 0f; } else { pos.x += 1; } } TetrisBlockPlacement p = root.GetComponent <TetrisBlockPlacement> (); p.shape = t; blocks.Add(p); lastCreated = p; p.Init(this, Grid, t.maxX); }
void Start () { trans = transform; if ( Application.isPlaying ) { grid = new TetrisBlockTemplate( countX * countY ); if ( block != null ) { Destroy( block.gameObject ); } } }
void Start() { trans = transform; if (Application.isPlaying) { grid = new TetrisBlockTemplate(countX * countY); if (block != null) { Destroy(block.gameObject); } } }