void setDataLst(ref List <PhepToan> lstP) { var children = new List <GameObject>(); foreach (Transform child in this.transform) { children.Add(child.gameObject); } int i = 0; foreach (GameObject item in children) { if (item.CompareTag("nguoi")) { continue; } item.SetActive(true); item.GetComponent <SpItem>().Giatri = ClsThaoTac.doKetQua(lstP[i].Ketqua); item.GetComponent <SpItem>().Pheptoan = "" + lstP[i].Congthuc; item.GetComponent <SpItem>().setData(lstP[i].Loai); item.GetComponent <SpItem>().Trangthai = true; i++; } }
void setDataLst(ref List <PhepToan> lstP) { var children = new List <GameObject>(); foreach (Transform child in this.transform) { children.Add(child.gameObject); } foreach (GameObject item in children) { if (item.CompareTag("nguoi")) { continue; } item.SetActive(true); int chon = UnityEngine.Random.Range(0, lstP.Count); item.GetComponent <SpItem>().Giatri = ClsThaoTac.doKetQua(lstP[chon].Ketqua); item.GetComponent <SpItem>().Pheptoan = "" + lstP[chon].Congthuc; item.GetComponent <SpItem>().setData(lstP[chon].Loai); item.GetComponent <SpItem>().Trangthai = true; lstP.RemoveAt(chon); } }
public static PhepToan getPhepToan(PhepToan giatri, ref List <PhepToan> lst, int pc) { lst.RemoveAt(pc); List <PhepToan> tmg = new List <PhepToan>(); foreach (PhepToan item in lst) { if (item.Congthuc.Equals(giatri.Congthuc)) { continue; } if (ClsThaoTac.doKetQua(item.Ketqua) == ClsThaoTac.doKetQua((giatri.Ketqua))) { tmg.Add(item); } } if (tmg.Count > 0) { int chon = UnityEngine.Random.Range(0, tmg.Count); string tambo = "" + tmg[chon].Congthuc; string tambo2 = "" + tmg[chon].Congthuc; if (tambo.Contains("c")) { string[] mang = tambo.Split('c'); if (mang[0].Contains("/") && mang[1].Contains("/")) { tambo = "phanhai"; } else if (mang[0].Contains("/")) { tambo = "phantrai"; } else if (mang[1].Contains("/")) { tambo = "phanphai"; } else { tambo = "number"; tambo2 = mang[0] + ClsLanguage.doOf() + mang[1]; } } else if (tambo.Contains("]")) { if (tambo.Contains("+") || tambo.Contains("-") || tambo.Contains("x") || tambo.Contains(":")) { tambo = "mixhai"; } else { tambo = "mix"; } } else if (tambo.Contains("/")) { if (tambo.Contains("+") || tambo.Contains("-") || tambo.Contains("x") || tambo.Contains(":")) { string[] mang = tambo.Split(new Char[] { '-', '+', 'x', ':' }); if (mang.Length >= 3) { int dem = 0; for (int i = 0; i < tambo.Count(); i++) { string dkm = "" + tambo[i]; if (dkm.Equals("/")) { dem++; } } if (dem >= 2) { tambo = "phansoba"; } else { tambo = "phanso"; } } else { if (mang[0].Contains("/") && mang[1].Contains("/")) { tambo = "phansohai"; } else if (mang[0].Contains("/")) { tambo = "phansotrai"; } else if (mang[1].Contains("/")) { tambo = "phansophai"; } else { tambo = "phanso"; } } } else { tambo = "phanso"; } } else { tambo = "number"; } return(new PhepToan(tambo2, tmg[chon].Ketqua, tambo)); } else { if (giatri.Ketqua.Contains("/")) { return(new PhepToan("" + giatri.Ketqua, giatri.Ketqua, "phanso")); } else { return(new PhepToan("" + giatri.Ketqua, giatri.Ketqua, "number")); } } }
void CreateLevel(float positionX, float positionY, PhepToan vio, int thutu) { SpItem levelCreate = spPrefab.Spawn <SpItem> ( new Vector3(positionX, positionY, 71), spPrefab.transform.rotation ); levelCreate.gameObject.GetComponent <tk2dSprite>().scale = new Vector3(2.4f, 2.4f, 1); levelCreate.Giatri = ClsThaoTac.doKetQua(vio.Ketqua); levelCreate.Pheptoan = "" + vio.Congthuc; levelCreate.setData(vio.Loai); levelCreate.Trangthai = true; //levelCreate.Vitri = thutu; sp = levelCreate.GetComponent <tk2dUIItem>(); switch (thutu) { case 1: bt1 = levelCreate; sp.OnClick += onClick_sp1; break; case 2: bt2 = levelCreate; sp.OnClick += onClick_sp2; break; case 3: bt3 = levelCreate; sp.OnClick += onClick_sp3; break; case 4: bt4 = levelCreate; sp.OnClick += onClick_sp4; break; case 5: bt5 = levelCreate; sp.OnClick += onClick_sp5; break; case 6: bt6 = levelCreate; sp.OnClick += onClick_sp6; break; case 7: bt7 = levelCreate; sp.OnClick += onClick_sp7; break; case 8: bt8 = levelCreate; sp.OnClick += onClick_sp8; break; case 9: bt9 = levelCreate; sp.OnClick += onClick_sp9; break; case 10: bt10 = levelCreate; sp.OnClick += onClick_sp10; break; case 11: bt11 = levelCreate; sp.OnClick += onClick_sp11; break; case 12: bt12 = levelCreate; sp.OnClick += onClick_sp12; break; case 13: bt13 = levelCreate; sp.OnClick += onClick_sp13; break; case 14: bt14 = levelCreate; sp.OnClick += onClick_sp14; break; case 15: bt15 = levelCreate; sp.OnClick += onClick_sp15; break; case 16: bt16 = levelCreate; sp.OnClick += onClick_sp16; break; case 17: bt17 = levelCreate; sp.OnClick += onClick_sp17; break; case 18: bt18 = levelCreate; sp.OnClick += onClick_sp18; break; case 19: bt19 = levelCreate; sp.OnClick += onClick_sp19; break; case 20: bt20 = levelCreate; sp.OnClick += onClick_sp20; break; default: Debug.Log("Default case"); break; } levelCreate.transform.parent = this.gameObject.transform; }
void chonData5(ref List <PhepToan> tmg1, List <PhepToan> lstTam, int loai) { #region Singleton List <PhepToan> lstRank = new List <PhepToan>(); foreach (PhepToan item in lstTam) { if (item.Loai.Equals("" + loai)) { lstRank.Add(item); } } if (loai == 5) { 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].Congthuc, lstRank[chon].Ketqua, "number"); } else { double kqn = double.Parse(lstRank[chon].Ketqua); int gtrd = UnityEngine.Random.Range(0, 8); string stKq = ""; switch (gtrd) { case 0: stKq = kqn + " mm"; break; case 1: stKq = (kqn / 10) + " cm"; break; case 2: stKq = (kqn / 100) + " dm"; break; case 3: stKq = (kqn / 1000000) + " km"; break; case 4: stKq = (kqn / 10000) + " dam"; break; case 5: stKq = (kqn / 100000) + " hm"; break; default: stKq = (kqn / 1000) + " m"; break; } pt1 = new PhepToan(stKq, lstRank[chon].Ketqua, "number"); } tmg1.Add(pt1); lstSapXep.Add(pt1); } } } else { while (tmg1.Count < 20) { int chon = UnityEngine.Random.Range(0, lstRank.Count); bool ok = false; for (int i = 0; i < tmg1.Count; i++) { if (ClsThaoTac.doKetQua(lstRank[chon].Ketqua) == ClsThaoTac.doKetQua(tmg1[i].Ketqua)) { ok = true; break; } } if (ok == false) { PhepToan pt1; PhepToan ptTm; if (chon % 2 == 0) { if (lstRank[chon].Ketqua.Contains("/")) { pt1 = new PhepToan("" + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "phanso"); ptTm = new PhepToan("" + lstRank[chon].Ketqua, "" + ClsThaoTac.doKetQua(lstRank[chon].Ketqua), "phanso"); } else { pt1 = new PhepToan("" + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number"); ptTm = new PhepToan("" + lstRank[chon].Ketqua, "" + ClsThaoTac.doKetQua(lstRank[chon].Ketqua), "number"); } } else { string tambo = "" + lstRank[chon].Congthuc; string tambo2 = "" + lstRank[chon].Congthuc; if (tambo.Contains("c")) { string[] mang = tambo.Split('c'); if (mang[0].Contains("/") && mang[1].Contains("/")) { tambo = "phanhai"; } else if (mang[0].Contains("/")) { tambo = "phantrai"; } else if (mang[1].Contains("/")) { tambo = "phanphai"; } else { tambo = "number"; tambo2 = mang[0] + ClsLanguage.doOf() + mang[1]; } } else if (tambo.Contains("]")) { if (tambo.Contains("+") || tambo.Contains("-") || tambo.Contains("x") || tambo.Contains(":")) { tambo = "mixhai"; } else { tambo = "mix"; } } else if (tambo.Contains("/")) { if (tambo.Contains("+") || tambo.Contains("-") || tambo.Contains("x") || tambo.Contains(":")) { string[] mang = tambo.Split(new Char[] { '-', '+', 'x', ':' }); if (mang.Length >= 3) { int dem = 0; for (int i = 0; i < tambo.Count(); i++) { string dkm = "" + tambo[i]; if (dkm.Equals("/")) { dem++; } } if (dem >= 2) { tambo = "phansoba"; } else { tambo = "phanso"; } } else { if (mang[0].Contains("/") && mang[1].Contains("/")) { tambo = "phansohai"; } else if (mang[0].Contains("/")) { tambo = "phansotrai"; } else if (mang[1].Contains("/")) { tambo = "phansophai"; } else { tambo = "phanso"; } } } else { tambo = "phanso"; } } else { tambo = "number"; } pt1 = new PhepToan(tambo2, lstRank[chon].Ketqua, tambo); ptTm = new PhepToan(tambo2, "" + ClsThaoTac.doKetQua(lstRank[chon].Ketqua), tambo); } tmg1.Add(pt1); lstSapXep.Add(ptTm); } } } #endregion }
void chonData4(ref List <PhepToan> tmg1, List <PhepToan> lstTam, int loai) { #region Singleton List <PhepToan> lstRank = new List <PhepToan>(); foreach (PhepToan item in lstTam) { if (item.Loai.Equals("" + loai)) { lstRank.Add(item); } } if (loai == 16 || loai == 17 || loai == 18) { 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 % 6 == 0) { pt1 = new PhepToan("" + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number"); } else { pt1 = new PhepToan(lstRank[chon].Congthuc, lstRank[chon].Ketqua, "phantrai"); } tmg1.Add(pt1); lstSapXep.Add(pt1); } } } else if (loai == 15) { 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 = new PhepToan("" + lstRank[chon].Congthuc, lstRank[chon].Ketqua, "phanso"); tmg1.Add(pt1); PhepToan pt2 = new PhepToan("" + lstRank[chon].Congthuc, "" + ClsThaoTac.doKetQua(lstRank[chon].Ketqua), "number"); lstSapXep.Add(pt2); } } } else if (loai == 5) { 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 = new PhepToan("" + lstRank[chon].Congthuc, lstRank[chon].Ketqua, "number"); tmg1.Add(pt1); lstSapXep.Add(pt1); } } } else { lstRank = lstRank.OrderBy(p => double.Parse(p.Ketqua)).ToList(); List <PhepToan> lstTG = ClsThaoTac.FakeData(int.Parse(lstRank[0].Ketqua), int.Parse(lstRank[lstRank.Count - 1].Ketqua), 15); foreach (PhepToan item in lstTG) { lstRank.Add(item); } 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].Congthuc, lstRank[chon].Ketqua, "number"); } else { pt1 = new PhepToan("" + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number"); } tmg1.Add(pt1); lstSapXep.Add(pt1); } } } #endregion }