Пример #1
0
        private void SetData()
        {
            //string url = @"http://39.108.134.200:8080/api/gameExchangeBrandData";
            string         url  = @"http://119.23.48.181:8080/api/gameExchangeBrandData";
            string         json = VersionUpdateManager.Instance.GetPage(url);
            GameDataResult r    = JsonUtility.FromJson <GameDataResult>(json);

            if (r == null || r.result == null || r.result.Length == 0)
            {
                return;
            }
            for (int i = 0; i < r.result.Length; i++)
            {
                brands.Add(r.result[i].name, r.result[i]);

                Debug.Log(string.Format("<color=#ffffffff><---{0}-{1}----></color>", r.result[i].ToString(), "test1"));
            }
        }
Пример #2
0
        private void SetData()
        {
            //url = @"http://39.108.134.200:8080/publiccms/api/gameGoodsData";
            url = @"http://119.23.48.181:8080/publiccms/api/gameGoodsData";
            //            url = "http:// "+ LoginConfig.Instance.serverIP+ ":"+ 8080 + "/api/gameGoodsData";

            Debug.LogError(string.Format("<color=#ff0000ff><---{0}-{1}----></color>", url, "test1"));

            string         json = VersionUpdateManager.Instance.GetPage(url);
            GameDataResult r    = JsonUtility.FromJson <GameDataResult>(json);

            if (r == null || r.result == null || r.result.Length == 0)
            {
                return;
            }
            for (int i = 0; i < r.result.Length; i++)
            {
                GameData      data          = r.result[i];
                BaseAtrribute baseAtrribute = new BaseAtrribute();
                baseAtrribute.Name = data.name.Trim();
                //baseAtrribute.CombineCount = data.combineCount;
                baseAtrribute.Des       = data.desc.Trim();
                baseAtrribute.GrothTime = data.growTime;
                baseAtrribute.Price     = data.price;
                baseAtrribute.SpeedUp   = data.speedUp;
                baseAtrribute.Type      = (ObjectType)data.type;

                baseAtrribute.Id = data.id;
                //baseAtrribute.ProduceId = data.combineId;
                baseAtrribute.ExchangedName = data.exchangeName.Trim();

                //                    Debug.Log(string.Format("<color=#ffffffff><---{0}-{1}----></color>", baseAtrribute.ToString(), "test1"));


                BaseAtrributes.Add(baseAtrribute.Id, baseAtrribute);
            }
            for (int i = 0; i < r.result.Length; i++)
            {
                GameData data = r.result[i];
                if (data.combineId != 0)
                {
                    BaseAtrributes[data.combineId].ProduceId    = data.id;
                    BaseAtrributes[data.combineId].CombineCount = data.combineCount;
                }
            }

            for (int i = 0; i < r.exchange.Length; i++)
            {
                ID data = r.exchange[i];
                if (needs.ContainsKey(data.targetId))
                {
                    List <NeedClass> ids   = needs[data.targetId];
                    bool             isHas = false;
                    for (int j = 0; j < ids.Count; j++)
                    {
                        if (ids[j].id == data.needId)
                        {
                            isHas = true;
                            break;
                        }
                    }
                    if (isHas == false)
                    {
                        NeedClass m = new NeedClass(data.needId, data.count);
                        ids.Add(m);
                    }
                }
                else
                {
                    List <NeedClass> needlist = new List <NeedClass>();
                    NeedClass        m        = new NeedClass(data.needId, data.count);
                    needlist.Add(m);
                    needs.Add(data.targetId, needlist);
                }
            }

            needs.Add(401, new List <NeedClass>()
            {
                new NeedClass(301, 1)
            });
            needs.Add(402, new List <NeedClass>()
            {
                new NeedClass(302, 1)
            });
            needs.Add(403, new List <NeedClass>()
            {
                new NeedClass(303, 1)
            });
            needs.Add(404, new List <NeedClass>()
            {
                new NeedClass(304, 1)
            });
            needs.Add(405, new List <NeedClass>()
            {
                new NeedClass(305, 1)
            });
            needs.Add(406, new List <NeedClass>()
            {
                new NeedClass(306, 1)
            });
            needs.Add(407, new List <NeedClass>()
            {
                new NeedClass(307, 1)
            });

            needs.Add(301, new List <NeedClass>()
            {
                new NeedClass(101, 1)
            });
            needs.Add(302, new List <NeedClass>()
            {
                new NeedClass(102, 1)
            });
            needs.Add(303, new List <NeedClass>()
            {
                new NeedClass(103, 1)
            });
            needs.Add(304, new List <NeedClass>()
            {
                new NeedClass(104, 1)
            });
            needs.Add(305, new List <NeedClass>()
            {
                new NeedClass(105, 1)
            });
            needs.Add(306, new List <NeedClass>()
            {
                new NeedClass(106, 1)
            });
            needs.Add(307, new List <NeedClass>()
            {
                new NeedClass(107, 1)
            });

            //测试配方
            //BaseAtrribute b = new BaseAtrribute();
            //b.Name = "神秘配方";
            //b.Price = 10000;
            //b.Type = ObjectType.formula;
            //b.Id = 1001;
            //BaseAtrributes.Add(b.Id, b);
        }