示例#1
0
        private ItemBar AddItem(BagItem item, string key, string eventKey, string count)
        {
            ItemBar bar = new ItemBar();

            SimpleProto model = SingletonManager.Get <FreeUiManager>().GetUIData(key);

            if (model == null)
            {
                Debug.LogWarningFormat("item '{0}' is not defined.", key);
                return(null);
            }

            FreePrefabComponent ff = new FreePrefabComponent();

            ff.parentObject = parentBag;
            int realCount = 1;

            if (!string.IsNullOrEmpty(count))
            {
                realCount = int.Parse(count);
            }
            TipUtil.AddTip(eventKey, new TipData(item.cat, item.id, realCount));

            ff.Initial(model.Ss[2], model.Ss[3]);
            ff.SetValues("TEXT_ItemNumber" + FreeMessageConstant.SpilterField + count);
            ff.SetEvents("");
            ff.SetAllEventKey(eventKey);

            bar.prefab = ff;
            bar.value  = model.Ss[2].Split(FreeMessageConstant.SpliterStyle)[1];

            return(bar);
        }
示例#2
0
        public static void ShowTopTip(string msg)
        {
            SimpleFreeUI ui = SingletonManager.Get <FreeUiManager>().GetUi("upTipUI");

            if (ui != null && !StringUtil.IsNullOrEmpty(msg))
            {
                FreePrefabComponent txt = (FreePrefabComponent)ui.GetComponent(0);
                txt.SetFieldValue("Content", msg);

                ui.Show(5000);
            }
        }
示例#3
0
        private void ReturnObject(ItemBar bar)
        {
            FreePrefabComponent prefab = bar.prefab;
            GameObject          obj    = (GameObject)prefab.currentObject;

            if (obj != null)
            {
                obj.GetComponent <Transform>().parent = null;
                FreePrefabLoader.ReturnGameObject(obj, prefab.assetInfo);

                string   imgUrl      = "";
                string[] fieldValues = bar.value.Split(FreeMessageConstant.SpliterRecord);

                foreach (string fieldValue in fieldValues)
                {
                    string[] vs = fieldValue.Split(FreeMessageConstant.SpilterField);
                    if (vs.Length == 2)
                    {
                        if (vs[0].Trim() == "IMG_WeaponIcon")
                        {
                            imgUrl = vs[1].Trim();
                        }
                    }
                }

                GameObject img = UnityUiUtility.FindUIObject(obj, "IMG_WeaponIcon");
                if (img != null && !string.IsNullOrEmpty(imgUrl))
                {
                    int       last       = imgUrl.Trim().LastIndexOf("/");
                    string    buddleName = imgUrl.Trim().Substring(0, last);
                    string    assetName  = imgUrl.Trim().Substring(last + 1);
                    AssetInfo info       = new AssetInfo(buddleName, assetName);

                    Graphic gra = img.GetComponent <Graphic>();
                    if (gra is Image)
                    {
                        FreeUILoader.ReturnGameObject(((Image)gra).sprite, info);
                    }
                    if (gra is RawImage)
                    {
                        FreeUILoader.ReturnGameObject(((RawImage)gra).texture, info);
                    }
                }
            }
        }
示例#4
0
        private void Handle(SimpleProto value, SimpleProto model, GameObject parentObj)
        {
            for (var i = 0; i < model.Ks.Count - 1; i++)
            {
                var newPo = FreeUIUtil.GetInstance().GetComponent(model.Ks[i + 1]);
                if (newPo == null)
                {
                    Logger.ErrorFormat("Free component not exist {0}", model.Ks[i + 1]);
                    continue;
                }

                newPo.Initial(model.Ss[i * 3 + 2], model.Ss[i * 3 + 3]);

                if (newPo is FreePrefabComponent)
                {
                    FreePrefabComponent ff = (FreePrefabComponent)newPo;
                    ff.SetValues(value.Ss[2]);
                    ff.SetEvents(value.Ss[3]);
                    ff.SetAllEventKey(value.Ss[4]);

                    ff.parentObject = parentObj;
                }
            }
        }
示例#5
0
        private ItemBar AddChild(int cat, int id, int count, int entityId)
        {
            ItemBar bar = new ItemBar();
            string  key = (cat * 10000 + id) + "_itemUI";

            SimpleProto model = SingletonManager.Get <FreeUiManager>().GetUIData(key);

            if (model == null)
            {
                Debug.LogWarningFormat("item '{0}' is not defined.", key);
                return(null);
            }

            FreePrefabComponent ff = new FreePrefabComponent();

            ff.parentObject = parentGround;
            TipUtil.AddTip("ground,0," + entityId, new TipData(cat, id, count));

            ff.Initial(model.Ss[2], model.Ss[3]);
            if (count > 0)
            {
                ff.SetValues("TEXT_ItemNumber" + FreeMessageConstant.SpilterField + count);
            }
            else
            {
                ff.SetValues("TEXT_ItemNumber" + FreeMessageConstant.SpilterField + " ");
            }

            ff.SetEvents("");
            ff.SetAllEventKey("ground,0," + entityId);

            bar.prefab = ff;
            bar.value  = model.Ss[2].Split(FreeMessageConstant.SpliterStyle)[1];

            return(bar);
        }
示例#6
0
        private ItemBar AddCaseName(string name)
        {
            ItemBar     bar   = new ItemBar();
            SimpleProto model = SingletonManager.Get <FreeUiManager>().GetUIData("caseName");

            if (model == null)
            {
                Debug.LogWarningFormat("item 'caseName' is not defined.");
                return(null);
            }

            FreePrefabComponent ff = new FreePrefabComponent();

            ff.parentObject = parentGround;

            ff.Initial(model.Ss[2], model.Ss[3]);
            ff.SetValues("TEXT_CaseName" + FreeMessageConstant.SpilterField + name);
            ff.SetEvents("");

            bar.prefab = ff;
            bar.value  = "";

            return(bar);
        }