void chonData3(ref List <PhepToan> tmg1, List <PhepToan> lstTam, int loai) { List <PhepToan> lstRank = new List <PhepToan>(); foreach (PhepToan item in lstTam) { if (loai == 4) { if (item.Loai.Equals("" + 30)) { lstRank.Add(item); } } else if (loai == 5) { if (item.Loai.Equals("" + 21) || item.Loai.Equals("" + 22)) { lstRank.Add(item); } } else if (loai == 6) { if (item.Loai.Equals("" + 23)) { lstRank.Add(item); } } else if (loai == 7) { if (item.Loai.Equals("" + 35)) { lstRank.Add(item); } } else if (loai == 8) { if (item.Loai.Equals("" + 24)) { lstRank.Add(item); } } else if (loai == 9) { if (item.Loai.Equals("" + 25)) { lstRank.Add(item); } } else if (loai == 10) { if (item.Loai.Equals("" + 36)) { lstRank.Add(item); } } else if (loai == 11) { if (item.Loai.Equals("" + 26) || item.Loai.Equals("" + 28)) { lstRank.Add(item); } } else if (loai == 12) { if (item.Loai.Equals("" + 27) || item.Loai.Equals("" + 29)) { lstRank.Add(item); } } else if (loai == 13) { if (item.Loai.Equals("" + 37)) { lstRank.Add(item); } } else if (loai == 14 || loai == 15) { if (item.Loai.Equals("" + 31)) { lstRank.Add(item); } } else if (loai == 16) { if (item.Loai.Equals("" + 32)) { lstRank.Add(item); } } else if (loai == 17 || loai == 18) { if (item.Loai.Equals("" + 33)) { lstRank.Add(item); } } else if (loai == 19 || loai == 20) { if (item.Loai.Equals("" + 34)) { lstRank.Add(item); } } } if (loai == 5) { lstRank = lstRank.Concat(ClsThaoTac.FakeData(70, 80)).ToList(); } else if (loai == 6) { lstRank = lstRank.Concat(ClsThaoTac.FakeData(90, 100)).ToList(); } #region Singleton if (loai == 4 || loai == 8 || loai == 9 || loai == 11 || loai == 12) { //1 phep toan while (tmg1.Count < 20) { int chon = UnityEngine.Random.Range(0, lstRank.Count); bool ok = false; for (int i = 0; i < tmg1.Count; i++) { if (lstRank[chon].Ketqua == tmg1[i].Ketqua) { ok = true; break; } } if (ok == false) { PhepToan pt1; if (chon % 7 == 0) { pt1 = new PhepToan(ClsLanguage.doNumber() + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number"); } else if (chon % 4 == 0) { pt1 = new PhepToan("" + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number"); } else { int nh = UnityEngine.Random.Range(0, 3); if (nh == 1) { pt1 = ClsThaoTac.getCongThuc(lstRank[chon]); } else { pt1 = new PhepToan("" + lstRank[chon].Congthuc, lstRank[chon].Ketqua, "number"); } } tmg1.Add(pt1); lstSapXep.Add(pt1); } } } else if (loai == 13) { //gio phut while (tmg1.Count < 20) { int chon = UnityEngine.Random.Range(0, lstRank.Count); bool ok = false; for (int i = 0; i < tmg1.Count; i++) { if (lstRank[chon].Ketqua == tmg1[i].Ketqua) { ok = true; break; } } if (ok == false) { string ptmoi = ClsThaoTac.getTimeCongThuc(lstRank[chon].Congthuc); PhepToan pt1 = new PhepToan(ptmoi, lstRank[chon].Ketqua, "number"); tmg1.Add(pt1); lstSapXep.Add(pt1); } } } else if (loai == 14 || loai == 15 || loai == 16 || loai == 17 || loai == 18 || loai == 19 || loai == 20) { //2 phep toan while (tmg1.Count < 20) { int chon = UnityEngine.Random.Range(0, lstRank.Count); bool ok = false; for (int i = 0; i < tmg1.Count; i++) { if (lstRank[chon].Ketqua == tmg1[i].Ketqua) { ok = true; break; } } if (ok == false) { PhepToan pt1; if (chon % 7 == 0) { pt1 = new PhepToan(ClsLanguage.doNumber() + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number"); } else if (chon % 4 == 0) { pt1 = new PhepToan("" + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number"); } else { pt1 = new PhepToan("" + lstRank[chon].Congthuc, lstRank[chon].Ketqua, "number"); } tmg1.Add(pt1); lstSapXep.Add(pt1); } } } else if (loai == 7 || loai == 10) { string dv = "mm"; if (loai == 7) { dv = "mm"; } else { dv = "dm"; } //1 phep toan biet truopc number while (tmg1.Count < 20) { int chon = UnityEngine.Random.Range(0, lstRank.Count); bool ok = false; for (int i = 0; i < tmg1.Count; i++) { if (lstRank[chon].Ketqua == tmg1[i].Ketqua) { ok = true; break; } } if (ok == false) { PhepToan pt1; if (chon % 2 == 0) { pt1 = new PhepToan("" + lstRank[chon].Ketqua + dv, lstRank[chon].Ketqua, "number"); } else { pt1 = new PhepToan("" + lstRank[chon].Congthuc, lstRank[chon].Ketqua, "number"); } tmg1.Add(pt1); lstSapXep.Add(pt1); } } } else if (loai == 5 || loai == 6) { //1 phep toan biet truopc number while (tmg1.Count < 20) { int chon = UnityEngine.Random.Range(0, lstRank.Count); bool ok = false; for (int i = 0; i < tmg1.Count; i++) { if (lstRank[chon].Ketqua == tmg1[i].Ketqua) { ok = true; break; } } if (ok == false) { PhepToan pt1; if (chon % 7 == 0 && lstRank[chon].Loai.Equals("number")) { pt1 = new PhepToan(ClsLanguage.doNumber() + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number"); } else if (chon % 4 == 0 && lstRank[chon].Loai.Equals("number")) { pt1 = new PhepToan("" + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number"); } else { int nh = UnityEngine.Random.Range(0, 3); if (nh == 0) { pt1 = ClsThaoTac.getCongThuc(lstRank[chon]); } else { pt1 = new PhepToan("" + lstRank[chon].Congthuc, lstRank[chon].Ketqua, "number"); } } tmg1.Add(pt1); lstSapXep.Add(pt1); } } } #endregion }