Esempio n. 1
0
        //购买成功回调
        private bool OnBuySucc(int eventId, object arg)
        {
            BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(ID);

            Name.text  = ba.Name;
            Price.text = ba.Price.ToString();

            if (ba.Type == ObjectType.Seed)
            {
                Time.text = "成长周期: " + ba.GrothTime / 3600 + "h";
            }
            else
            {
                Time.text = "";
            }

            Sprite sp = SpritesManager.Instance.GetSprite(ID);

            _Image.rectTransform.sizeDelta = new Vector2(100, 100);
            //_Image.rectTransform.sizeDelta = new Vector2(sp.rect.width, sp.rect.height);
            _Image.sprite = sp;
            _Image.color  = Color.white;

            TargetGo.SetActive(true);
            MusicManager.Instance.Playsfx(AudioNames.GetMoney);
            return(true);
        }
Esempio n. 2
0
        private bool OnUpgrading(int eventId, object arg)
        {
            int           produceId = (int)arg;
            BaseAtrribute ba        = LoadObjctDateConfig.Instance.GetAtrribute(produceId);

            if (ba.Type == ObjectType.PrimaryOil)
            {
                produceType = 1;
            }
            else if (ba.Type == ObjectType.SemiOil)
            {
                produceType = 2;
            }
            else if (ba.Type == ObjectType.elixir)
            {
                produceType = 3;
            }

            Sprite sp = SpritesManager.Instance.GetSprite(produceId);

            ProduceImage.rectTransform.sizeDelta = new Vector2(56, 80);
            ProduceImage.sprite = sp;
            ProduceImage.color  = Color.white;
            return(false);
        }
Esempio n. 3
0
        private void SetData(string content)
        {
            string[] ContentLines = content.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < ContentLines.Length; i++)
            {
                string[] infos = ContentLines[i].Split('\t');

                if (infos[0] != "")
                {
                    BaseAtrribute baseAtrribute = new BaseAtrribute();
                    baseAtrribute.Name         = infos[2];
                    baseAtrribute.CombineCount = int.Parse(infos[7] != "" ? infos[7] : "0");
                    baseAtrribute.Des          = infos[4];
                    baseAtrribute.GrothTime    = int.Parse(infos[5] != "" ? infos[5] : "0");
                    baseAtrribute.Price        = int.Parse(infos[3] != "" ? infos[3] : "0");
                    baseAtrribute.SpeedUp      = int.Parse(infos[6] != "" ? infos[6] : "0");
                    baseAtrribute.Type         = (ObjectType)int.Parse(infos[1] != "" ? infos[1] : "0");

                    baseAtrribute.Id            = int.Parse(infos[0] != "" ? infos[0] : "0");
                    baseAtrribute.ProduceId     = int.Parse(infos[8] != "" ? infos[8] : "0");
                    baseAtrribute.ExchangedName = infos[9] != ""?infos[9]:"";

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


                    BaseAtrributes.Add(baseAtrribute.Id, baseAtrribute);
                }
            }
        }
Esempio n. 4
0
        public int UserGameID;  //背包物品id
        //输入显示的数据
        public void SetData(BaseObject bo)
        {
            UserGameID = bo.ID;

            BaseAtrribute ba     = LoadObjctDateConfig.Instance.GetAtrribute(bo.ID);
            string        _count = "";

            if (ba.Type == ObjectType.PrimaryOil)
            {
                //_count = (10 * bo.ObjectNum).ToString() + "ml";
                _count = "x" + bo.ObjectNum.ToString();
            }
            else if (ba.Type == ObjectType.SemiOil)
            {
                _count = (0.5 * bo.ObjectNum).ToString() + "ml";
            }
            else
            {
                _count = "x" + bo.ObjectNum.ToString();
            }
            transform.Find("Count").GetComponent <Text>().text = _count;
            transform.Find("Price").GetComponent <Text>().text = ba.Price.ToString();
            transform.Find("Name").GetComponent <Text>().text  = bo.Name;

            Image  img = transform.Find("Image").GetComponent <Image>();
            Sprite sp  = SpritesManager.Instance.GetSprite(bo.ID);

            img.sprite = sp;
            float height = 69;
            float width  = sp.rect.width / sp.rect.height * height;

            img.rectTransform.sizeDelta = new Vector2(width, height);
            //img.rectTransform.sizeDelta = new Vector2(sp.rect.width,sp.rect.height);
            img.color = Color.white;
        }
Esempio n. 5
0
        public void SetData(Farm_Game_PaySucc_Anw p)
        {
            MsgUnit msg = new MsgUnit();

            msg.type = 4;
            msg.id   = Convert.ToInt32(p.Ordernum);
            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区
            DateTime        dt        = startTime.AddSeconds(Convert.ToInt32(p.Time));

            msg.sendTime = dt.ToString("HH:mm");

            string c = "";

            if (p.Type == 1)
            {
                c += "登录支付成功\n";
            }
            else if (p.Type == 2)
            {
                c += "兑换成功\n";
            }

            c += ("订单号:" + p.Ordernum + "\n");
            c += ("支付的邮费:" + p.Money + "\n");
            c += ("时间:" + msg.sendTime + "\n");
            c += ("物品信息:");
            for (int i = 0; i < p.ObjsCount; i++)
            {
                BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(p.ObjsList[i].Id);
                c += (ba.Name + "x" + p.ObjsList[i].Count + "\n");
            }
            msg.content = c;
            orders.Add(msg);
            //SaveData(msg);
        }
Esempio n. 6
0
        //选择商品后刷新信息
        private bool OnSelectItem(int eventId, object arg)
        {
            int id = (int)arg;

            ID = id;
            BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(id);

            if (ba.Type == ObjectType.Seed)
            {
                Info_grothTime.text = "生长周期:" + ba.GrothTime / 3600 + "h";
            }
            else
            {
                Info_grothTime.text = "";
            }
            Info_name.text  = ba.Name;
            Info_price.text = ba.Price.ToString();

            Sprite sp = SpritesManager.Instance.GetSprite(id);

            Info_image.rectTransform.sizeDelta = new Vector2(sp.rect.width, sp.rect.height);
            Info_image.sprite = sp;
            Info_image.color  = Color.white;

            WindowHideOrShow(true);
            MusicManager.Instance.Playsfx(AudioNames.OnClick5);
            return(false);
        }
Esempio n. 7
0
        /// <summary>
        /// 给公用属性赋值
        /// </summary>
        /// <param name="baseObject"></param>
        /// <param name="stagePropUnit"></param>
        public static void SerializeProto(BaseObject baseObject, PMsg_StagePropUnit stagePropUnit)
        {
            //服务器的信息:id+count
            baseObject.ID        = stagePropUnit.Id;
            baseObject.ObjectNum = stagePropUnit.Count;

            //查找本地配置表
            BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(stagePropUnit.Id);

            baseObject.Name  = ba.Name;
            baseObject.Price = ba.Price;
            baseObject.Des   = ba.Des;
        }
Esempio n. 8
0
        private void LoadPayObj(BaseObject id)
        {
            BaseAtrribute ba     = LoadObjctDateConfig.Instance.GetAtrribute(id.ID);
            GameObject    go     = GameObject.Instantiate(Exchangeitem);
            Text          t      = go.transform.Find("Item Label").GetComponent <Text>();
            Text          c      = go.transform.Find("count").GetComponent <Text>();
            Toggle        toggle = go.GetComponent <Toggle>();

            toggle.onValueChanged.AddListener(OnValueChange);
            ToggleAndObj tao = new ToggleAndObj(id.ID, toggle, id.ObjectNum);

            taos.Add(tao);

            t.text = ba.ExchangedName;
            c.text = "×" + id.ObjectNum;
            go.transform.SetParent(ExchangeGrid.transform, false);
        }
Esempio n. 9
0
        public static DogFood SetDogFoodAnwData(PMsg_StagePropUnit obj)
        {
            if (obj != null)
            {
                //查找本地配置表
                BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(obj.Id);

                DogFood p = new DogFood();
                p.Speedup = ba.SpeedUp;
                p.Url     = "Sprites/DogFoods/DogFood_" + ba.Id;
                p.Des     = ba.Des;

                DataSettingManager.SerializeProto(p, obj);
                return(p);
            }
            else
            {
                Debug.LogError(string.Format("the DogFoodObject is null"));
                return(null);
            }
        }
Esempio n. 10
0
        public static Elixir SetElixirAnwData(PMsg_StagePropUnit obj)
        {
            if (obj != null)
            {
                //查找本地配置表
                BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(obj.Id);

                Elixir p = new Elixir();
                //p.Url = "Sprites/Fertilizers/Fertilizer_" + ba.Id;
                p.StoreShowTag = 4;
                p.Des          = ba.Des;

                DataSettingManager.SerializeProto(p, obj);
                return(p);
            }
            else
            {
                Debug.LogError(string.Format("the FertilizerObject is null"));
                return(null);
            }
        }
Esempio n. 11
0
        public static Plant SetAnwData(PMsg_Plant _plant)
        {
            if (_plant != null)
            {
                //查找本地配置表
                BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(_plant.Id);

                Plant p = new Plant();
                p.GrothTime = ba.GrothTime;
                p.ID        = ba.Id;
                p.Name      = ba.Name;
                p.Des       = ba.Des;

                return(p);
            }
            else
            {
                Debug.LogError(string.Format("the plant is null"));
                return(null);
            }
        }
Esempio n. 12
0
        public static Result SetResultAnwData(PMsg_StagePropUnit obj)
        {
            if (obj != null)
            {
                //查找本地配置表
                BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(obj.Id);

                Result p = new Result();
                p.UpGradeToOilNum = ba.CombineCount;
                p.StoreShowTag    = 2;
                p.Url             = "Sprites/Results/Result_" + ba.Id;
                p.Des             = ba.Des;

                DataSettingManager.SerializeProto(p, obj);
                return(p);
            }
            else
            {
                Debug.LogError(string.Format("the ResultObject is null"));
                return(null);
            }
        }
Esempio n. 13
0
        public static Seed SetSeedAnwData(PMsg_StagePropUnit obj)
        {
            if (obj != null)
            {
                //查找本地配置表
                BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(obj.Id);

                Seed p = new Seed();
                p.GrothTime    = ba.GrothTime;
                p.StoreShowTag = 1;
                p.Url          = "Sprites/Seeds/Seed_" + ba.Id;
                p.Des          = ba.Des;

                DataSettingManager.SerializeProto(p, obj);
                return(p);
            }
            else
            {
                Debug.LogError(string.Format("the SeedObject is null"));
                return(null);
            }
        }
Esempio n. 14
0
        public static Oil SetOilAnwData(PMsg_StagePropUnit obj)
        {
            if (obj != null)
            {
                //查找本地配置表
                BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(obj.Id);

                Oil p = new Oil();
                if (ba.Type == ObjectType.PrimaryOil)
                {
                    p.OilType     = 1;//初级精油   ?合成数量?
                    p.CombinCount = ba.CombineCount;
                    p.Url         = "Sprites/Oils/PrimaryOil/POil_" + ba.Id;
                }
                else if (ba.Type == ObjectType.SemiOil)
                {
                    p.OilType = 2;//半成品精油
                    p.Url     = "Sprites/Oils/SemiOil/SEOil_" + ba.Id;
                }
                else if (ba.Type == ObjectType.SeniorOil)
                {
                    p.OilType = 3;//高级精油
                    p.Url     = "Sprites/Oils/SeniorOil/SOil_" + ba.Id;
                }
                //p.GainExp = obj.GainEXP;
                //p.OnceLackResult = obj.OnceLackResult;
                p.StoreShowTag = 3;
                p.Des          = ba.Des;

                DataSettingManager.SerializeProto(p, obj);
                return(p);
            }
            else
            {
                Debug.LogError(string.Format("the OilObject is null"));
                return(null);
            }
        }
Esempio n. 15
0
        public void SetData(Farm_Game_LogisticsOrder p)
        {
            MsgUnit msg = new MsgUnit();

            msg.type = 4;
            msg.id   = Convert.ToInt32(p.Ordernum);
//            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)); // 当地时区
//            DateTime dt = startTime.AddSeconds((double)Convert.ToInt32(p.Sendtime));
//            msg.sendTime = dt.ToString("HH:mm");
            msg.sendTime = p.Sendtime;
            string c = "";

//            if (p.Type== 1)
//            {
//                c += "登录支付成功\n";
//
//
//            }
//            else if (p.Type == 2)
            {
                c += ("快递单号:" + (p.LogisticsOrder == ""?"请等待发货": p.LogisticsOrder) + "\n");
            }
            c += ("快递公司:" + p.Company + "\n");

            c += ("订单号:" + p.Ordernum + "\n");
            c += ("支付的邮费:" + p.Money + "\n");
            c += ("时间:" + msg.sendTime + "\n");
            c += ("物品信息:\n");
            for (int i = 0; i < p.ObjsCount; i++)
            {
                BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(p.ObjsList[i].Id);
                c += ("[" + ba.Name + "x" + p.ObjsList[i].Count + "]" + "\n");
            }
            msg.content = c;
            orders.Add(msg);
            //SaveData(msg);
        }
Esempio n. 16
0
        private bool OnSellSucc(int eventId, object arg)
        {
            int           itemId = StoreController.Instance.currentSellID;
            int           count  = StoreController.Instance.currentSellNumber;
            string        type   = "";
            BaseAtrribute ba     = LoadObjctDateConfig.Instance.GetAtrribute(itemId);

            switch (ba.Type)
            {
            case ObjectType.Seed:
                type = "种子";
                break;

            case ObjectType.Result:
                type = "果实";
                break;

            case ObjectType.PrimaryOil:
            case ObjectType.SeniorOil:
                type = "精油";
                break;

            case ObjectType.Fertilizer:
                type = "肥料";
                break;

            default:
                Debug.Log("卖出物体类型错误");
                break;
            }
            GetMoney.text    = (count * ba.Price).ToString();
            SellContent.text = "[出售" + count + "份" + type + "]";
            TargetGo.SetActive(true);

            MusicManager.Instance.Playsfx(AudioNames.GetMoney);
            return(false);
        }
Esempio n. 17
0
        //在背包中选中物体后,更新sellview中的内容
        private bool ReFreshView(int eventId, object arg)
        {
            ID = (int)arg;

            //根据ID在model中获取info
            BaseObject itemInfo  = Farm_Game_StoreInfoModel.Instance.GetData(ID);
            string     Item_path = itemInfo.Url;

            Sprite sp = SpritesManager.Instance.GetSprite(ID);

            Info_Image.sprite = sp;
            Info_Image.rectTransform.sizeDelta = new Vector2(sp.rect.width, sp.rect.height);
            Info_Image.color = Color.white;

            Info_Name.text      = itemInfo.Name;
            Info_UnitPrice.text = itemInfo.Price.ToString();
            Introduce_Text.text = itemInfo.Des;

            Count_Number.text = "1";

            BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(ID);

            if (ba.Type == ObjectType.elixir)
            {
                BtnSell.gameObject.SetActive(false);
                SellOilView.gameObject.SetActive(true);
            }
            else
            {
                BtnSell.gameObject.SetActive(true);
                SellOilView.gameObject.SetActive(false);
            }

            WindowShowOrHide(true);
            MusicManager.Instance.Playsfx(AudioNames.OnClick5);
            return(false);
        }
Esempio n. 18
0
        public virtual void SetData(BaseObject bo)
        {
            ID = bo.ID;
            transform.Find("Name").GetComponent <Text>().text  = bo.Name;
            transform.Find("Price").GetComponent <Text>().text = bo.Price.ToString();

            BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(bo.ID);

            if (ba.Type == ObjectType.Seed)
            {
                transform.Find("GrothTime").GetComponent <Text>().text = "生长周期:" + ba.GrothTime / 3600 + "h";
            }
            else
            {
                transform.Find("GrothTime").GetComponent <Text>().text = " ";
            }

            Image  img = transform.Find("Image").GetComponent <Image>();
            Sprite sp  = SpritesManager.Instance.GetSprite(bo.ID);

            img.rectTransform.sizeDelta = new Vector2(sp.rect.width, sp.rect.height);
            img.sprite = sp;
            img.color  = Color.white;
        }
Esempio n. 19
0
        public BaseObject GetData(int id)
        {
            BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(id);

            if (ba == null)
            {
                return(null);
            }
            BaseObject bo;

            switch (ba.Type)
            {
            case ObjectType.Seed:
                if (storage.Seeds.ContainsKey(id))
                {
                    bo = storage.Seeds[id];
                }
                else
                {
                    bo = new BaseObject()
                    {
                        Name  = ba.Name,
                        Des   = ba.Des,
                        Price = ba.Price,

                        ID        = id,
                        ObjectNum = 0,
                    }
                };
                break;

            case ObjectType.Result:
                if (storage.Results.ContainsKey(id))
                {
                    bo = storage.Results[id];
                }
                else
                {
                    bo = new BaseObject()
                    {
                        Name  = ba.Name,
                        Des   = ba.Des,
                        Price = ba.Price,

                        ID        = id,
                        ObjectNum = 0,
                    }
                };;
                break;

            case ObjectType.PrimaryOil:
            case ObjectType.SemiOil:
            case ObjectType.SeniorOil:
                if (storage.Oils.ContainsKey(id))
                {
                    bo = storage.Oils[id];
                }
                else
                {
                    bo = new BaseObject()
                    {
                        Name  = ba.Name,
                        Des   = ba.Des,
                        Price = ba.Price,

                        ID        = id,
                        ObjectNum = 0,
                    }
                };;
                break;

            case ObjectType.DogFood:
                if (storage.DogFoods.ContainsKey(id))
                {
                    bo = storage.DogFoods[id];
                }
                else
                {
                    bo = new BaseObject()
                    {
                        Name  = ba.Name,
                        Des   = ba.Des,
                        Price = ba.Price,

                        ID        = id,
                        ObjectNum = 0,
                    }
                };;
                break;

            case ObjectType.Fertilizer:
                if (storage.Fertilizers.ContainsKey(id))
                {
                    bo = storage.Fertilizers[id];
                }
                else
                {
                    bo = new BaseObject()
                    {
                        Name  = ba.Name,
                        Des   = ba.Des,
                        Price = ba.Price,

                        ID        = id,
                        ObjectNum = 0,
                    }
                };
                break;

            case ObjectType.elixir:
                if (storage.Elixirs.ContainsKey(id))
                {
                    bo = storage.Elixirs[id];
                }
                else
                {
                    bo = new BaseObject()
                    {
                        Name  = ba.Name,
                        Des   = ba.Des,
                        Price = ba.Price,

                        ID        = id,
                        ObjectNum = 0,
                    }
                };
                break;

            default:
                bo = null;
                break;
            }
            return(bo);
        }
Esempio n. 20
0
        //商店信息输入
        public static void SetAnwData(out Dictionary <int, Seed> seeds, out Dictionary <int, DogFood> dogfoods, out Dictionary <int, Fertilizer> Fertilizer, out Dictionary <int, Result> results, out Dictionary <int, Formula> formulas, Farm_Game_ShopInfo_Anw GenerateAnw)
        {
            IList <Shop_MessageUnit>     list        = GenerateAnw.ObjectsList;
            Dictionary <int, Seed>       _seeds      = new Dictionary <int, Seed>();
            Dictionary <int, DogFood>    _dogfoods   = new Dictionary <int, DogFood>();
            Dictionary <int, Fertilizer> _fertilizer = new Dictionary <int, Fertilizer>();
            Dictionary <int, Result>     _results    = new Dictionary <int, Result>();
            Dictionary <int, Formula>    _formulas   = new Dictionary <int, Formula>();

            for (int i = 0; i < list.Count; i++)
            {
                BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(list[i].Object.Id);
                if (ba != null)
                {
                    switch (ba.Type)
                    {
                    case ObjectType.Seed:
                        _seeds.Add(list[i].Object.Id, SetSeedAnwData(list[i].Object));
                        _seeds[list[i].Object.Id].Price = list[i].Price;
                        break;

                    case ObjectType.DogFood:
                        _dogfoods.Add(list[i].Object.Id, SetDogFoodAnwData(list[i].Object));
                        _dogfoods[list[i].Object.Id].Price = list[i].Price;
                        break;

                    case ObjectType.Fertilizer:
                        _fertilizer.Add(list[i].Object.Id, SetFertilizerAnwData(list[i].Object));
                        _fertilizer[list[i].Object.Id].Price = list[i].Price;
                        break;

                    //测试用果实
                    case ObjectType.Result:
                        _results.Add(list[i].Object.Id, SetResultAnwData(list[i].Object));
                        break;

                    case ObjectType.formula:
                        _formulas.Add(list[i].Object.Id, SetFormulaAnwData(list[i].Object));
                        _formulas[list[i].Object.Id].Price = list[i].Price;
                        break;

                    default:
                        break;
                    }
                }
            }

            //测试配方
            //Formula f = new Formula();
            //f.ID = 1001;
            //f.Name = "神秘配方";
            //f.Price = 100;
            //f.ShopTag = 2;
            //_formulas.Add(f.ID, f);

            seeds      = _seeds;
            dogfoods   = _dogfoods;
            Fertilizer = _fertilizer;
            results    = _results;
            formulas   = _formulas;
        }
Esempio n. 21
0
        //仓库信息输入
        public static void SetStoreAnwData(IList <PMsg_StagePropUnit> list)
        {
            StorageDeltaList storageDeltaList = Farm_Game_StoreInfoModel.storage;

            if (list != null)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    //移除该id的信息,后面重新输入
                    storageDeltaList.Seeds.Remove(list[i].Id);
                    storageDeltaList.Results.Remove(list[i].Id);
                    storageDeltaList.Oils.Remove(list[i].Id);
                    storageDeltaList.DogFoods.Remove(list[i].Id);
                    storageDeltaList.Fertilizers.Remove(list[i].Id);
                    storageDeltaList.Elixirs.Remove(list[i].Id);
                    storageDeltaList.Formulas.Remove(list[i].Id);
                    //若数量为0,则表示该物品已从仓库移除

                    BaseAtrribute item = LoadObjctDateConfig.Instance.GetAtrribute(list[i].Id);

                    if (list[i].Count == 0)
                    {
                        switch (item.Type)
                        {
                        case ObjectType.Seed:
                            Debug.Log(string.Format("<color=#ffffffff><---{0}-{1}----></color>", list[i].Id, "test1"));

                            storageDeltaList.Seeds.Remove(list[i].Id);
                            Seed seed;
                            if (storageDeltaList.Seeds.TryGetValue(list[i].Id, out seed))
                            {
                                Debug.Log(string.Format("<color=#ffffffff><---{0}-{1}----></color>", seed.Name, "test1"));
                            }

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

                            break;

                        case ObjectType.Result:
                            storageDeltaList.Results.Remove(list[i].Id);
                            break;

                        case ObjectType.SeniorOil:
                        case ObjectType.PrimaryOil:
                        case ObjectType.SemiOil:
                            storageDeltaList.Oils.Remove(list[i].Id);
                            break;

                        case ObjectType.DogFood:
                            storageDeltaList.DogFoods.Remove(list[i].Id);
                            break;

                        case ObjectType.Fertilizer:
                            storageDeltaList.Fertilizers.Remove(list[i].Id);
                            break;

                        case ObjectType.elixir:
                            storageDeltaList.Elixirs.Remove(list[i].Id);
                            break;

                        case ObjectType.formula:
                            storageDeltaList.Formulas.Remove(list[i].Id);
                            break;

                        default:
                            Debug.LogError("后台返回了不该在仓库的东西:" + item.Name);
                            break;
                        }
                    }
                    else
                    {
                        if (item != null)
                        {
                            switch (item.Type)
                            {
                            case ObjectType.Seed:

                                storageDeltaList.Seeds.Add(list[i].Id, SetSeedAnwData(list[i]));
                                //                                Debug.Log(string.Format("<color=#ffffffff><---{0}-{1}----></color>", storageDeltaList.Seeds[list[i].Id].Name, storageDeltaList.Seeds[list[i].Id].ObjectNum));

                                break;

                            case ObjectType.Result:
                                storageDeltaList.Results.Add(list[i].Id, SetResultAnwData(list[i]));
                                break;

                            case ObjectType.SeniorOil:
                            case ObjectType.PrimaryOil:
                            case ObjectType.SemiOil:
                                storageDeltaList.Oils.Add(list[i].Id, SetOilAnwData(list[i]));
                                break;

                            case ObjectType.DogFood:
                                storageDeltaList.DogFoods.Add(list[i].Id, SetDogFoodAnwData(list[i]));
                                break;

                            case ObjectType.Fertilizer:
                                storageDeltaList.Fertilizers.Add(list[i].Id, SetFertilizerAnwData(list[i]));
                                break;

                            case ObjectType.elixir:
                                storageDeltaList.Elixirs.Add(list[i].Id, SetElixirAnwData(list[i]));
                                break;

                            case ObjectType.formula:
                                storageDeltaList.Formulas.Add(list[i].Id, SetFormulaAnwData(list[i]));
                                break;

                            default:
                                Debug.LogError("后台返回了不该在仓库的东西:" + item.Name);
                                break;
                            }
                        }
                    }
                }

                if (storageDeltaList.Seeds.Count == 0)
                {
                    if (ViewMgr.Instance.isOpen(ViewNames.SeedBarView))
                    {
                        SystemMsgView.SystemFunction(Function.OpenDialog, Info.SeedNumNotEngouth, ViewNames.ShopView, (
                                                         () =>
                        {
                            SeedBarView.PlayBack();
                        }));
                    }
                }
            }
            Farm_Game_StoreInfoModel.storage = storageDeltaList;
        }
Esempio n. 22
0
        /// <summary>
        /// 初始化地图上的所有数据
        /// </summary>
        /// <param name="GenerateAnw"></param>
        public void SetData(IList <PMsg_MapUnit> GenerateAnw)
        {
            int _brandId = 1;

            for (int i = 0; i < GenerateAnw.Count; i++)
            {
                PMsg_MapUnit mapUnit = GenerateAnw[i];
                //                Debug.Log(mapUnit.Id);
                FarmUnit fm = farms[mapUnit.Id] as FarmUnit;

                fm.EnablePlant = mapUnit.EnablePlant;


                if (mapUnit.EnablePlant == 1 && mapUnit.Id > _brandId)
                {
                    _brandId = mapUnit.Id;
                }

                fm.FarmID = mapUnit.Id;

                SpriteRenderer sr = fm.Renderer;

                int baseOder = 100 * fm.Xposi + 50 * fm.Yposi;
                sr.sortingLayerName = "land";

                sr.sortingOrder = baseOder;
                //传回来的地上植物不为空
                if (mapUnit.Plant.ToString() != "")
                {
                    if (fm.Plant != null)
                    {
                        fm.Plant.ID     = mapUnit.Plant.Id;
                        fm.Plant.FarmID = fm.FarmID;

                        fm.Plant.IsSteal   = mapUnit.Plant.IsSteal;
                        fm.Plant.StartTime = mapUnit.Plant.StartTime;
                        fm.Plant.IsGrass   = mapUnit.Plant.IsGrass;
                        fm.Plant.IsWorm    = mapUnit.Plant.IsWorm;
                        fm.Plant.IsWater   = mapUnit.Plant.IsLessWater;

                        BaseAtrribute ba = LoadObjctDateConfig.Instance.GetAtrribute(mapUnit.Plant.Id);
                        fm.Plant.Name = ba.Name;
                    }
                    else
                    {
                        Plant plant = DataSettingManager.SetAnwData(mapUnit.Plant);

                        GameObject plant1 = new GameObject("plant" + fm.FarmID);
                        plant1.transform.SetParent(fm.Renderer.transform, false);
                        SpriteRenderer plantR = plant1.AddComponent <SpriteRenderer>();
                        plant.FarmID = fm.FarmID;

                        plant.ID        = mapUnit.Plant.Id;
                        plant.IsSteal   = mapUnit.Plant.IsSteal;
                        plant.StartTime = mapUnit.Plant.StartTime;
                        plant.Renderer  = plantR;

                        plant.IsGrass = mapUnit.Plant.IsGrass;
                        plant.IsWorm  = mapUnit.Plant.IsWorm;
                        plant.IsWater = mapUnit.Plant.IsLessWater;
                        fm.Plant      = plant;
                        fm.Plant.Renderer.sortingLayerName = "plant";
                        fm.Plant.Renderer.sortingOrder     = baseOder + 10;
                    }
                }
                else
                {
                    for (int j = 0; j < fm.Go.transform.childCount; j++)
                    {
                        if (fm.Go.transform.GetChild(j) && fm.Go.transform.GetChild(j).name != "brand(Clone)")
                        {
                            GameObject.Destroy(fm.Go.transform.GetChild(j).gameObject);
                        }
                    }
                    //这块地上原来有植物
                    if (fm.Plant != null)
                    {
                        fm.Plant.destroyPlant();
                        fm.Plant.DisposeBadIcon();
                    }
                    fm.Plant = null;
                }
            }
//            GC.Collect();
            Brand brand = Brand.Instance;

            brand.SelectId = _brandId + 1;
        }
Esempio n. 23
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);
        }