Example #1
0
    public IEnumerator IEClearLocation(SimpleJSON_DatDz.JSONNode objJson)
    {
        GameManager.Instance.ClearLocation();
        yield return(new WaitUntil(() => GameManager.Instance.lsLocation.Count == 0));

        GameManager.Instance.gold                = objJson["gold"].AsDouble;
        GameManager.Instance.dollar              = objJson["dollar"].AsDouble;
        GameManager.Instance.sumHomeAll          = objJson["sumHomeAll"].AsInt;
        GameManager.Instance.indexSawmill        = objJson["indexSawmill"].AsInt;
        GameManager.Instance.dateStartPlay       = DateTime.Parse(objJson["dateStartPlay"]);
        GameManager.Instance.dateGame            = DateTime.Parse(objJson["dateGame"]);
        UIManager.Instance.txtDollar.text        = UIManager.Instance.ConvertNumber(GameManager.Instance.dollar);
        GameManager.Instance.countSpin           = objJson["countSpin"].AsInt;
        UIManager.Instance.txtCountSpinMain.text = "x" + GameManager.Instance.countSpin;

        var lsItem = objJson["lsItem"].AsArray;

        for (int i = 6; i < UIManager.Instance.lsItem.Length; i++)
        {
            UIManager.Instance.lsItem[i].timeItem      = lsItem[i]["timeItem"].AsFloat;
            UIManager.Instance.lsItem[i].timeItemTatol = lsItem[i]["timeItemTatol"].AsFloat;
            UIManager.Instance.lsItem[i].isOnItem      = lsItem[i]["isOnItem"].AsBool;
            UIManager.Instance.lsItem[i].money         = lsItem[i]["money"].AsDouble;
            UIManager.Instance.lsItem[i].random        = lsItem[i]["random"].AsInt;

            if (UIManager.Instance.lsItem[i].isOnItem && i != 6)
            {
                UIManager.Instance.lsItem[i].obj.SetActive(true);
            }
        }
        var lsData = objJson["lsLocation"].AsArray;

        if (lsData.Count > 1 || lsData[0]["countType"].AsInt > 2)
        {
            UIManager.Instance.btnSpin.SetActive(true);
        }
        lsLocation = new List <LocationJSON>();
        GameManager.Instance.lsLocation = new List <Location>();
        StartCoroutine(IELoadLocationJson(lsData));
        GameManager.Instance.locationManager.gameObject.SetActive(true);
        GameManager.Instance.locationManager.SetAsFirstSibling();
    }
Example #2
0
    public IEnumerator IEClearLocation(SimpleJSON_DatDz.JSONNode objJson)
    {
        GameManager.Instance.ClearLocation();
        yield return(new WaitUntil(() => GameManager.Instance.lsLocation.Count == 0));

        GameManager.Instance.gold          = objJson["gold"].AsDouble;
        GameManager.Instance.dollar        = objJson["dollar"].AsDouble;
        GameManager.Instance.sumHomeAll    = objJson["sumHomeAll"].AsInt;
        GameManager.Instance.indexSawmill  = objJson["indexSawmill"].AsInt;
        GameManager.Instance.dateStartPlay = DateTime.Parse(objJson["dateStartPlay"]);
        GameManager.Instance.dateGame      = DateTime.Parse(objJson["dateGame"]);

        var lsData = objJson["lsLocation"].AsArray;

        lsLocation = new List <LocationJSON>();
        GameManager.Instance.lsLocation = new List <Location>();
        StartCoroutine(IELoadLocationJson(lsData));
        GameManager.Instance.locationManager.gameObject.SetActive(true);
        GameManager.Instance.locationManager.SetAsFirstSibling();
    }
Example #3
0
 public virtual JSONNode Remove(JSONNode aNode)
 {
     return(aNode);
 }
Example #4
0
 public override JSONNode Remove(JSONNode aNode)
 {
     m_List.Remove(aNode);
     return(aNode);
 }
Example #5
0
 public virtual void Add(JSONNode aItem)
 {
     Add("", aItem);
 }
Example #6
0
 public virtual void Add(string aKey, JSONNode aItem)
 {
 }
Example #7
0
 public override void Add(string aKey, JSONNode aItem)
 {
     m_List.Add(aItem);
 }
Example #8
0
        public static JSONNode Parse(string aJSON)
        {
            Stack <JSONNode> stack = new Stack <JSONNode>();
            JSONNode         ctx   = null;
            int    i         = 0;
            string Token     = "";
            string TokenName = "";
            bool   QuoteMode = false;

            while (i < aJSON.Length)
            {
                switch (aJSON[i])
                {
                case '{':
                    if (QuoteMode)
                    {
                        Token += aJSON[i];
                        break;
                    }
                    stack.Push(new JSONClass());
                    if (ctx != null)
                    {
                        TokenName = TokenName.Trim();
                        if (ctx is JSONArray)
                        {
                            ctx.Add(stack.Peek());
                        }
                        else if (TokenName != "")
                        {
                            ctx.Add(TokenName, stack.Peek());
                        }
                    }
                    TokenName = "";
                    Token     = "";
                    ctx       = stack.Peek();
                    break;

                case '[':
                    if (QuoteMode)
                    {
                        Token += aJSON[i];
                        break;
                    }

                    stack.Push(new JSONArray());
                    if (ctx != null)
                    {
                        TokenName = TokenName.Trim();
                        if (ctx is JSONArray)
                        {
                            ctx.Add(stack.Peek());
                        }
                        else if (TokenName != "")
                        {
                            ctx.Add(TokenName, stack.Peek());
                        }
                    }
                    TokenName = "";
                    Token     = "";
                    ctx       = stack.Peek();
                    break;

                case '}':
                case ']':
                    if (QuoteMode)
                    {
                        Token += aJSON[i];
                        break;
                    }
                    if (stack.Count == 0)
                    {
                        throw new Exception("JSON Parse: Too many closing brackets");
                    }

                    stack.Pop();
                    if (Token != "")
                    {
                        TokenName = TokenName.Trim();
                        if (ctx is JSONArray)
                        {
                            ctx.Add(Token);
                        }
                        else if (TokenName != "")
                        {
                            ctx.Add(TokenName, Token);
                        }
                    }
                    TokenName = "";
                    Token     = "";
                    if (stack.Count > 0)
                    {
                        ctx = stack.Peek();
                    }
                    break;

                case ':':
                    if (QuoteMode)
                    {
                        Token += aJSON[i];
                        break;
                    }
                    TokenName = Token;
                    Token     = "";
                    break;

                case '"':
                    QuoteMode ^= true;
                    break;

                case ',':
                    if (QuoteMode)
                    {
                        Token += aJSON[i];
                        break;
                    }
                    if (Token != "")
                    {
                        if (ctx is JSONArray)
                        {
                            ctx.Add(Token);
                        }
                        else if (TokenName != "")
                        {
                            ctx.Add(TokenName, Token);
                        }
                    }
                    TokenName = "";
                    Token     = "";
                    break;

                case '\r':
                case '\n':
                    break;

                case ' ':
                case '\t':
                    if (QuoteMode)
                    {
                        Token += aJSON[i];
                    }
                    break;

                case '\\':
                    ++i;
                    if (QuoteMode)
                    {
                        char C = aJSON[i];
                        switch (C)
                        {
                        case 't': Token += '\t'; break;

                        case 'r': Token += '\r'; break;

                        case 'n': Token += '\n'; break;

                        case 'b': Token += '\b'; break;

                        case 'f': Token += '\f'; break;

                        case 'u':
                        {
                            string s = aJSON.Substring(i + 1, 4);
                            Token += (char)int.Parse(s, System.Globalization.NumberStyles.AllowHexSpecifier);
                            i     += 4;
                            break;
                        }

                        default: Token += C; break;
                        }
                    }
                    break;

                default:
                    Token += aJSON[i];
                    break;
                }
                ++i;
            }
            if (QuoteMode)
            {
                throw new Exception("JSON Parse: Quotation marks seems to be messed up.");
            }
            return(ctx);
        }
Example #9
0
 public static JSONNode Parse(string aJSON)
 {
     return(JSONNode.Parse(aJSON));
 }
Example #10
0
 public JSONLazyCreator(JSONNode aNode, string aKey)
 {
     m_Node = aNode;
     m_Key  = aKey;
 }
Example #11
0
 public JSONLazyCreator(JSONNode aNode)
 {
     m_Node = aNode;
     m_Key  = null;
 }
Example #12
0
    public IEnumerator IE_LoadDataPlayer(SimpleJSON_DatDz.JSONNode objJson)
    {
        idMapBox        = objJson["idMapBox"].AsInt;
        maxLevelHouse   = objJson["maxLevelHouse"].AsInt;
        gold            = objJson["gold"].AsInt;
        coin            = objJson["coin"].AsInt;
        ratioBorn       = objJson["ratioBorn"].AsFloat;
        dateGame        = objJson["dateGame"].AsLong;
        dateEnemyAttack = objJson["dateEnemyAttack"].AsLong;

        var lstBuildHouseJson = objJson["lstBuildHouse"];

        for (int i = 0; i < lstBuildHouseJson.Count; i++)
        {
            BuildHouse buildHouse = new BuildHouse();
            buildHouse.ID       = lstBuildHouseJson[i]["ID"].AsInt;
            buildHouse.isUnlock = lstBuildHouseJson[i]["isUnlock"].AsBool;
            lstBuildHouse.Add(buildHouse);
        }

        var lstHousePlayerJson = objJson["lsHousePlayer"];

        if (lstHousePlayerJson.Count > 0)
        {
            for (int i = 0; i < lstHousePlayerJson.Count; i++)
            {
                HouseInfoST hInfo = new HouseInfoST();
                hInfo.ID                 = lstHousePlayerJson[i]["ID"].AsInt;
                hInfo.level              = lstHousePlayerJson[i]["level"].AsInt;
                hInfo.price              = lstHousePlayerJson[i]["price"].AsLong;
                hInfo.capWar             = lstHousePlayerJson[i]["capWar"].AsInt;
                hInfo.isLock             = lstHousePlayerJson[i]["isLock"].AsBool;
                hInfo.heroInfo           = new HeroInfoST();
                hInfo.heroInfo.ID        = lstHousePlayerJson[i]["heroInfo"]["ID"].AsInt;
                hInfo.heroInfo.CountHero = lstHousePlayerJson[i]["heroInfo"]["CountHero"].AsInt;
                lsHousePlayer.Add(hInfo);
            }
        }

        var lsBoxJson = objJson["lsBox"].AsArray;

        for (int i = 0; i < lsBoxJson.Count; i++)
        {
            BoxInfoST bInfo = new BoxInfoST();
            bInfo.col = lsBoxJson[i]["col"].AsInt;
            bInfo.row = lsBoxJson[i]["row"].AsInt;

            var goldMineJson = lsBoxJson[i]["goldMineInfo"];
            bInfo.goldMineInfo                   = new GoldMineInfoST();
            bInfo.goldMineInfo.ID                = goldMineJson["ID"].AsInt;
            bInfo.goldMineInfo.level             = goldMineJson["level"].AsInt;
            bInfo.goldMineInfo.name              = goldMineJson["name"];
            bInfo.goldMineInfo.isPlayer          = goldMineJson["isPlayer"].AsBool;
            bInfo.goldMineInfo.indexLoadGoldMine = goldMineJson["indexLoadGoldMine"].AsInt;
            bInfo.goldMineInfo.xR                = goldMineJson["xR"].AsFloat;
            bInfo.goldMineInfo.yR                = goldMineJson["yR"].AsFloat;
            bInfo.goldMineInfo.zR                = goldMineJson["zR"].AsFloat;
            bInfo.goldMineInfo.lsHeroGoldMine    = new List <HeroInfoST>();
            var lsHeroGoldMineJson = goldMineJson["lsHeroGoldMine"];

            if (lsHeroGoldMineJson.Count > 0)
            {
                for (int j = 0; j < lsHeroGoldMineJson.Count; j++)
                {
                    HeroInfoST hInfo = new HeroInfoST();
                    hInfo.ID        = lsHeroGoldMineJson[j]["ID"].AsInt;
                    hInfo.CountHero = lsHeroGoldMineJson[j]["CountHero"].AsInt;
                    bInfo.goldMineInfo.lsHeroGoldMine.Add(hInfo);
                }
            }

            lsBox.Add(bInfo);
        }

        yield return(new WaitUntil(() => lsBox.Count == lsBoxJson.Count));

        castlePlayer         = new CastleInfoST();
        castlePlayer.lsHouse = new List <HouseInfoST>();
        var lsHouseJson = objJson["castlePlayer"]["lsHouse"];

        if (lsHouseJson.Count > 0)
        {
            for (int i = 0; i < lsHouseJson.Count; i++)
            {
                HouseInfoST hInfo = new HouseInfoST();
                hInfo.ID                 = lsHouseJson[i]["ID"].AsInt;
                hInfo.level              = lsHouseJson[i]["level"].AsInt;
                hInfo.isLock             = lstHousePlayerJson[i]["isLock"].AsBool;
                hInfo.heroInfo           = new HeroInfoST();
                hInfo.heroInfo.ID        = lsHouseJson[i]["heroInfo"]["ID"].AsInt;
                hInfo.heroInfo.CountHero = lsHouseJson[i]["heroInfo"]["CountHero"].AsInt;
                castlePlayer.lsHouse.Add(hInfo);
            }
        }

        yield return(new WaitUntil(() => castlePlayer.lsHouse.Count == lsHouseJson.Count));

        Fade.Instance.EndFade(0);
    }