示例#1
0
    //合成属性的方法
    public ArrayList ComposeProperty(ArrayList PropertyBox, out Result Compose)
    {
        //ArrayList SortPropertyBox = SelectionSortAscendingByProperty(PropertyBox);
        ArrayList AllComposeResult = FindAllComposeResult(PropertyBox);

        Compose = new Result();
        bool canCompose = false;

        foreach (Result r in AllComposeResult)
        {
            //如何有可以合成的属性则跳出循环
            if (canCompose)
            {
                break;
            }

            foreach (PropertyRecipe pr in PropertyRecipeList)
            {
                int _sum = pr.Slots[0] + pr.Slots[1];
                if (_sum == r.sum)
                {
                    if (pr.Slots[0] == r.Base1.Property.ID && pr.Slots[1] == r.Base2.Property.ID)
                    {
                        //表示可以合成
                        canCompose    = true;
                        Compose.sum   = pr.Target;
                        Compose.Base1 = r.Base1;
                        Compose.Base2 = r.Base2;
                        break;
                    }
                    if (pr.Slots[1] == r.Base1.Property.ID && pr.Slots[0] == r.Base2.Property.ID)
                    {
                        //表示可以合成
                        canCompose    = true;
                        Compose.sum   = pr.Target;
                        Compose.Base1 = r.Base1;
                        Compose.Base2 = r.Base2;
                        break;
                    }
                }
            }
        }

        if (canCompose)
        {
            Compose.Base1.Property            = Materiral.GetProNameByProID(Compose.sum);
            PropertyBox[Compose.Base1.ID - 1] = Compose.Base1;
            PropertyBox.Remove(Compose.Base2);

            for (int i = 0; i < PropertyBox.Count; i++)
            {
                RecipeUI.PropertyElementBase _p = (RecipeUI.PropertyElementBase)PropertyBox[i];
                _p.ID          = i + 1;
                PropertyBox[i] = _p;
            }
        }
        return(PropertyBox);
    }
示例#2
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);
    }
示例#3
0
    //属性效果UI效果
    void AddPropertyUIEft(CharBag.Goods _slot)
    {
        float actionTime = 0.5f;

        for (int i = 0; i < _slot.Property.Length; i++)
        {
            if (_slot.Property[i] == 0)
            {
                continue;
            }

            int           proID     = _slot.Property[i];
            RectTransform _property = Instantiate(PropertyListElement).GetComponent <RectTransform>();
            _property.transform.SetParent(PropertyListGrid.transform, false);

            _property.localPosition = GetPropertyPos(PropertyBox.Count + 1);
            _property.sizeDelta     = GetPropertySize(PropertyBox.Count + 1);

            //获取materiral的颜色
            Color _color_image = _property.GetComponent <Image>().color;
            Color _color_text  = _property.transform.Find("Text").GetComponent <Text>().color;
            Color from         = new Color(_color_image.r, _color_image.g, _color_image.b, 0);
            _property.GetComponent <Image>().color = from;
            _property.transform.Find("Image").GetComponent <Image>().color = from;
            _property.transform.Find("Text").GetComponent <Text>().color   = from;

            //渐现效果
            LeanTween.value(_property.gameObject, from, _color_image, 0.25f).setDelay(actionTime).setOnUpdate(
                (Color col) =>
            {
                _property.GetComponent <Image>().color = col;
            }
                );
            LeanTween.value(_property.gameObject, from, _color_text, 0.25f).setDelay(actionTime).setOnUpdate(
                (Color col) =>
            {
                _property.transform.Find("Text").GetComponent <Text>().color = col;
            }
                );
            LeanTween.value(_property.gameObject, from, new Color(1, 1, 1, 1), 0.25f).setDelay(actionTime).setOnUpdate(
                (Color col) =>
            {
                _property.transform.Find("Image").GetComponent <Image>().color = col;
            }
                );

            //TODO:点击效果

            //EndTODO

            Materiral.Property _p = Materiral.GetProNameByProID(proID);
            _property.transform.Find("Text").GetComponent <Text>().text     = _p.Name;
            _property.transform.Find("Image").GetComponent <Image>().sprite = Materiral.GetIconByName(_p.IMG);

            PropertyElementBase _proBase = new PropertyElementBase();
            _proBase.ID       = PropertyBox.Count + 1;
            _proBase.Property = _p;
            _proBase.Button   = _property;
            PropertyBox.Add(_proBase);
        }
    }