public void ChoiceRandom() { var choice = ProbabilityController.ChoiceRandom(BonusItems); StartCoroutine( RotateToAngle(new Vector3(0, 0, 1), Arrow.rotation.eulerAngles.z, Arrow.rotation.eulerAngles.z + (360 - Arrow.rotation.eulerAngles.z) + BonusItems[choice].Angle, 10, EndRandomChoice)); }
public void ChoiceRandom() { var choice = ProbabilityController.ChoiceRandom(BonusItems.ToArray()); var rotation = arrowRect.rotation; StartCoroutine( RotateToAngle(new Vector3(0, 0, 1), rotation.eulerAngles.z, rotation.eulerAngles.z + (360 - rotation.eulerAngles.z) + BonusItems[choice].Angle, 10, () => Callback(choice))); }
public void ChoiceRandom() { button.SetActive(false); var choice = ProbabilityController.ChoiceRandom(BonusItems); Debug.Log(BonusItems[choice].ID); itemName.text = BonusItems[choice].name; StartCoroutine( RotateToAngle(choice, new Vector3(0, 0, 1), Arrow.rotation.eulerAngles.z, Arrow.rotation.eulerAngles.z + (360 - Arrow.rotation.eulerAngles.z) + BonusItems[choice].Angle, 10, EndRandomChoice)); }
private List <BlockType> FillBlocks(int length) { int freeCells = length; List <BlockType> result = new List <BlockType>(); int rangeTypes = 4;// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! while (freeCells > 0) { var max = freeCells; if (freeCells > rangeTypes) { max = rangeTypes; } float[] mas = new float[] { 0.35f, 0.30f, 0.25f, 0.10f }; var blockIndex = 1; if (max >= 4) { blockIndex = (ProbabilityController.GetRandom(mas) - 4) * -1; } else if (max >= 3) { mas = new float[] { 0.55f, 0.35f, 0.10f }; blockIndex = (ProbabilityController.GetRandom(mas) - 3) * -1; } else if (max >= 2) { mas = new float[] { 0.55f, 0.45f }; blockIndex = (ProbabilityController.GetRandom(mas) - 2) * -1; } Debug.Log($"! {blockIndex} {max+1}"); var blockType = (BlockType)(blockIndex); result.Add(blockType); freeCells -= blockIndex; } return(result); }
private void SetRandomLine() { //1 Set Random //2 Get Arrays //3 Fill arraays //4 add blocks //1 //float[] mas = new float[] {0.35f,0.30f,0.25f,0.10f}; float[] emptyProb = new float[] { 0.40f, 0.30f, 0.20f, 0.10f }; int emptyCounts = ProbabilityController.GetRandom(emptyProb) + 1; Debug.Log($"emptyCounts {emptyCounts}"); var emptyIndexes = getUniqueRandomArray(0, MaxLine, emptyCounts).OrderBy(i => i);// board width 88888 foreach (var index in emptyIndexes) { Debug.Log($"empty {index}"); } // int freeCells = 8; // Queue<BlockType> line = new Queue<BlockType>(); // int freeCells = 8; // int rangeTypes = 3; // while(freeCells > 0) // { // } Queue <BlockType> line = new Queue <BlockType>(); int current = 0; foreach (var index in emptyIndexes) { var length = index - current; if (length > 0) { var group = FillBlocks(length); foreach (var item in group) { line.Enqueue(item); } } current = index + 1; line.Enqueue(BlockType.Empty); } // for last if (current != MaxLine) { var length = MaxLine - current; if (length > 0) { var group = FillBlocks(length); foreach (var item in group) { line.Enqueue(item); } } line.Enqueue(BlockType.Empty); } // print // foreach (var p in line) // { // Debug.Log($"line {p}"); // } current = 0; //while(line.Count != 0) for (var i = 0; i < line.Count; i++) { var blockType = line.Dequeue(); Debug.Log($"{current} {line.Dequeue()}"); if (blockType == BlockType.Empty) { current += 1; continue; } CreateBlock(Board[current, indexInst], blockType); current += (int)blockType; } }