public void InitOperationCell(int pos, Dice.Operation operation, int cellNumber) { pos = Mathf.Clamp(pos, 0, 1); //Debug.Log(pos); GameObject cell = inGame.cellNormal; switch (operation) { case Dice.Operation.Div: cell = inGame.cellDivision; break; case Dice.Operation.Mult: cell = inGame.cellMultiplication; break; case Dice.Operation.Rest: cell = inGame.cellSubstraction; break; case Dice.Operation.Sum: cell = inGame.cellSum; break; } Cell leftCell = instantiateCell(cellNumber, cell, (pos == 0 ? LCell : DCell)); if (pos == 0) { LCell = leftCell.transform; } else if (pos == 1) { DCell = leftCell.transform; } }
public void Init(int[] numbers, Dice.Operation operation) { //Debug.Log(numbers[0]+", "+numbers[1]+", "+numbers[2]); int index = Random.Range(1, 3); int rightOperation = 0, wrongOperation = 0; switch (operation) { case Dice.Operation.Sum: rightOperation = numbers[0] + numbers[index]; wrongOperation = numbers[0] + numbers[(index == 1 ? 2 : 1)] + wrongRange(); while (wrongOperation == numbers[0] + numbers[1]) { wrongOperation += (int)(Mathf.Sign(Random.Range(-1, 1))) * 1; } break; case Dice.Operation.Mult: rightOperation = numbers[0] * numbers[index]; wrongOperation = numbers[0] * numbers[(index == 1 ? 2 : 1)] + (int)(Mathf.Sign(Random.Range(-1, 1))) * numbers[(index == 1 ? 2 : 1)]; while (wrongOperation == numbers[0] + numbers[1]) { wrongOperation += (int)(Mathf.Sign(Random.Range(-1, 1))) * 1; } break; case Dice.Operation.Div: rightOperation = (int)(numbers[0] / numbers[index]); if (numbers[(index == 1 ? 2 : 1)] != 0) { wrongOperation = (int)(numbers[0] / numbers[(index == 1 ? 2 : 1)]) + wrongRange(); } else { wrongOperation = (int)(numbers[0] / numbers[(index == 1 ? 2 : 1)] + 1) + wrongRange(); } while (wrongOperation == numbers[0] + numbers[1]) { wrongOperation += (int)(Mathf.Sign(Random.Range(-1, 1))) * 1; } break; case Dice.Operation.Rest: rightOperation = numbers[0] - numbers[index]; wrongOperation = numbers[0] - numbers[(index == 1 ? 2 : 1)] + wrongRange(); while (wrongOperation == numbers[0] + numbers[1]) { wrongOperation += (int)(Mathf.Sign(Random.Range(-1, 1))) * 1; } break; } if (index == 1) { Cell leftCell = instantiateCell(rightOperation, inGame.cellNormal, LCell); Cell downCell = instantiateCell(wrongOperation, inGame.cellNormal, DCell); } else { Cell leftCell = instantiateCell(wrongOperation, inGame.cellNormal, LCell); Cell downCell = instantiateCell(rightOperation, inGame.cellNormal, DCell); } }
public void InitCellDown(int[] numbers, Dice.Operation operation, int cellNumber) { Cell downCell = instantiateCell(cellNumber, inGame.cellNormal, DCell); }