private void UndoInit() { Transform[] children = TransformUtil.GetChildren(transform); transform.DetachChildren(); LoopUtil.LoopAction((i) => Destroy(children[i].gameObject), children.Length); inited = false; }
private void SetColor(Tetramino.TetraminoType type) { int childCount; SpriteRenderer[] spriteRenderers = GetComponentUtil.GetComponentsInChildren <SpriteRenderer>(transform, out childCount); LoopUtil.LoopAction((i) => spriteRenderers[i].color = TetraminoUtil.Color(type), childCount); }
public static void ApplyLocalPoses(Transform[] transforms, Vector2[] poses) { if (transforms.Length != poses.Length) { Debug.Log(transforms.Length + " : " + poses.Length); throw new System.Exception("transforms.Length != poses.Length"); } LoopUtil.LoopAction((i) => transforms[i].localPosition = poses[i], transforms.Length); }
public void SetOpacity(float opacity) { int childCount; SpriteRenderer[] spriteRenderers = GetComponentUtil.GetComponentsInChildren <SpriteRenderer>(transform, out childCount); LoopUtil.LoopAction((i) => spriteRenderers[i].color = ColorUtil.ColorWithOpacity(spriteRenderers[i].color, opacity), childCount); }
private void _UpdateBlocks() { var xCount = blocks.GetLength(0); var yCount = blocks.GetLength(1); LoopUtil.LoopAction((x, y) => { blockGameObjects[x, y].SetActive(blocks[x, y] != null); } , xCount, yCount); }
// makes cells occupied by tetramino impassable public void FreezeTetraminoArea(TetraminoMono tetraminoMono) { Tetramino tetramino = tetraminoMono.tetramino; Vector2Int[] absPoses = tetramino.AbsPoses; LoopUtil.LoopAction((i) => { this[absPoses[i]] = new WallBlock(BlockType.Unspecified, tetraminoMono.GetChildGameObject(i)); } , absPoses.Length); DisplayBlocks.UpdateBlocks(); }
void Start() { var xCount = blocks.GetLength(0); var yCount = blocks.GetLength(1); blockGameObjects = new GameObject[xCount, yCount]; LoopUtil.LoopAction((x, y) => { blockGameObjects[x, y] = Instantiate (prefab, new Vector2(x, y), Quaternion.identity, transform); } , xCount, yCount); _UpdateBlocks(); }
public void Rotate(int rotationCount) { float sign = Mathf.Sign(rotationCount); int abs = Mathf.Abs(rotationCount); rotationCount = abs % 4; if (sign > 0) { LoopUtil.LoopAction((i) => RotateClockwise(), rotationCount); } else if (sign < 0) { LoopUtil.LoopAction((i) => RotateAntiClockwise(), rotationCount); } }
// Start is called before the first frame update void Start() { PrintChildrenCount(); var children = TransformUtil.GetChildren(transform); LoopUtil.LoopAction( (i) => { children[i].parent = null; Destroy(children[i].gameObject); }, children.Length); PrintChildrenCount(); LoopUtil.LoopAction((i) => new GameObject().transform.parent = transform, 1); PrintChildrenCount(); }
private void SetColor(Tetramino.TetraminoType type) { int childCount; SpriteRenderer[] spriteRenderers = GetSpriteRenderers(transform, out childCount); #region old version //for (int i = 0; i < 4; i++) //{ // Transform child = transform.GetChild(i); // SpriteRenderer spriteRenderer = child.GetComponent<SpriteRenderer>(); // spriteRenderer.color = TetraminoUtil.Color(type); //} #endregion LoopUtil.LoopAction((i) => spriteRenderers[i].color = TetraminoUtil.Color(type), childCount); }
void Start() { var xCount = blocks.GetLength(0); var yCount = blocks.GetLength(1); blockGameObjects = new GameObject[xCount, yCount]; LoopUtil.LoopAction((x, y) => { blockGameObjects[x, y] = Instantiate (prefab, new Vector2(x, y), Quaternion.identity, transform); if (blocks[x, y] == null) { blockGameObjects[x, y].SetActive(false); } } , xCount, yCount); }
// makes cells occupied by tetramino impassable public void FreezeTetraminoArea(TetraminoMono tetraminoMono) { //foreach (Vector2Int pos in ) //{ // blocks[pos.x, pos.y] = new WallBlock(BlockType.Unspecified); //} Tetramino tetramino = tetraminoMono.tetramino; Vector2Int[] absPoses = tetramino.AbsPoses; LoopUtil.LoopAction((i) => { blocks[absPoses[i].x, absPoses[i].y] = new WallBlock(BlockType.Unspecified, tetraminoMono.GetChildGameObject(i)); } , absPoses.Length); DisplayBlocks.UpdateBlocks(); }
public void SetOpacity(float opacity) { int childCount; SpriteRenderer[] spriteRenderers = GetSpriteRenderers(transform, out childCount); LoopUtil.LoopAction((i) => spriteRenderers[i].color = ColorUtil.ColorWithOpacity(spriteRenderers[i].color, opacity), childCount); #region old version //for(int i = 0; i < 4; i++) //{ // Transform child = transform.GetChild(i); // SpriteRenderer spriteRenderer = child.GetComponent<SpriteRenderer>(); // spriteRenderer.color = ColorUtil.ColorWithOpacity(spriteRenderer.color, opacity); //} #endregion }
private void _UpdateBlocks() { var xCount = blocks.GetLength(0); var yCount = blocks.GetLength(1); LoopUtil.LoopAction((x, y) => { if (blocks[x, y] == null) { blockGameObjects[x, y].SetActive(false); } else { blockGameObjects[x, y].SetActive(true); } } , xCount, yCount); }
// builds Tetris playing grid according to the data specified in Grid class private void BuildGrid() { Transform parent = transform; Color color = Color.white; float offset = Grid.offset; int xCount = Grid.gridSize.x; int yCount = Grid.gridSize.y; LoopUtil.LoopAction( (x, y) => { GameObject square = SquareUtil.InstantiateAndSetUpSquare(parent, offset * new Vector2(x, y), color); if (Grid.HideBlock(y)) { square.SetActive(false); } }, xCount, yCount); }
private static void InstantiateCells(Transform parent, float offset, Vector2Int[] poses, Color color) { LoopUtil.LoopAction((i) => SquareUtil.InstantiateAndSetUpSquare(parent, offset * (Vector2)poses[i], color), poses.Length); }