private void ProductProcessDoll(List <Doll> availableDoll, int num1, int num2, int num3, int num4, int loopCount) { if (availableDoll.Count == 0) { Toast.MakeText(this, "Empty Doll List", ToastLength.Short).Show(); return; } try { int[] resultsDicNumber = new int[loopCount]; int[] tP = { 60, 27, 10, 3 }; int[] tAP1 = { 40, 45, 15 }; int[] tAP2 = { 20, 60, 20 }; int[] tAP3 = { 0, 75, 25 }; int[] P = (type == ProductType.Normal) ? new int[4] : new int[3]; int confirmGrade = 0; int mag = 10; int seedNum = (num1 + num2 + num3 + num4) / availableDoll.Count; for (int i = 0; i < loopCount; ++i) { switch (type) { case ProductType.Normal: for (int k = 0; k < tP.Length; ++k) { P[k] = tP[k] * mag; } break; case ProductType.Advance: switch (typeAdvance) { case AdvanceType._1: for (int k = 0; k < tAP1.Length; ++k) { P[k] = tAP1[k] * mag; } break; case AdvanceType._2: for (int k = 0; k < tAP2.Length; ++k) { P[k] = tAP2[k] * mag; } break; case AdvanceType._3: for (int k = 0; k < tAP3.Length; ++k) { P[k] = tAP3[k] * mag; } break; } break; } if (seedNum == 0) { seedNum = 1; } int num = ETC.CreateRandomNum(seedNum) % (100 * mag); switch (type) { case ProductType.Normal: if ((num >= 0) && (num < P[0])) { confirmGrade = 2; } else if ((num >= P[0]) && (num < (P[0] + P[1]))) { confirmGrade = 3; } else if ((num >= (P[0] + P[1])) && (num >= (P[0] + P[1] + P[2]))) { confirmGrade = 4; } else { confirmGrade = 5; } break; case ProductType.Advance: if ((num >= 0) && (num < P[0])) { confirmGrade = 3; } else if ((num >= P[0]) && (num < (P[0] + P[1]))) { confirmGrade = 4; } else { confirmGrade = 5; } break; } if (confirmGrade == 0) { if (type == ProductType.Normal) { confirmGrade = 2; } else if ((type == ProductType.Advance) && (typeAdvance == AdvanceType._3)) { confirmGrade = 4; } else { confirmGrade = 3; } } var finalDoll = new List <Doll>(); foreach (var doll in availableDoll) { if (doll.Grade == confirmGrade) { finalDoll.Add(doll); } } finalDoll.TrimExcess(); finalDoll.ShuffleList(); int fnum = ETC.CreateRandomNum() % finalDoll.Count; resultsDicNumber[i] = finalDoll[fnum].DicNumber; } ShowResultScreen(resultsDicNumber); } catch (Exception ex) { ETC.LogError(ex, this); ETC.ShowSnackbar(snackbarLayout, Resource.String.ProductSimulatorActivity_ProductDollError, Snackbar.LengthShort); } }