Пример #1
0
    public void OpenItemInfo(CharBag.Goods good)
    {
        //名称
        goodsUIBase.nameText.text = good.Name;

        //图片icon
        goodsUIBase.goodsIMG.sprite = Materiral.GetMaterialIcon(good.MateriralType, good.ID);

        //物品类型
        if (good.MateriralType == 0)
        {
            goodsUIBase.MaterialtypeText.text = "类型:物品";
        }
        else if (good.MateriralType == 1)
        {
            goodsUIBase.MaterialtypeText.text = "类型:概念";
        }
        else
        {
            goodsUIBase.MaterialtypeText.text = "类型:未知";
        }

        //数量
        goodsUIBase.numText.text = "数量:" + good.Number.ToString();

        //品质
        goodsUIBase.qualityText.text = "品质:" + good.Quality.ToString();

        //价格
        goodsUIBase.priceText.text = "价格:" + good.Price.ToString();

        //物品效果
        if (good.MaterialEffet != 0)
        {
            Materiral.Effect _effect = Materiral.FindMaterialEffectByID(good.MaterialEffet);
            goodsUIBase.effect.text = _effect.Name;

            effect = _effect;
        }

        //物品属性
        if (good.Property != null)
        {
            for (int i = 0; i < good.Property.Length; i++)
            {
                if (good.Property[i] == 0)
                {
                    break;
                }

                Materiral.Property _p    = Materiral.GetProNameByProID(good.Property[i]);
                GameObject         p_obj = goodsUIBase.propertys[i];
                p_obj.SetActive(true);
                p_obj.transform.GetChild(0).GetComponent <Text>().text    = _p.Name;
                p_obj.transform.GetChild(1).GetComponent <Image>().sprite = Materiral.GetPropertyIcon(_p.ID);

                Propertys.Add(_p);
            }
        }

        //类型
        goodsUIBase.typeText.text = Materiral.FindTypeNameByID(good.Type).Name;

        string str = Materiral.GetDesByMaterialID(good.MateriralType, good.ID);

        //描述
        goodsUIBase.des.text = System.Text.RegularExpressions.Regex.Unescape(str);
    }
Пример #2
0
    //设置合成界面槽的信息和位置
    void SetSlot(Recipe.RecipeMap map)
    {
        int num = map.Slots.Length;

        //TODO:游戏道具的名称和ID,以及按钮的表现效果
        Vector3 base_point  = new Vector3(0, -100, 0);
        int     targetAngel = 0;

        SlotList = new Dictionary <int, SlotBox>();

        for (int i = 0; i < num; i++)
        {
            GameObject recipeSlot = Instantiate(btn_recipeSlot);
            recipeSlot.transform.SetParent(recipeSlotsList.transform, false);

            //设置按钮位置
            targetAngel = 360 / num * i;

            Vector3 target_pos = Quaternion.Euler(0, 0, targetAngel) * base_point;
            recipeSlot.transform.localPosition = target_pos;

            //判断slot中材料的类型,0为固定材料,1为材料种类
            if (map.Slots[i].SlotType == Recipe.SlotTypeList.Material)
            {
                //固定材料
                if (map.Slots[i].MatType == 0)  //Item
                {
                    Materiral.Items _item = Materiral.FindItemByID(map.Slots[i].MatId);

                    recipeSlot.name = i.ToString();
                    recipeSlot.transform.Find("Text").GetComponent <Text>().text            = "[" + _item.Name + "]";
                    recipeSlot.transform.Find("Bottom/Image").GetComponent <Image>().sprite = Materiral.GetIconByName(_item.IMG);
                    recipeSlot.transform.Find("Bottom/Image").GetComponent <Image>().color  = new Color(1, 1, 1, 0.5f);
                }
                else if (map.Slots[i].MatType == 1)  //Mind
                {
                    Materiral.Minds _mind = Materiral.FindMindByID(map.Slots[i].MatId);
                    recipeSlot.name = i.ToString();
                    recipeSlot.transform.Find("Text").GetComponent <Text>().text            = "[" + _mind.Name + "]";
                    recipeSlot.transform.Find("Bottom/Image").GetComponent <Image>().sprite = Materiral.GetIconByName(_mind.IMG);
                    recipeSlot.transform.Find("Bottom/Image").GetComponent <Image>().color  = new Color(1, 1, 1, 0.5f);
                }
            }
            else if (map.Slots[i].SlotType == Recipe.SlotTypeList.MaterialType)
            {
                //材料类型
                recipeSlot.name = i.ToString();

                int typeID = map.Slots[i].MatType;
                Materiral.MaterialType type = Materiral.FindTypeNameByID(typeID);
                recipeSlot.transform.Find("Text").GetComponent <Text>().text            = "<color=red>[" + type.Name + "]\n(类型)</color>";
                recipeSlot.transform.Find("Bottom/Image").GetComponent <Image>().sprite = Materiral.GetIconByName(type.IMG);
                recipeSlot.transform.Find("Bottom/Image").GetComponent <Image>().color  = new Color(1, 1, 1, 0.5f);
            }
            else
            {
                Debug.Log("Can't find recipe slots!");
            }

            //设置参数容器中的参数
            Parameter.Box parameter = new Parameter.Box();
            parameter.ID       = i; //ID为slot的序号
            parameter.callback = ClickInBag;
            parameter.obj      = map.Slots[i];
            parameter.subobj   = SlotList;

            //添加记录到合成系统用容器中
            SlotBox slot = new SlotBox();
            slot.button = recipeSlot;
            SlotList.Add(i, slot);

            //设置点击事件
            GameObject _slot = recipeSlot.transform.Find("Bottom/Image").gameObject;
            EventTriggerListener.Get(_slot).parameter          = parameter;
            EventTriggerListener.Get(_slot).onClickByParameter = OpenBag;
        }
    }