// Update is called once per frame
    void Update()
    {
        if (currentState == State.InGame1 || currentState == State.Click1 || currentState == State.Click2)
        {
            if (demframe < 30)
            {
                demframe++;
            }
            else
            {
                mTime--;
                txtTime.text = ClsThaoTac.CoverTimeToString(mTime);
                //if (mTime <= 10)
                //{
                //    txtTime.color = new Color(1, 0, 1, 1);
                //}

                demframe = 0;
                if (mTime <= 0)
                {
                    GameOver();
                }
            }
        }
    }
Esempio n. 2
0
    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++;
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        if (currentState != State.Start && currentState != State.Stop)
        {
            //đếm ngược thời gian từ 20 phút
            if (demframe < 30)
            {
                demframe++;
            }
            else
            {
                mTime--;
                txtTime.text = ClsThaoTac.CoverTimeToString(mTime);
                //if (mTime <= 10)
                //{
                //    txtTime.color = new Color(1, 0, 1, 1);
                //}

                demframe = 0;
                if (mTime <= 0)
                {
                    //currentState = State.Stop;
                    //hết giờ thì game over
                    doHideShow(true);
                    resetColorBt();
                    gameOver();
                }
            }
        }
    }
    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);
        }
    }
Esempio n. 5
0
    // Update is called once per frame
    void Update()
    {
        if (currentState == State.InGame1 || currentState == State.Click1)
        {
            if (demframe < 30)
            {
                demframe++;
            }
            else
            {
                mTime--;

                txtTime.text = ClsThaoTac.CoverTimeToString(mTime);
                //if (mTime <= 10)
                //{
                //    txtTime.color = new Color(1, 0, 1, 1);
                //}

                demframe = 0;
                if (mTime <= 0)
                {
                    BangSoSanh.gameObject.SetActive(false);
                    BangSoSanh.RecycleSp();
                    GameOver();
                }
            }
        }
    }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        if (currentState == State.InGame1 || currentState == State.Click1)
        {
            //đếm ngược thời gian từ 20 phút
            if (demframe < 30)
            {
                demframe++;
            }
            else
            {
                mTime--;
                txtTime.text = ClsThaoTac.CoverTimeToString(mTime);
                //if (mTime <= 10)
                //{
                //    txtTime.color = new Color(1, 0, 1, 1);
                //}

                demframe = 0;
                if (mTime <= 0)
                {
                    //hết giờ thì game over
                    GameOver();
                }
            }
        }
    }
 void gameOver()
 {
     currentState = State.Stop;
     if (diemSo < 0)
     {
         diemSo = 0;
     }
     VioGameController.instance.sumCoin += diemSo;
     VioGameController.instance.sumTime += mTime;
     VioPopUpController.instance.ShowStopThongThai(diemSo, ClsThaoTac.CoverTimeToString(1200 - mTime));
     VioPopUpController.instance.HideQuestionMonkey();
     resetDefault();
 }
Esempio n. 8
0
 void gameOver()
 {
     currentState = State.Stop;
     if (diemSo < 0)
     {
         diemSo = 0;
     }
     GameController.instance.sumCoin += diemSo;
     GameController.instance.sumTime += mTime;
     PopUpController.instance.ShowStopDinhNui(diemSo, ClsThaoTac.CoverTimeToString(1200 - mTime));
     PopUpController.instance.HideQuestionDinhNui();
     resetThongSo();
 }
Esempio n. 9
0
 void GameOver()
 {
     currentState = State.Start;
     PopUpController.instance.HideQuestionSapXep();
     if (mDiemB1 < 0)
     {
         mDiemB1 = 0;
     }
     GameController.instance.sumCoin += mDiemB1;
     GameController.instance.sumTime += mTime;
     PopUpController.instance.ShowStopSapXep(mDiemB1, ClsThaoTac.CoverTimeToString(1200 - mTime));
     resetTL();
 }
Esempio n. 10
0
    public void Create()
    {
        float positionX = startX;

        List <PhepToan> lstTMG  = new List <PhepToan>();
        List <PhepToan> lstTMG2 = new List <PhepToan>();

        if (GameController.instance.level == 1)
        {
            chonData(ref lstTMG, ref lstTMG2, ClsThaoTac.ChuanHoaDaTa(10, 80, 1, GameController.instance.lstCongTruHai), GameController.instance.level);
        }
        else if (GameController.instance.level == 2)
        {
            chonData(ref lstTMG, ref lstTMG2, ClsThaoTac.ChuanHoaDaTa(0, 50, 2, GameController.instance.lstCongTruHai), GameController.instance.level);
        }
        else if (GameController.instance.level == 3)
        {
            chonData(ref lstTMG, ref lstTMG2, ClsThaoTac.ChuanHoaDaTa(20, 80, 1, GameController.instance.lstCongTruBa), GameController.instance.level);
        }
        else if (GameController.instance.level == 4)
        {
            chonData(ref lstTMG, ref lstTMG2, ClsThaoTac.ChuanHoaDaTa(0, 40, 2, GameController.instance.lstCongTruBa), GameController.instance.level);
        }
        else if (GameController.instance.level == 5)
        {
            chonData(ref lstTMG, ref lstTMG2, GameController.instance.lstNhanHaiBa, GameController.instance.level);
        }
        else if (GameController.instance.level == 6)
        {
            chonData(ref lstTMG, ref lstTMG2, GameController.instance.lstNhanBonNam, GameController.instance.level);
        }
        else if (GameController.instance.level == 7)
        {
            chonData(ref lstTMG, ref lstTMG2, GameController.instance.lstNhanCong23, GameController.instance.level);
        }
        else if (GameController.instance.level == 8)
        {
            chonData(ref lstTMG, ref lstTMG2, GameController.instance.lstNhanCong45, GameController.instance.level);
        }
        else if (GameController.instance.level == 9)
        {
            chonData(ref lstTMG, ref lstTMG2, GameController.instance.lstNhanTru23, GameController.instance.level);
        }
        else if (GameController.instance.level == 10)
        {
            chonData(ref lstTMG, ref lstTMG2, GameController.instance.lstNhanTru45, GameController.instance.level);
        }
        else if (GameController.instance.level == 11)
        {
            chonData(ref lstTMG, ref lstTMG2, GameController.instance.lstTruNhan23, GameController.instance.level);
        }
        else if (GameController.instance.level == 12)
        {
            chonData(ref lstTMG, ref lstTMG2, GameController.instance.lstTruNhan45, GameController.instance.level);
        }
        else if (GameController.instance.level == 13)
        {
            chonData(ref lstTMG, ref lstTMG2, GameController.instance.lstChia23, GameController.instance.level);
        }
        else if (GameController.instance.level == 14)
        {
            chonData(ref lstTMG, ref lstTMG2, GameController.instance.lstChia45, GameController.instance.level);
        }
        else if (GameController.instance.level == 15)
        {
            chonData(ref lstTMG, ref lstTMG2, GameController.instance.lstCongChia23, GameController.instance.level);
        }
        else if (GameController.instance.level == 16)
        {
            chonData(ref lstTMG, ref lstTMG2, GameController.instance.lstCongChia45, GameController.instance.level);
        }
        else if (GameController.instance.level == 17)
        {
            chonData(ref lstTMG, ref lstTMG2, GameController.instance.lstTruChia23, GameController.instance.level);
        }
        else if (GameController.instance.level == 18)
        {
            chonData(ref lstTMG, ref lstTMG2, GameController.instance.lstTruChia45, GameController.instance.level);
        }
        else if (GameController.instance.level == 19 || GameController.instance.level == 20)
        {
            var bien = GameController.instance.lstNhanHaiBa.Concat(GameController.instance.lstNhanBonNam).Concat(GameController.instance.lstChia23).Concat(GameController.instance.lstChia45).ToList();

            chonData(ref lstTMG, ref lstTMG2, bien, GameController.instance.level);
        }


        int vt = 1;

        for (int i = 1; i <= 10; i++)
        {
            doPhanPhat(ref lstTMG, ref lstTMG2, ref vt, ref positionX);
        }

        foreach (Transform child in XuLy.transform)
        {
            children.Add(child.GetComponent <SpItemMonkey>());
        }
        XuatDaTa();
        txtLoading.gameObject.SetActive(false);
    }
Esempio n. 11
0
    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"));
            }
        }
    }
Esempio n. 12
0
    public void getDataLevel()
    {
        foreach (DinhNui item in GameController.instance.lstSum)
        {
            if (item.Level == GameController.instance.level)
            {
                lstLevel.Add(item);
            }
        }
        //===========================================

        if (GameController.instance.level == 1 || GameController.instance.level == 3 || GameController.instance.level == 5)
        {
            for (int i = 0; i < 30; i++)
            {
                int tm = UnityEngine.Random.Range(0, GameController.instance.lstCongTruHai.Count);
                lstPt.Add(GameController.instance.lstCongTruHai[tm]);
            }

            if (GameController.instance.level == 1)
            {
                lstPt = ClsThaoTac.ChuanHoaDaTa(0, 50, 0, lstPt);
            }
            else if (GameController.instance.level == 5)
            {
                lstPt = ClsThaoTac.ChuanHoaDaTa(0, 50, 2, lstPt);
            }
        }
        else if (GameController.instance.level == 2 || GameController.instance.level == 4 || GameController.instance.level == 6)
        {
            for (int i = 0; i < 30; i++)
            {
                int tm = UnityEngine.Random.Range(0, GameController.instance.lstCongTruBa.Count);
                lstPt.Add(GameController.instance.lstCongTruBa[tm]);
            }

            if (GameController.instance.level == 2)
            {
                lstPt = ClsThaoTac.ChuanHoaDaTa(0, 50, 0, lstPt);
            }
            else if (GameController.instance.level == 6)
            {
                lstPt = ClsThaoTac.ChuanHoaDaTa(0, 50, 2, lstPt);
            }
        }
        else if (GameController.instance.level == 7 || GameController.instance.level == 8)
        {
            for (int i = 0; i < 15; i++)
            {
                int tm = UnityEngine.Random.Range(0, GameController.instance.lstNhanHaiBa.Count);
                lstPt.Add(GameController.instance.lstNhanHaiBa[tm]);
            }
        }
        else if (GameController.instance.level == 9 || GameController.instance.level == 10)
        {
            for (int i = 0; i < 15; i++)
            {
                int tm = UnityEngine.Random.Range(0, GameController.instance.lstNhanBonNam.Count);
                lstPt.Add(GameController.instance.lstNhanBonNam[tm]);
            }
        }
        else if (GameController.instance.level == 11)
        {
            for (int i = 0; i < 30; i++)
            {
                int tm = UnityEngine.Random.Range(0, GameController.instance.lstNhanCong23.Count);
                lstPt.Add(GameController.instance.lstNhanCong23[tm]);
            }
        }
        else if (GameController.instance.level == 12)
        {
            for (int i = 0; i < 30; i++)
            {
                int tm = UnityEngine.Random.Range(0, GameController.instance.lstNhanCong45.Count);
                lstPt.Add(GameController.instance.lstNhanCong45[tm]);
            }
        }
        else if (GameController.instance.level == 13)
        {
            for (int i = 0; i < 15; i++)
            {
                int tm = UnityEngine.Random.Range(0, GameController.instance.lstNhanTru23.Count);
                lstPt.Add(GameController.instance.lstNhanTru23[tm]);
            }

            for (int i = 0; i < 15; i++)
            {
                int tm = UnityEngine.Random.Range(0, GameController.instance.lstNhanTru45.Count);
                lstPt.Add(GameController.instance.lstNhanTru45[tm]);
            }
        }
        else if (GameController.instance.level == 14)
        {
            for (int i = 0; i < 15; i++)
            {
                int tm = UnityEngine.Random.Range(0, GameController.instance.lstTruNhan23.Count);
                lstPt.Add(GameController.instance.lstTruNhan23[tm]);
            }

            for (int i = 0; i < 15; i++)
            {
                int tm = UnityEngine.Random.Range(0, GameController.instance.lstTruNhan45.Count);
                lstPt.Add(GameController.instance.lstTruNhan45[tm]);
            }
        }
        else if (GameController.instance.level == 15)
        {
            for (int i = 0; i < 15; i++)
            {
                int tm = UnityEngine.Random.Range(0, GameController.instance.lstChia23.Count);
                lstPt.Add(GameController.instance.lstChia23[tm]);
            }

            for (int i = 0; i < 15; i++)
            {
                int tm = UnityEngine.Random.Range(0, GameController.instance.lstChia45.Count);
                lstPt.Add(GameController.instance.lstChia45[tm]);
            }
        }
        else if (GameController.instance.level == 16)
        {
            for (int i = 0; i < 15; i++)
            {
                int tm = UnityEngine.Random.Range(0, GameController.instance.lstCongChia23.Count);
                lstPt.Add(GameController.instance.lstCongChia23[tm]);
            }

            for (int i = 0; i < 15; i++)
            {
                int tm = UnityEngine.Random.Range(0, GameController.instance.lstCongChia45.Count);
                lstPt.Add(GameController.instance.lstCongChia45[tm]);
            }
        }
        else if (GameController.instance.level == 17)
        {
            for (int i = 0; i < 15; i++)
            {
                int tm = UnityEngine.Random.Range(0, GameController.instance.lstTruChia23.Count);
                lstPt.Add(GameController.instance.lstTruChia23[tm]);
            }
        }
        else if (GameController.instance.level == 18)
        {
            for (int i = 0; i < 15; i++)
            {
                int tm = UnityEngine.Random.Range(0, GameController.instance.lstTruChia45.Count);
                lstPt.Add(GameController.instance.lstTruChia45[tm]);
            }
        }



        //==============================================Duoi La conver sang dinh nui


        foreach (PhepToan item in lstPt)
        {
            string   tmp  = item.Congthuc;
            string[] mang = tmp.Split(new Char[] { '-', '+', 'x', ':' });
            int      chon = UnityEngine.Random.Range(0, 3);
            int      kq   = 0;

            if (chon != 0)
            {
                if (int.Parse(item.Loai) == 51)
                {
                    int chon2 = UnityEngine.Random.Range(0, 2);
                    if (chon2 == 0)
                    {
                        tmp = ".... + " + mang[1] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[0].Trim());
                    }
                    else
                    {
                        tmp = mang[0] + "+ .... " + "= " + item.Ketqua;
                        kq  = int.Parse(mang[1].Trim());
                    }
                }
                else if (int.Parse(item.Loai) == 52)
                {
                    int chon2 = UnityEngine.Random.Range(0, 2);
                    if (chon2 == 0)
                    {
                        tmp = ".... - " + mang[1] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[0].Trim());
                    }
                    else
                    {
                        tmp = mang[0] + "- .... " + "= " + item.Ketqua;
                        kq  = int.Parse(mang[1].Trim());
                    }
                }
                else if (int.Parse(item.Loai) == 53)
                {
                    int chon2 = UnityEngine.Random.Range(0, 3);
                    if (chon2 == 0)
                    {
                        tmp = ".... + " + mang[1] + " + " + mang[2] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[0].Trim());
                    }
                    else if (chon2 == 1)
                    {
                        tmp = mang[0] + " +....+ " + mang[2] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[1].Trim());
                    }
                    else
                    {
                        tmp = mang[0] + " + " + mang[1] + " +....." + "= " + item.Ketqua;
                        kq  = int.Parse(mang[2].Trim());
                    }
                }
                else if (int.Parse(item.Loai) == 54)
                {
                    int chon2 = UnityEngine.Random.Range(0, 3);
                    if (chon2 == 0)
                    {
                        tmp = ".... + " + mang[1] + " - " + mang[2] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[0].Trim());
                    }
                    else if (chon2 == 1)
                    {
                        tmp = mang[0] + " + .... - " + mang[2] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[1].Trim());
                    }
                    else
                    {
                        tmp = mang[0] + " + " + mang[1] + " -....." + "= " + item.Ketqua;
                        kq  = int.Parse(mang[2].Trim());
                    }
                }
                else if (int.Parse(item.Loai) == 55)
                {
                    int chon2 = UnityEngine.Random.Range(0, 3);
                    if (chon2 == 0)
                    {
                        tmp = ".... - " + mang[1] + " + " + mang[2] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[0].Trim());
                    }
                    else if (chon2 == 1)
                    {
                        tmp = mang[0] + " - .... + " + mang[2] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[1].Trim());
                    }
                    else
                    {
                        tmp = mang[0] + " - " + mang[1] + " +....." + "= " + item.Ketqua;
                        kq  = int.Parse(mang[2].Trim());
                    }
                }
                else if (int.Parse(item.Loai) == 56)
                {
                    int chon2 = UnityEngine.Random.Range(0, 3);
                    if (chon2 == 0)
                    {
                        tmp = ".... - " + mang[1] + " - " + mang[2] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[0].Trim());
                    }
                    else if (chon2 == 1)
                    {
                        tmp = mang[0] + " - .... - " + mang[2] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[1].Trim());
                    }
                    else
                    {
                        tmp = mang[0] + " - " + mang[1] + " - ....." + "= " + item.Ketqua;
                        kq  = int.Parse(mang[2].Trim());
                    }
                }
                else if (int.Parse(item.Loai) == 57 || int.Parse(item.Loai) == 58 || int.Parse(item.Loai) == 59 || int.Parse(item.Loai) == 60)
                {
                    int chon2 = UnityEngine.Random.Range(0, 2);
                    if (chon2 == 0)
                    {
                        tmp = ".... x " + mang[1] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[0].Trim());
                    }
                    else
                    {
                        tmp = mang[0] + " x ..... = " + item.Ketqua;
                        kq  = int.Parse(mang[1].Trim());
                    }
                }
                else if (int.Parse(item.Loai) == 61 || int.Parse(item.Loai) == 62 || int.Parse(item.Loai) == 63 || int.Parse(item.Loai) == 64)
                {
                    int chon2 = UnityEngine.Random.Range(0, 3);
                    if (chon2 == 0)
                    {
                        tmp = ".... x " + mang[1] + " + " + mang[2] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[0].Trim());
                    }
                    else if (chon2 == 1)
                    {
                        tmp = mang[0] + " x .... + " + mang[2] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[1].Trim());
                    }
                    else
                    {
                        tmp = mang[0] + " x " + mang[1] + " + ....." + "= " + item.Ketqua;
                        kq  = int.Parse(mang[2].Trim());
                    }
                }
                else if (int.Parse(item.Loai) == 65 || int.Parse(item.Loai) == 66 || int.Parse(item.Loai) == 67 || int.Parse(item.Loai) == 68)
                {
                    int chon2 = UnityEngine.Random.Range(0, 3);
                    if (chon2 == 0)
                    {
                        tmp = ".... x " + mang[1] + " - " + mang[2] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[0].Trim());
                    }
                    else if (chon2 == 1)
                    {
                        tmp = mang[0] + " x .... - " + mang[2] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[1].Trim());
                    }
                    else
                    {
                        tmp = mang[0] + " x " + mang[1] + " - ....." + "= " + item.Ketqua;
                        kq  = int.Parse(mang[2].Trim());
                    }
                }
                else if (int.Parse(item.Loai) == 69 || int.Parse(item.Loai) == 70 || int.Parse(item.Loai) == 71 || int.Parse(item.Loai) == 72)
                {
                    int chon2 = UnityEngine.Random.Range(0, 3);
                    if (chon2 == 0)
                    {
                        tmp = ".... - " + mang[1] + " x " + mang[2] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[0].Trim());
                    }
                    else if (chon2 == 1)
                    {
                        tmp = mang[0] + " - .... x " + mang[2] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[1].Trim());
                    }
                    else
                    {
                        tmp = mang[0] + " - " + mang[1] + " x ....." + "= " + item.Ketqua;
                        kq  = int.Parse(mang[2].Trim());
                    }
                }
                else if (int.Parse(item.Loai) == 73 || int.Parse(item.Loai) == 74 || int.Parse(item.Loai) == 75 || int.Parse(item.Loai) == 76)
                {
                    int chon2 = UnityEngine.Random.Range(0, 2);
                    if (chon2 == 0)
                    {
                        tmp = ".... : " + mang[1] + "= " + item.Ketqua;
                        kq  = int.Parse(mang[0].Trim());
                    }
                    else
                    {
                        tmp = mang[0] + " : .... " + "= " + item.Ketqua;
                        kq  = int.Parse(mang[1].Trim());
                    }
                }
                else if (int.Parse(item.Loai) >= 77 && int.Parse(item.Loai) <= 84)
                {
                    tmp = item.Congthuc + " = ....?";
                    kq  = item.Ketqua;
                }
                //them o day
            }
            else
            {
                tmp = item.Congthuc + " = ....?";
                kq  = item.Ketqua;
            }

            tmp = ClsLanguage.doFillNumber() + tmp;

            List <int> lstTH = new List <int>();

            lstTH.Add(doChonSai(kq));
            lstTH.Add(doChonSai(kq));
            lstTH.Add(doChonSai(kq));


            DinhNui dn = new DinhNui();
            dn.Question  = tmp;
            dn.Giaithich = item.Congthuc + "=" + item.Ketqua;

            List <int> lstVt = new List <int>();
            lstVt.Add(1);
            lstVt.Add(2);
            lstVt.Add(3);
            lstVt.Add(4);
            int vtd = UnityEngine.Random.Range(0, lstVt.Count);
            if (lstVt[vtd] == 1)
            {
                dn.Casea = "" + kq;
            }
            else if (lstVt[vtd] == 2)
            {
                dn.Caseb = "" + kq;
            }
            else if (lstVt[vtd] == 3)
            {
                dn.Casec = "" + kq;
            }
            else if (lstVt[vtd] == 4)
            {
                dn.Cased = "" + kq;
            }
            dn.Truecase = lstVt[vtd];
            lstVt.RemoveAt(vtd);

            //----het dung



            if (lstVt[0] == 1)
            {
                dn.Casea = "" + lstTH[0];
            }
            else if (lstVt[0] == 2)
            {
                dn.Caseb = "" + lstTH[0];
            }
            else if (lstVt[0] == 3)
            {
                dn.Casec = "" + lstTH[0];
            }
            else
            {
                dn.Cased = "" + lstTH[0];
            }
            lstTH.RemoveAt(0);
            lstVt.RemoveAt(0);



            if (lstVt[0] == 1)
            {
                dn.Casea = "" + lstTH[0];
            }
            else if (lstVt[0] == 2)
            {
                dn.Caseb = "" + lstTH[0];
            }
            else if (lstVt[0] == 3)
            {
                dn.Casec = "" + lstTH[0];
            }
            else
            {
                dn.Cased = "" + lstTH[0];
            }
            lstTH.RemoveAt(0);
            lstVt.RemoveAt(0);



            if (lstVt[0] == 1)
            {
                dn.Casea = "" + lstTH[0];
            }
            else if (lstVt[0] == 2)
            {
                dn.Caseb = "" + lstTH[0];
            }
            else if (lstVt[0] == 3)
            {
                dn.Casec = "" + lstTH[0];
            }
            else
            {
                dn.Cased = "" + lstTH[0];
            }
            lstTH.RemoveAt(0);
            lstVt.RemoveAt(0);


            lstLevel.Add(dn);
        }



        doSubGet(ref lstLevel);
        currentState = State.InGame;
    }
Esempio n. 13
0
    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
    }
Esempio n. 14
0
    void chonData(ref List <PhepToan> tmg1, List <PhepToan> lstRank, int loai)
    {
        #region Singleton
        if (loai == 4 || loai == 5 || loai == 19 || loai == 20)
        {
            //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 (lstRank[chon].Ketqua % 7 == 0)
                    {
                        pt1 = new PhepToan(ClsLanguage.doNumber() + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                    }
                    else if (lstRank[chon].Ketqua % 4 == 0)
                    {
                        pt1 = new PhepToan("" + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                    }
                    else
                    {
                        int nh = UnityEngine.Random.Range(0, 10);
                        if (nh == 0)
                        {
                            if (lstRank[chon].Ketqua > 1)
                            {
                                pt1 = new PhepToan(ClsLanguage.doSoLienSau() + (lstRank[chon].Ketqua - 1), lstRank[chon].Ketqua, "number");
                            }
                            else
                            {
                                pt1 = new PhepToan(ClsLanguage.doSoLienTruoc() + (lstRank[chon].Ketqua + 1), lstRank[chon].Ketqua, "number");
                            }
                        }
                        else if (nh == 1)
                        {
                            pt1 = new PhepToan(ClsLanguage.doSoLienTruoc() + (lstRank[chon].Ketqua + 1), lstRank[chon].Ketqua, "number");
                        }
                        else if (nh == 2)
                        {
                            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 == 6 || loai == 7 || loai == 9 || loai == 10 || loai == 11 || loai == 12 || loai == 13 || loai == 14 || loai == 17 || loai == 18)
        {
            //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 (lstRank[chon].Ketqua % 7 == 0)
                    {
                        pt1 = new PhepToan(ClsLanguage.doNumber() + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                    }
                    else if (lstRank[chon].Ketqua % 4 == 0)
                    {
                        pt1 = new PhepToan("" + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                    }
                    else
                    {
                        int nh = UnityEngine.Random.Range(0, 7);
                        if (nh == 0)
                        {
                            if (lstRank[chon].Ketqua > 1)
                            {
                                pt1 = new PhepToan(ClsLanguage.doSoLienSau() + (lstRank[chon].Ketqua - 1), lstRank[chon].Ketqua, "number");
                            }
                            else
                            {
                                pt1 = new PhepToan(ClsLanguage.doSoLienTruoc() + (lstRank[chon].Ketqua + 1), lstRank[chon].Ketqua, "number");
                            }
                        }
                        else if (nh == 1)
                        {
                            pt1 = new PhepToan(ClsLanguage.doSoLienTruoc() + (lstRank[chon].Ketqua + 1), lstRank[chon].Ketqua, "number");
                        }
                        else
                        {
                            pt1 = new PhepToan("" + lstRank[chon].Congthuc, lstRank[chon].Ketqua, "number");
                        }
                    }

                    tmg1.Add(pt1);
                    lstSapXep.Add(pt1);
                }
            }
        }
        else if (loai == 8 || loai == 15 || loai == 16)
        {
            //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 (lstRank[chon].Ketqua % 7 == 0 && lstRank[chon].Loai.Equals("number"))
                    {
                        pt1 = new PhepToan(ClsLanguage.doNumber() + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                    }
                    else if (lstRank[chon].Ketqua % 4 == 0 && lstRank[chon].Loai.Equals("number"))
                    {
                        pt1 = new PhepToan("" + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                    }
                    else
                    {
                        int nh = UnityEngine.Random.Range(0, 7);
                        if (nh == 0 && lstRank[chon].Loai.Equals("number"))
                        {
                            if (lstRank[chon].Ketqua > 1)
                            {
                                pt1 = new PhepToan(ClsLanguage.doSoLienSau() + (lstRank[chon].Ketqua - 1), lstRank[chon].Ketqua, "number");
                            }
                            else
                            {
                                pt1 = new PhepToan(ClsLanguage.doSoLienTruoc() + (lstRank[chon].Ketqua + 1), lstRank[chon].Ketqua, "number");
                            }
                        }
                        else if (nh == 1 && lstRank[chon].Loai.Equals("number"))
                        {
                            pt1 = new PhepToan(ClsLanguage.doSoLienTruoc() + (lstRank[chon].Ketqua + 1), lstRank[chon].Ketqua, "number");
                        }
                        else if (nh == 2)
                        {
                            pt1 = ClsThaoTac.getCongThuc(lstRank[chon]);
                        }
                        else
                        {
                            pt1 = new PhepToan("" + lstRank[chon].Congthuc, lstRank[chon].Ketqua, "number");
                        }
                    }

                    tmg1.Add(pt1);
                    lstSapXep.Add(pt1);
                }
            }
        }



        #endregion
    }
Esempio n. 15
0
    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
    }
Esempio n. 16
0
    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
    }
    public void Create()
    {
        #region Singleton

        float           positionX = startX;
        float           positionY = startY;
        List <PhepToan> lstTMG    = new List <PhepToan>();

        int sl = 12;

        if (GameController.instance.level == 4 || GameController.instance.level == 5)
        {
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 1).ToList();
            chonData(12, sl, 2, ref lstTMG, ref lstSapXep, query);
        }
        else if (GameController.instance.level == 6)
        {
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 1).ToList();
            chonData(12, sl, 4, ref lstTMG, ref lstSapXep, query);
            //phep toan vs hoa qua
        }
        else if (GameController.instance.level == 7)
        {
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 1).ToList();
            chonData(12, sl, 6, ref lstTMG, ref lstSapXep, query);
        }
        else if (GameController.instance.level == 8)
        {
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 1).ToList();
            chonData(12, sl, 5, ref lstTMG, ref lstSapXep, query);
        }
        else if (GameController.instance.level == 9)
        {
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 2).ToList();
            chonData(12, sl, 3, ref lstTMG, ref lstSapXep, query);

            //int GT = 12;

            //chonData(GT, sl, 3, ref lstTMG, ref lstSapXep, clsThaoTac.ChuanHoaData(GT, GameController.instance.lst2));
        }
        else if (GameController.instance.level == 10)
        {
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 2).ToList();
            chonData(12, sl, 6, ref lstTMG, ref lstSapXep, query);
        }
        else if (GameController.instance.level == 11)
        {
            // chonData(12, sl, 3, ref lstTMG, ref lstSapXep, GameController.instance.lst3);

            int GT    = 12;
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 3).ToList();

            chonData(GT, sl, 3, ref lstTMG, ref lstSapXep, ClsThaoTac.ChuanHoaDaTa(GT, query, 1));
        }
        else if (GameController.instance.level == 12)
        {
            int GT = 12;

            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 3).ToList();
            chonData(GT, sl, 6, ref lstTMG, ref lstSapXep, ClsThaoTac.ChuanHoaDaTa(GT, query, 1));
        }
        else if (GameController.instance.level == 13)
        {
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 4).ToList();
            int GT    = 12;
            chonData(GT, sl, 3, ref lstTMG, ref lstSapXep, ClsThaoTac.ChuanHoaDaTa(GT, query, 1));
        }
        else if (GameController.instance.level == 14)
        {
            int GT    = 12;
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 4).ToList();
            chonData(GT, sl, 1, ref lstTMG, ref lstSapXep, ClsThaoTac.ChuanHoaDaTa(GT, query, 1));
        }
        else if (GameController.instance.level == 15)
        {
            int GT    = 12;
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 5).ToList();
            chonData(GT, sl, 3, ref lstTMG, ref lstSapXep, ClsThaoTac.ChuanHoaDaTa(GT, query, 1));
        }
        else if (GameController.instance.level == 16)
        {
            int GT    = 12;
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 5).ToList();
            chonData(GT, sl, 6, ref lstTMG, ref lstSapXep, ClsThaoTac.ChuanHoaDaTa(GT, query, 1));
        }
        else if (GameController.instance.level == 17)
        {
            int GT    = 12;
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 6).ToList();
            chonData(GT, sl, 3, ref lstTMG, ref lstSapXep, ClsThaoTac.ChuanHoaDaTa(GT, query, 1));
        }
        else if (GameController.instance.level == 18)
        {
            int GT    = 12;
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 6).ToList();
            chonData(GT, sl, 6, ref lstTMG, ref lstSapXep, ClsThaoTac.ChuanHoaDaTa(GT, query, 1));
        }
        else if (GameController.instance.level == 19)
        {
            int GT = 12;

            chonData(GT, sl, 3, ref lstTMG, ref lstSapXep, GameController.instance.lstPhepToan1);
        }
        else if (GameController.instance.level == 20)
        {
            int GT = 12;
            chonData(GT, sl, 2, ref lstTMG, ref lstSapXep, GameController.instance.lstPhepToan1);
        }



        #endregion

        lstSapXep = lstSapXep.OrderBy(p => double.Parse(p.Ketqua)).ToList();

        //foreach (PhepToan item in lstSapXep)
        //{
        //    Debug.Log(""+item.Congthuc+" gt:"+item.Ketqua);
        //}


        if (checkCreate)
        {
            int vt = 1;

            for (int i = 0; i < 12; i++)
            {
                doPhanPhat(ref lstTMG, ref vt, ref positionX, ref positionY);
            }

            checkCreate = false;
        }
        else
        {
            setDataLst(ref lstTMG);
        }

        currentState = State.InGame1;
        txtLoading.gameObject.SetActive(false);
    }
Esempio n. 18
0
    void chonData(ref List <PhepToan> tmg1, ref List <PhepToan> tmg2, List <PhepToan> lstRank, int loai)
    {
        if (loai == 1)
        {
            while (tmg1.Count < 8)
            {
                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 (lstRank[chon].Ketqua % 3 == 0)
                    {
                        pt1 = new PhepToan(ClsLanguage.doNumber() + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                    }
                    else
                    {
                        pt1 = new PhepToan("" + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                    }
                    PhepToan pt2 = new PhepToan("" + lstRank[chon].Congthuc, lstRank[chon].Ketqua, "number");

                    if (lstRank[chon].Ketqua % 2 == 0)
                    {
                        tmg1.Add(pt1);
                        tmg2.Add(pt2);
                    }
                    else
                    {
                        tmg1.Add(pt2);
                        tmg2.Add(pt1);
                    }
                }
            }

            PhepToan pt    = new PhepToan("" + ClsLanguage.doHinhTron(), -1, "number");
            PhepToan pta   = new PhepToan("", -1, "monkeyhinhtron");
            int      chons = UnityEngine.Random.Range(0, 3);
            if (chons == 0)
            {
                tmg1.Add(pt);
                tmg2.Add(pta);
            }
            else
            {
                tmg1.Add(pta);
                tmg2.Add(pt);
            }

            PhepToan pt11  = new PhepToan("" + ClsLanguage.doHinhChuNhat(), -4, "number");
            PhepToan pta1  = new PhepToan("", -4, "monkeyhinhchunhat");
            int      chonk = UnityEngine.Random.Range(0, 3);
            if (chonk == 0)
            {
                tmg1.Add(pt11);
                tmg2.Add(pta1);
            }
            else
            {
                tmg1.Add(pta1);
                tmg2.Add(pt11);
            }
        }
        else if (loai == 2)
        {
            while (tmg1.Count < 8)
            {
                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 (lstRank[chon].Ketqua % 4 == 0)
                    {
                        pt1 = new PhepToan(ClsLanguage.doNumber() + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                    }
                    else if (lstRank[chon].Ketqua % 3 == 0)
                    {
                        int nh = UnityEngine.Random.Range(0, 3);
                        if (nh == 0)
                        {
                            if (lstRank[chon].Ketqua > 1)
                            {
                                pt1 = new PhepToan(ClsLanguage.doSoLienSau() + (lstRank[chon].Ketqua - 1), lstRank[chon].Ketqua, "number");
                            }
                            else
                            {
                                pt1 = new PhepToan(ClsLanguage.doSoLienTruoc() + (lstRank[chon].Ketqua + 1), lstRank[chon].Ketqua, "number");
                            }
                        }
                        else
                        {
                            pt1 = new PhepToan(ClsLanguage.doSoLienTruoc() + (lstRank[chon].Ketqua + 1), lstRank[chon].Ketqua, "number");
                        }
                    }
                    else
                    {
                        int chon1 = UnityEngine.Random.Range(0, 2);
                        if (chon1 == 0)
                        {
                            pt1 = new PhepToan("" + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                        }
                        else
                        {
                            pt1 = ClsThaoTac.getPhepToan(lstRank[chon], lstRank);
                        }
                    }
                    PhepToan pt2 = new PhepToan("" + lstRank[chon].Congthuc, lstRank[chon].Ketqua, "number");
                    if (chon % 2 == 0)
                    {
                        tmg1.Add(pt1);
                        tmg2.Add(pt2);
                    }
                    else
                    {
                        tmg1.Add(pt2);
                        tmg2.Add(pt1);
                    }
                }
            }

            PhepToan pt    = new PhepToan("" + ClsLanguage.doHinhVuong(), -3, "number");
            PhepToan pta   = new PhepToan("", -3, "monkeyhinhvuong");
            int      chons = UnityEngine.Random.Range(0, 3);
            if (chons == 0)
            {
                tmg1.Add(pt);
                tmg2.Add(pta);
            }
            else
            {
                tmg1.Add(pta);
                tmg2.Add(pt);
            }


            PhepToan pt11  = new PhepToan("" + ClsLanguage.doHinhChuNhat(), -4, "number");
            PhepToan pta1  = new PhepToan("", -4, "monkeyhinhchunhat");
            int      chonk = UnityEngine.Random.Range(0, 3);
            if (chonk == 0)
            {
                tmg1.Add(pt11);
                tmg2.Add(pta1);
            }
            else
            {
                tmg1.Add(pta1);
                tmg2.Add(pt11);
            }
        }
        else if (loai == 3)
        {
            while (tmg1.Count < 8)
            {
                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 (lstRank[chon].Ketqua % 4 == 0)
                    {
                        pt1 = new PhepToan(ClsLanguage.doNumber() + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                    }
                    else if (lstRank[chon].Ketqua % 3 == 0)
                    {
                        int nh = UnityEngine.Random.Range(0, 3);
                        if (nh == 0)
                        {
                            if (lstRank[chon].Ketqua > 1)
                            {
                                pt1 = new PhepToan(ClsLanguage.doSoLienSau() + (lstRank[chon].Ketqua - 1), lstRank[chon].Ketqua, "number");
                            }
                            else
                            {
                                pt1 = new PhepToan(ClsLanguage.doSoLienTruoc() + (lstRank[chon].Ketqua + 1), lstRank[chon].Ketqua, "number");
                            }
                        }
                        else
                        {
                            pt1 = new PhepToan(ClsLanguage.doSoLienTruoc() + (lstRank[chon].Ketqua + 1), lstRank[chon].Ketqua, "number");
                        }
                    }
                    else
                    {
                        pt1 = new PhepToan("" + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                    }
                    PhepToan pt2 = new PhepToan("" + lstRank[chon].Congthuc, lstRank[chon].Ketqua, "number");
                    if (chon % 2 == 0)
                    {
                        tmg1.Add(pt1);
                        tmg2.Add(pt2);
                    }
                    else
                    {
                        tmg1.Add(pt2);
                        tmg2.Add(pt1);
                    }
                }
            }

            PhepToan pt    = new PhepToan("" + ClsLanguage.doHinhNguGiac(), -6, "number");
            PhepToan pta   = new PhepToan("", -6, "monkeyhinhngugiac");
            int      chons = UnityEngine.Random.Range(0, 3);
            if (chons == 0)
            {
                tmg1.Add(pt);
                tmg2.Add(pta);
            }
            else
            {
                tmg1.Add(pta);
                tmg2.Add(pt);
            }


            PhepToan pt11  = new PhepToan("" + ClsLanguage.doHinhLucGiac(), -7, "number");
            PhepToan pta1  = new PhepToan("", -7, "monkeyhinhlucgiac");
            int      chonk = UnityEngine.Random.Range(0, 3);
            if (chonk == 0)
            {
                tmg1.Add(pt11);
                tmg2.Add(pta1);
            }
            else
            {
                tmg1.Add(pta1);
                tmg2.Add(pt11);
            }
        }
        else if (loai == 4 || loai == 7 || loai == 8 || loai == 9 || loai == 10 || loai == 11 || loai == 12 || loai == 15 || loai == 16 || loai == 17 || loai == 18)
        {
            while (tmg1.Count < 10)
            {
                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 (lstRank[chon].Ketqua % 4 == 0)
                    {
                        pt1 = new PhepToan(ClsLanguage.doNumber() + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                    }
                    else if (lstRank[chon].Ketqua % 3 == 0)
                    {
                        int nh = UnityEngine.Random.Range(0, 3);
                        if (nh == 0)
                        {
                            if (lstRank[chon].Ketqua > 1)
                            {
                                pt1 = new PhepToan(ClsLanguage.doSoLienSau() + (lstRank[chon].Ketqua - 1), lstRank[chon].Ketqua, "number");
                            }
                            else
                            {
                                pt1 = new PhepToan(ClsLanguage.doSoLienTruoc() + (lstRank[chon].Ketqua + 1), lstRank[chon].Ketqua, "number");
                            }
                        }
                        else
                        {
                            pt1 = new PhepToan(ClsLanguage.doSoLienTruoc() + (lstRank[chon].Ketqua + 1), lstRank[chon].Ketqua, "number");
                        }
                    }
                    else
                    {
                        int chon1 = UnityEngine.Random.Range(0, 2);
                        if (chon1 == 0)
                        {
                            pt1 = new PhepToan("" + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                        }
                        else
                        {
                            pt1 = ClsThaoTac.getPhepToan(lstRank[chon], lstRank);
                        }
                    }
                    PhepToan pt2 = new PhepToan("" + lstRank[chon].Congthuc, lstRank[chon].Ketqua, "number");
                    if (chon % 2 == 0)
                    {
                        tmg1.Add(pt1);
                        tmg2.Add(pt2);
                    }
                    else
                    {
                        tmg1.Add(pt2);
                        tmg2.Add(pt1);
                    }
                }
            }
        }
        else if (loai == 5 || loai == 6 || loai == 13 || loai == 14)
        {
            while (tmg1.Count < 10)
            {
                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 (lstRank[chon].Ketqua % 4 == 0)
                    {
                        if (chon % 2 == 0)
                        {
                            pt1 = new PhepToan("" + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                        }
                        else
                        {
                            pt1 = new PhepToan(ClsLanguage.doNumber() + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                        }
                    }
                    else if (lstRank[chon].Ketqua % 3 == 0)
                    {
                        int nh = UnityEngine.Random.Range(0, 3);
                        if (nh == 0)
                        {
                            if (lstRank[chon].Ketqua > 1)
                            {
                                pt1 = new PhepToan(ClsLanguage.doSoLienSau() + (lstRank[chon].Ketqua - 1), lstRank[chon].Ketqua, "number");
                            }
                            else
                            {
                                pt1 = new PhepToan(ClsLanguage.doSoLienTruoc() + (lstRank[chon].Ketqua + 1), lstRank[chon].Ketqua, "number");
                            }
                        }
                        else
                        {
                            pt1 = new PhepToan(ClsLanguage.doSoLienTruoc() + (lstRank[chon].Ketqua + 1), lstRank[chon].Ketqua, "number");
                        }
                    }
                    else
                    {
                        pt1 = new PhepToan("" + lstRank[chon].Ketqua, lstRank[chon].Ketqua, "number");
                    }
                    PhepToan pt2;
                    if (chon % 2 == 0)
                    {
                        pt2 = new PhepToan("" + lstRank[chon].Congthuc, lstRank[chon].Ketqua, "number");
                    }
                    else
                    {
                        pt2 = ClsThaoTac.getCongThuc(lstRank[chon]);
                    }

                    if (chon % 2 == 0)
                    {
                        tmg1.Add(pt1);
                        tmg2.Add(pt2);
                    }
                    else
                    {
                        tmg1.Add(pt2);
                        tmg2.Add(pt1);
                    }
                }
            }
        }
        else if (loai == 19)
        {
            var bien = GameController.instance.lstCongTruHai.Concat(GameController.instance.lstCongTruBa).ToList();
            while (tmg1.Count < 10)
            {
                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");
                    PhepToan pt2 = ClsThaoTac.getPhepToan(lstRank[chon], bien);
                    if (chon % 2 == 0)
                    {
                        tmg1.Add(pt1);
                        tmg2.Add(pt2);
                    }
                    else
                    {
                        tmg1.Add(pt2);
                        tmg2.Add(pt1);
                    }
                }
            }
        }
        else if (loai == 20)
        {
            var bien = GameController.instance.lstNhanCong23.Concat(GameController.instance.lstNhanCong45).Concat(GameController.instance.lstNhanTru23).Concat(GameController.instance.lstNhanTru45).Concat(GameController.instance.lstTruNhan23).Concat(GameController.instance.lstTruNhan45).ToList();
            while (tmg1.Count < 10)
            {
                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");
                    PhepToan pt2 = ClsThaoTac.getPhepToan(lstRank[chon], bien);
                    if (chon % 2 == 0)
                    {
                        tmg1.Add(pt1);
                        tmg2.Add(pt2);
                    }
                    else
                    {
                        tmg1.Add(pt2);
                        tmg2.Add(pt1);
                    }
                }
            }
        }
    }
Esempio n. 19
0
    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;
    }
Esempio n. 20
0
    public void getDataLevel()
    {
        if (GameController.instance.mGrade == 1)
        {
            if (GameController.instance.level == 1 || GameController.instance.level == 2 || GameController.instance.level == 3)
            {
                string tao     = "";
                string loai    = "tao";
                string tenloai = ClsLanguage.doQuaTao();

                if (GameController.instance.level == 2)
                {
                    loai    = "hoa";
                    tenloai = ClsLanguage.doBongHoa();
                }

                if (GameController.instance.level == 3)
                {
                    loai    = "meo";
                    tenloai = ClsLanguage.doConMeo();
                }

                List <int> lst = new List <int>();
                for (int i = 1; i <= 10; i++)
                {
                    DinhNui dn;
                    tao = loai + i;
                    int chon = UnityEngine.Random.Range(0, 4) + 1;
                    dn = new DinhNui(tao, i + " ", "", "", "", chon, i + " " + tenloai, GameController.instance.level);
                    lst.Add(i);
                    switch (chon)
                    {
                    case 1:
                        dn.Casea = i + " " + tenloai;


                        dn.Caseb = doChonCase(ref lst, 0, 10) + " " + tenloai;

                        dn.Casec = doChonCase(ref lst, 0, 10) + " " + tenloai;
                        dn.Cased = doChonCase(ref lst, 0, 10) + " " + tenloai;


                        break;

                    case 2:
                        dn.Caseb = i + " " + tenloai;

                        dn.Casea = doChonCase(ref lst, 0, 10) + " " + tenloai;

                        dn.Casec = doChonCase(ref lst, 0, 10) + " " + tenloai;
                        dn.Cased = doChonCase(ref lst, 0, 10) + " " + tenloai;

                        break;

                    case 3:
                        dn.Casec = i + " " + tenloai;

                        dn.Caseb = doChonCase(ref lst, 0, 10) + " " + tenloai;

                        dn.Casea = doChonCase(ref lst, 0, 10) + " " + tenloai;
                        dn.Cased = doChonCase(ref lst, 0, 10) + " " + tenloai;


                        break;

                    case 4:
                        dn.Cased = i + " " + tenloai;


                        dn.Caseb = doChonCase(ref lst, 0, 10) + " " + tenloai;

                        dn.Casec = doChonCase(ref lst, 0, 10) + " " + tenloai;
                        dn.Casea = doChonCase(ref lst, 0, 10) + " " + tenloai;


                        break;
                    }
                    lstLevel.Add(dn);

                    lst.Clear();
                }
            }
            else if (GameController.instance.level >= 4 && GameController.instance.level <= 8)
            {
                var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 1).ToList();
                lstLevel = lstCover(query);
            }
            else if (GameController.instance.level == 9 || GameController.instance.level == 10)
            {
                var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 2).ToList();
                lstLevel = lstCover(query);
            }
            else if (GameController.instance.level == 11 || GameController.instance.level == 12)
            {
                var query = ClsThaoTac.ChuanHoaDaTa(12, GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 3).ToList(), 1);
                lstLevel = lstCover(query);
            }
            else if (GameController.instance.level == 13 || GameController.instance.level == 14)
            {
                var query = ClsThaoTac.ChuanHoaDaTa(12, GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 4).ToList(), 1);
                lstLevel = lstCover(query);
            }
            else if (GameController.instance.level == 15 || GameController.instance.level == 16)
            {
                var query = ClsThaoTac.ChuanHoaDaTa(12, GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 5).ToList(), 1);
                lstLevel = lstCover(query);
            }
            else if (GameController.instance.level == 17 || GameController.instance.level == 18)
            {
                var query = ClsThaoTac.ChuanHoaDaTa(12, GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 6).ToList(), 1);
                lstLevel = lstCover(query);
            }
            else if (GameController.instance.level == 19 || GameController.instance.level == 20)
            {
                lstLevel = lstCover(GameController.instance.lstPhepToan1);
            }
        }
        else
        {
            foreach (DinhNui item in GameController.instance.lstSumTam)
            {
                if (item.Level == GameController.instance.level)
                {
                    lstLevel.Add(item);
                }
            }
        }



        doSubGet(ref lstLevel);
        currentState = State.InGame;
    }
    public void Create()
    {
        float           positionX = startX;
        float           positionY = startY;
        List <PhepToan> lstTMG    = new List <PhepToan>();

        int sl = 12;

        if (GameController.instance.level == 1 || GameController.instance.level == 2 || GameController.instance.level == 3)
        {
            string loai     = "";
            string nameType = "";


            for (int i = 1; i <= ((sl / 2) - 1); i++)
            {
                int chontmg = UnityEngine.Random.Range(0, 4);

                if (chontmg == 0)
                {
                    loai     = "meo";
                    nameType = ClsLanguage.doConMeo();
                }
                else if (chontmg == 1)
                {
                    loai     = "hoa";
                    nameType = ClsLanguage.doBongHoa();
                }
                else
                {
                    loai     = "tao";
                    nameType = ClsLanguage.doQuaTao();
                }

                loai = loai + "" + i;
                if (i > 10)
                {
                    loai = "number";
                }
                PhepToan vo = new PhepToan("" + i, "" + i, loai);
                PhepToan vi = new PhepToan("" + i + " " + nameType, "" + i, "number");
                lstTMG.Add(vo);
                lstTMG.Add(vi);
                // lstSapXep.Add(i);
            }

            if (GameController.instance.level == 1)
            {
                loai     = "hinhtron";
                nameType = ClsLanguage.doHinhTron();

                PhepToan vo = new PhepToan("", "" + (-1), loai);
                PhepToan vi = new PhepToan("" + nameType, "" + (-1), "number");
                lstTMG.Add(vo);
                lstTMG.Add(vi);
            }
            else if (GameController.instance.level == 2)
            {
                loai     = "hinhtamgiac";
                nameType = ClsLanguage.doHinhTamGiac();

                PhepToan vo = new PhepToan("", "" + (-2), loai);
                PhepToan vi = new PhepToan("" + nameType, "" + (-2), "number");
                lstTMG.Add(vo);
                lstTMG.Add(vi);
            }
            else
            {
                loai     = "hinhvuong";
                nameType = ClsLanguage.doHinhVuong();

                PhepToan vo = new PhepToan("", "" + (-3), loai);
                PhepToan vi = new PhepToan("" + nameType, "" + (-3), "number");
                lstTMG.Add(vo);
                lstTMG.Add(vi);
            }
        }
        else if (GameController.instance.level == 4 || GameController.instance.level == 5)
        {
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 1).ToList();
            chonData(6, 2, ref lstTMG, query);
        }
        else if (GameController.instance.level == 6)
        {
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 2).ToList();
            chonData(6, 5, ref lstTMG, query);
            // phep toan vs phep toan lst2
        }
        else if (GameController.instance.level == 7)
        {
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 1).ToList();
            chonData(6, 6, ref lstTMG, query);
        }
        else if (GameController.instance.level == 8)
        {
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 1).ToList();
            chonData(6, 7, ref lstTMG, query);
        }
        else if (GameController.instance.level == 9)
        {
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 2).ToList();
            chonData(6, 1, ref lstTMG, query);
        }
        else if (GameController.instance.level == 10)
        {
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 2).ToList();
            chonData(6, 7, ref lstTMG, query);
        }
        else if (GameController.instance.level == 11)
        {
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 3).ToList();
            int GT    = 6;

            chonData(GT, 2, ref lstTMG, ClsThaoTac.ChuanHoaDaTa(GT, query, 1));
        }
        else if (GameController.instance.level == 12)
        {
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 3).ToList();
            int GT    = 6;

            chonData(GT, 4, ref lstTMG, ClsThaoTac.ChuanHoaDaTa(GT, query, 1));
        }
        else if (GameController.instance.level == 13)
        {
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 4).ToList();
            int GT    = 6;

            chonData(GT, 3, ref lstTMG, ClsThaoTac.ChuanHoaDaTa(GT, query, 1));
        }
        else if (GameController.instance.level == 14)
        {
            int GT    = 6;
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 4).ToList();
            chonData(GT, 5, ref lstTMG, ClsThaoTac.ChuanHoaDaTa(GT, query, 1));
        }
        else if (GameController.instance.level == 15)
        {
            int GT    = 6;
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 5).ToList();
            chonData(GT, 4, ref lstTMG, ClsThaoTac.ChuanHoaDaTa(GT, query, 1));
        }
        else if (GameController.instance.level == 16)
        {
            int GT    = 6;
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 5).ToList();
            chonData(GT, 3, ref lstTMG, ClsThaoTac.ChuanHoaDaTa(GT, query, 1));
        }
        else if (GameController.instance.level == 17)
        {
            int GT    = 6;
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 6).ToList();
            chonData(GT, 3, ref lstTMG, ClsThaoTac.ChuanHoaDaTa(GT, query, 1));
        }
        else if (GameController.instance.level == 18)
        {
            int GT    = 6;
            var query = GameController.instance.lstPhepToan1.Where(p => int.Parse(p.Loai) == 6).ToList();
            chonData(GT, 5, ref lstTMG, ClsThaoTac.ChuanHoaDaTa(GT, query, 1));
        }
        else if (GameController.instance.level == 19)
        {
            int GT = 6;

            chonData(GT, 4, ref lstTMG, GameController.instance.lstPhepToan1);
        }
        else if (GameController.instance.level == 20)
        {
            int GT = 6;

            chonData(GT, 5, ref lstTMG, GameController.instance.lstPhepToan1);
        }



        if (checkCreate)
        {
            int vt = 1;

            for (int i = 0; i < 12; i++)
            {
                doPhanPhat(ref lstTMG, ref vt, ref positionX, ref positionY);
            }

            checkCreate = false;
        }
        else
        {
            setDataLst(ref lstTMG);
        }



        currentState = State.InGame1;
        txtLoading.gameObject.SetActive(false);
    }
Esempio n. 22
0
    void chonData2(ref List <PhepToan> tmg1, List <PhepToan> lstTam, int loai)
    {
        List <PhepToan> lstRank       = new List <PhepToan>();
        List <PhepToan> lstNhanBonNam = new List <PhepToan>();

        foreach (PhepToan item in lstTam)
        {
            if (loai == 4 || loai == 5)
            {
                if (item.Loai.Equals("" + 51) || item.Loai.Equals("" + 52))
                {
                    lstRank.Add(item);
                }
            }
            else if (loai == 6 || loai == 7)
            {
                if (item.Loai.Equals("" + 53) || item.Loai.Equals("" + 54) || item.Loai.Equals("" + 55) || item.Loai.Equals("" + 56))
                {
                    lstRank.Add(item);
                }
            }
            else if (loai == 8 || loai == 15 || loai == 19 || loai == 20)
            {
                if (item.Loai.Equals("" + 57) || item.Loai.Equals("" + 58))
                {
                    lstRank.Add(item);
                }

                if (loai == 15 || loai == 19 || loai == 20)
                {
                    if (item.Loai.Equals("" + 73) || item.Loai.Equals("" + 74))
                    {
                        lstRank.Add(item);
                    }
                }


                if (loai == 19 || loai == 20)
                {
                    if (item.Loai.Equals("" + 59) || item.Loai.Equals("" + 60) || item.Loai.Equals("" + 75) || item.Loai.Equals("" + 76))
                    {
                        lstRank.Add(item);
                    }
                }
            }
            else if (loai == 9)
            {
                if (item.Loai.Equals("" + 61) || item.Loai.Equals("" + 62))
                {
                    lstRank.Add(item);
                }
            }
            else if (loai == 10)
            {
                if (item.Loai.Equals("" + 63) || item.Loai.Equals("" + 64))
                {
                    lstRank.Add(item);
                }
            }
            else if (loai == 11)
            {
                if (item.Loai.Equals("" + 65) || item.Loai.Equals("" + 66))
                {
                    lstRank.Add(item);
                }
            }
            else if (loai == 12)
            {
                if (item.Loai.Equals("" + 67) || item.Loai.Equals("" + 68))
                {
                    lstRank.Add(item);
                }
            }
            else if (loai == 13)
            {
                if (item.Loai.Equals("" + 69) || item.Loai.Equals("" + 70))
                {
                    lstRank.Add(item);
                }
            }
            else if (loai == 14)
            {
                if (item.Loai.Equals("" + 71) || item.Loai.Equals("" + 72))
                {
                    lstRank.Add(item);
                }
            }

            else if (loai == 16)
            {
                if (item.Loai.Equals("" + 75) || item.Loai.Equals("" + 76) || item.Loai.Equals("" + 59) || item.Loai.Equals("" + 60))
                {
                    lstRank.Add(item);
                }
            }
            else if (loai == 17)
            {
                if (item.Loai.Equals("" + 77) || item.Loai.Equals("" + 78) || item.Loai.Equals("" + 81) || item.Loai.Equals("" + 82))
                {
                    lstRank.Add(item);
                }
            }
            else if (loai == 18)
            {
                if (item.Loai.Equals("" + 79) || item.Loai.Equals("" + 80) || item.Loai.Equals("" + 83) || item.Loai.Equals("" + 84))
                {
                    lstRank.Add(item);
                }
            }



            if (loai == 8 || loai == 16)
            {
                if (item.Loai.Equals("" + 59) || item.Loai.Equals("" + 60))
                {
                    lstNhanBonNam.Add(item);
                }
            }
        }

        if (loai == 4)
        {
            lstRank = ClsThaoTac.ChuanHoaDaTa(10, 80, 1, lstRank);
        }
        else if (loai == 6)
        {
            lstRank = ClsThaoTac.ChuanHoaDaTa(0, 50, 0, lstRank);
        }
        else if (loai == 7)
        {
            lstRank = ClsThaoTac.ChuanHoaDaTa(30, 100, 1, lstRank);
        }
        else if (loai == 8)
        {
            lstRank = lstRank.Concat(ClsThaoTac.ChuanHoaDaTa(1, 32, 0, lstNhanBonNam)).Concat(ClsThaoTac.FakeData(2, 50)).ToList();
        }
        else if (loai == 15)
        {
            lstRank = lstRank.Concat(ClsThaoTac.FakeData(2, 33)).ToList();
        }
        else if (loai == 16)
        {
            lstRank = lstRank.Concat(ClsThaoTac.FakeData(2, 52)).ToList();
        }

        #region Singleton
        if (loai == 4 || loai == 5 || loai == 19 || loai == 20)
        {
            //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 == 0)
                        {
                            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 == 6 || loai == 7 || loai == 9 || loai == 10 || loai == 11 || loai == 12 || loai == 13 || loai == 14 || loai == 17 || loai == 18)
        {
            //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 == 8 || loai == 15 || loai == 16)
        {
            //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 == 1)
                        {
                            pt1 = ClsThaoTac.getCongThuc(lstRank[chon]);
                        }
                        else
                        {
                            pt1 = new PhepToan("" + lstRank[chon].Congthuc, lstRank[chon].Ketqua, "number");
                        }
                    }

                    tmg1.Add(pt1);
                    lstSapXep.Add(pt1);
                }
            }
        }



        #endregion
    }
Esempio n. 23
0
    public void Create()
    {
        #region Singleton

        float           positionX = startX;
        float           positionY = startY;
        List <PhepToan> lstTMG    = new List <PhepToan>();
        if (GameController.instance.level == 4)
        {
            chonData(ref lstTMG, ClsThaoTac.ChuanHoaDaTa(10, 80, 1, GameController.instance.lstCongTruHai), GameController.instance.level);
        }
        else if (GameController.instance.level == 5)
        {
            chonData(ref lstTMG, GameController.instance.lstCongTruHai, GameController.instance.level);
        }
        else if (GameController.instance.level == 6)
        {
            chonData(ref lstTMG, ClsThaoTac.ChuanHoaDaTa(0, 50, 0, GameController.instance.lstCongTruBa), GameController.instance.level);
        }
        else if (GameController.instance.level == 7)
        {
            chonData(ref lstTMG, ClsThaoTac.ChuanHoaDaTa(30, 100, 1, GameController.instance.lstCongTruBa), GameController.instance.level);
        }
        else if (GameController.instance.level == 8)
        {
            var bien = GameController.instance.lstNhanHaiBa.Concat(ClsThaoTac.ChuanHoaDaTa(1, 32, 0, GameController.instance.lstNhanBonNam)).Concat(ClsThaoTac.FakeData(2, 50)).ToList();
            chonData(ref lstTMG, bien, GameController.instance.level);
        }
        else if (GameController.instance.level == 9)
        {
            chonData(ref lstTMG, GameController.instance.lstNhanCong23, GameController.instance.level);
        }
        else if (GameController.instance.level == 10)
        {
            chonData(ref lstTMG, GameController.instance.lstNhanCong45, GameController.instance.level);
        }
        else if (GameController.instance.level == 11)
        {
            chonData(ref lstTMG, GameController.instance.lstNhanTru23, GameController.instance.level);
        }
        else if (GameController.instance.level == 12)
        {
            chonData(ref lstTMG, GameController.instance.lstNhanTru45, GameController.instance.level);
        }
        else if (GameController.instance.level == 13)
        {
            chonData(ref lstTMG, GameController.instance.lstTruNhan23, GameController.instance.level);
        }
        else if (GameController.instance.level == 14)
        {
            chonData(ref lstTMG, GameController.instance.lstTruNhan45, GameController.instance.level);
        }
        else if (GameController.instance.level == 15)
        {
            var bien = GameController.instance.lstChia23.Concat(GameController.instance.lstNhanHaiBa).Concat(ClsThaoTac.FakeData(2, 33)).ToList();
            chonData(ref lstTMG, bien, GameController.instance.level);
        }
        else if (GameController.instance.level == 16)
        {
            var bien = GameController.instance.lstChia45.Concat(GameController.instance.lstNhanBonNam).Concat(ClsThaoTac.FakeData(2, 52)).ToList();
            chonData(ref lstTMG, bien, GameController.instance.level);
        }

        else if (GameController.instance.level == 17)
        {
            chonData(ref lstTMG, GameController.instance.lstCongChia23.Concat(GameController.instance.lstTruChia23).ToList(), GameController.instance.level);
        }
        else if (GameController.instance.level == 18)
        {
            chonData(ref lstTMG, GameController.instance.lstCongChia45.Concat(GameController.instance.lstTruChia45).ToList(), GameController.instance.level);
        }

        else if (GameController.instance.level == 19 || GameController.instance.level == 20)
        {
            var bien = GameController.instance.lstNhanHaiBa.Concat(GameController.instance.lstNhanBonNam).Concat(GameController.instance.lstChia23).Concat(GameController.instance.lstChia45).ToList();

            chonData(ref lstTMG, bien, GameController.instance.level);
        }

        #endregion

        lstSapXep = lstSapXep.OrderBy(p => p.Ketqua).ToList();


        if (checkCreate)
        {
            int vt = 1;

            for (int i = 0; i < 20; i++)
            {
                doPhanPhat(ref lstTMG, ref vt, ref positionX, ref positionY);
            }

            checkCreate = false;
        }
        else
        {
            setDataLst(ref lstTMG);
        }

        currentState = State.InGame1;
        txtLoading.gameObject.SetActive(false);
    }