public void CreateTutorial(bool _hasLabel) { LoadingBoxLocation tutorialBox = new LoadingBoxLocation(Vector2.zero, new Vector2(Random.Range(0.40f, 0.50f), Random.Range(0.54f, 0.64f))); boxLocations.Add(tutorialBox); if (_hasLabel) { boxLocations[0].isHeavy = true; boxLocations[0].isUp = true; } remainingBoxes = 1; CreateBox(0); isPlaying = true; }
void DivideOnce(bool isHorizontal, float _sizeModifier) { //VARIABLE 1// if (isHorizontal) { boxLocations.Sort(delegate(LoadingBoxLocation x, LoadingBoxLocation y) { if (x.size.y < y.size.y) { return(1); } else { return(-1); } }); } else { boxLocations.Sort(delegate(LoadingBoxLocation x, LoadingBoxLocation y) { if (x.size.x < y.size.x) { return(1); } else { return(-1); } }); } int boxIndex = 0; //VARIABLE 1// //VARIABLE 2// //float sizeModifier = 0.99f; //1% - 99% //float sizeModifier = 0.5f; //25% - 75% //float sizeModifier = 0.2f; //40% - 60% //float sizeModifier = 0.0f; //50% //VARIABLE 2// Vector2 boxXRange = new Vector2(boxLocations[boxIndex].position.x - boxLocations[boxIndex].size.x / 2.0f, boxLocations[boxIndex].position.x + boxLocations[boxIndex].size.x / 2.0f); Vector2 boxYRange = new Vector2(boxLocations[boxIndex].position.y - boxLocations[boxIndex].size.y / 2.0f, boxLocations[boxIndex].position.y + boxLocations[boxIndex].size.y / 2.0f); Vector2 dividePoint = new Vector2(Random.Range(boxLocations[boxIndex].position.x - (boxLocations[boxIndex].size.x / 2.0f) * _sizeModifier, boxLocations[boxIndex].position.x + (boxLocations[boxIndex].size.x / 2.0f) * _sizeModifier), Random.Range(boxLocations[boxIndex].position.y - (boxLocations[boxIndex].size.y / 2.0f) * _sizeModifier, boxLocations[boxIndex].position.y + (boxLocations[boxIndex].size.y / 2.0f) * _sizeModifier)); Vector2 box1Pos = Vector2.zero; Vector2 box1Size = Vector2.zero; Vector2 box2Pos = Vector2.zero; Vector2 box2Size = Vector2.zero; if (isHorizontal) { box1Pos = new Vector2(boxLocations[boxIndex].position.x, (boxYRange.x + dividePoint.y) / 2.0f); box1Size = new Vector2(boxLocations[boxIndex].size.x, dividePoint.y - boxYRange.x); box2Pos = new Vector2(boxLocations[boxIndex].position.x, (boxYRange.y + dividePoint.y) / 2.0f); box2Size = new Vector2(boxLocations[boxIndex].size.x, boxYRange.y - dividePoint.y); } else { box1Pos = new Vector2((boxXRange.x + dividePoint.x) / 2.0f, boxLocations[boxIndex].position.y); box1Size = new Vector2(dividePoint.x - boxXRange.x, boxLocations[boxIndex].size.y); box2Pos = new Vector2((boxXRange.y + dividePoint.x) / 2.0f, boxLocations[boxIndex].position.y); box2Size = new Vector2(boxXRange.y - dividePoint.x, boxLocations[boxIndex].size.y); } LoadingBoxLocation box1 = new LoadingBoxLocation(box1Pos, box1Size); LoadingBoxLocation box2 = new LoadingBoxLocation(box2Pos, box2Size); boxLocations.RemoveAt(boxIndex); boxLocations.Add(box1); boxLocations.Add(box2); }