void DestroyMatchedBlock() { for (int x = 0; x < 6; x++) { for (int y = 0; y < 10; y++) { ColorBox target = ((Transform)Block[x][y]).GetComponent <ColorBox>(); if (target.rigidbody.velocity.magnitude > 0.3f || target.isDead) { return; } } } // vertical matched block check for (int x = 0; x < 6; x++) { for (int y = 0; y < 8; y++) { ColorBox first = ((Transform)Block[x][y]).GetComponent <ColorBox>(); ColorBox second = ((Transform)Block[x][y + 1]).GetComponent <ColorBox>(); ColorBox third = ((Transform)Block[x][y + 2]).GetComponent <ColorBox>(); if (first.FaceNumber() == second.FaceNumber() && second.FaceNumber() == third.FaceNumber()) { first.DestroyColorBox(0.2f, 0.4f); second.DestroyColorBox(0.2f, 0.4f); third.DestroyColorBox(0.2f, 0.4f); } } } // horizontal matched block check for (int x = 0; x < 4; x++) { for (int y = 0; y < 10; y++) { ColorBox first = ((Transform)Block[x][y]).GetComponent <ColorBox>(); ColorBox second = ((Transform)Block[x + 1][y]).GetComponent <ColorBox>(); ColorBox third = ((Transform)Block[x + 2][y]).GetComponent <ColorBox>(); if (first.FaceNumber() == second.FaceNumber() && second.FaceNumber() == third.FaceNumber()) { first.DestroyColorBox(0.2f, 0.4f); second.DestroyColorBox(0.2f, 0.4f); third.DestroyColorBox(0.2f, 0.4f); } } } }