Пример #1
0
    public void SetGoodsName(int MaterialType)
    {
        //创建物品列表
        for (int i = 0; i < _bagList.Count; i++)
        {
            CharBag.Goods _map = (CharBag.Goods)_bagList[i];

            //筛选物品,特殊物品不显示
            if (MaterialType != -1)
            {
                if (_map.MateriralType != MaterialType)
                {
                    continue;
                }
                if (_map.MateriralType == 2 && _map.Type == 0)
                {
                    continue;
                }
            }

            GameObject button = Instantiate(btn_menu);
            button.transform.SetParent(_fitter.transform, false);

            button.name = _map.ID.ToString();
            button.transform.Find("Text").GetComponent <Text>().text     = _map.Name;
            button.transform.Find("Image").GetComponent <Image>().sprite = Materiral.GetMaterialIcon(_map.MateriralType, _map.ID);

            //显示数量
            button.transform.Find("num").gameObject.SetActive(true);
            button.transform.Find("num/Text").GetComponent <Text>().text = _map.Number.ToString();

            //显示价格
            button.transform.Find("PriceBoard").gameObject.SetActive(true);
            button.transform.Find("PriceBoard/Text").GetComponent <Text>().text = _map.Price.ToString();

            //设置参数容器中的参数
            Parameter.Box _p = new Parameter.Box();
            _p.obj = _map;

            //设置点击事件
            OnClickInScorll.Get(button.transform).parameter         = _p;
            OnClickInScorll.Get(button.transform).onHoldByParameter = ShowMateriralInfo;

            //添加背包进入筛选背包列表
            f_BagList.Add(_map);
        }

        //调整列表为置顶
        if (f_BagList.Count > 5)
        {
            setGird();
        }

        StartCoroutine(SetListToTop());
    }
Пример #2
0
    void SetRecipeName()
    {
        for (int i = 0; i < recipeMap.ReicipeList.Count; i++)
        {
            GameObject button = Instantiate(recipeButton);
            button.transform.SetParent(_fitter.transform, false);

            Recipe.RecipeMap _map = (Recipe.RecipeMap)recipeMap.ReicipeList[i];

            button.name = _map.ID.ToString();
            button.transform.Find("Text").GetComponent <Text>().text = _map.Name;
            int _t = _map.Target[0].ToString() == "0" ? 0 : 1;
            int _i = int.Parse(_map.Target.Substring(_map.Target.IndexOf(",") + 1));

            button.transform.Find("Image").GetComponent <Image>().sprite = Materiral.GetMaterialIcon(_t, _i);

            //设置点击事件
            //button.GetComponent<Button>().onClick.AddListener(OpenRecipe);
            OnClickInScorll.Get(button.transform).onClick = OpenRecipe;
        }
    }
Пример #3
0
    void SetRecipeNameInShop(object parameter)
    {
        Parameter.Box p = (Parameter.Box)parameter;
        //显示当前上架的物品
        if (p.obj != null)
        {
            CharBag.Goods currentGoods = (CharBag.Goods)p.obj;

            Image  _image  = shopGoods.transform.Find("Image").GetComponent <Image>();
            Text   _text   = shopGoods.transform.Find("Text").GetComponent <Text>();
            Button _button = shopGoods.transform.Find("Button").GetComponent <Button>();

            _text.text = "当前上架的商品:";
            _text.transform.localPosition = new Vector3(_text.transform.position.x, 50, _text.transform.position.z);
            _image.gameObject.SetActive(true);
            _image.sprite = Materiral.GetMaterialIcon(currentGoods.MateriralType, currentGoods.ID);
            EventTriggerListener.Get(_image.gameObject).parameter          = p;
            EventTriggerListener.Get(_image.gameObject).onClickByParameter = ShowMateriralInfo;

            _button.gameObject.SetActive(true);
            EventTriggerListener.Get(_button.gameObject).parameter          = p;
            EventTriggerListener.Get(_button.gameObject).onClickByParameter = p.callbackByEvent;
        }

        //创建物品列表
        for (int i = 0; i < _bagList.Count; i++)
        {
            CharBag.Goods _map = (CharBag.Goods)_bagList[i];

            //筛选物品,特殊物品不显示
            if (_map.MateriralType > 1)
            {
                continue;
            }

            GameObject button = Instantiate(btn_menu);
            button.transform.SetParent(_fitter.transform, false);

            button.name = _map.ID.ToString();
            button.transform.Find("Text").GetComponent <Text>().text     = _map.Name;
            button.transform.Find("Image").GetComponent <Image>().sprite = Materiral.GetMaterialIcon(_map.MateriralType, _map.ID);

            //显示数量
            button.transform.Find("num").gameObject.SetActive(true);
            button.transform.Find("num/Text").GetComponent <Text>().text = _map.Number.ToString();

            //显示价格
            button.transform.Find("PriceBoard").gameObject.SetActive(true);
            button.transform.Find("PriceBoard/Text").GetComponent <Text>().text = _map.Price.ToString();

            //设置参数容器中的参数
            Parameter.Box _p = new Parameter.Box();
            _p.ID  = p.ID;
            _p.obj = _map;

            //设置点击事件
            OnClickInScorll.Get(button.transform).parameter          = _p;
            OnClickInScorll.Get(button.transform).onClickByParameter = p.callback;
            OnClickInScorll.Get(button.transform).onHoldByParameter  = ShowMateriralInfo;

            //添加背包进入筛选背包列表
            f_BagList.Add(_map);
        }

        //调整列表为置顶
        if (f_BagList.Count > 5)
        {
            setGird();
        }

        StartCoroutine(SetListToTop());
    }
Пример #4
0
    //TODO:add type mode
    void SetRecipeNameFilter(object parameter)
    {
        Parameter.Box p    = (Parameter.Box)parameter;
        Recipe.Slot   slot = (Recipe.Slot)p.obj;
        Dictionary <int, RecipeUI.SlotBox> slotList = (Dictionary <int, RecipeUI.SlotBox>)p.subobj;

        for (int i = 0; i < _bagList.Count; i++)
        {
            CharBag.Goods _map  = new CharBag.Goods();
            CharBag.Goods m_map = (CharBag.Goods)_bagList[i];

            ////////筛选
            if (slot.SlotType == Recipe.SlotTypeList.Material)
            {
                //固定材料
                if (slot.MatType == 0 && slot.MatType == m_map.MateriralType)  //Item
                {
                    if (m_map.ID == slot.MatId)
                    {
                        _map = m_map;
                    }
                }
                else if (slot.MatType == 1 && slot.MatType == m_map.MateriralType)  //Mind
                {
                    if (m_map.ID == slot.MatId)
                    {
                        _map = m_map;
                    }
                }
            }
            else if (slot.SlotType == Recipe.SlotTypeList.MaterialType)
            {
                if (m_map.Type == slot.MatType)
                {
                    _map = m_map;
                }
            }

            //添加进入背包列表,并且创建按钮
            if (_map.Name != null)
            {
                //添加背包进入筛选背包列表
                f_BagList.Add(_map);

                //创建按钮
                GameObject button = Instantiate(btn_menu);
                button.transform.SetParent(_fitter.transform, false);

                button.name = _map.ID.ToString();
                button.transform.Find("Text").GetComponent <Text>().text     = _map.Name;
                button.transform.Find("Image").GetComponent <Image>().sprite = Materiral.GetMaterialIcon(_map.MateriralType, _map.ID);

                //显示数量
                button.transform.Find("num").gameObject.SetActive(true);
                ;               button.transform.Find("num/Text").GetComponent <Text>().text = _map.Number.ToString();

                //设置参数容器中的参数
                Parameter.Box _p = new Parameter.Box();
                _p.ID  = p.ID;
                _p.obj = _map;

                //设置点击事件
                OnClickInScorll.Get(button.transform).parameter          = _p;
                OnClickInScorll.Get(button.transform).onClickByParameter = p.callback;
                OnClickInScorll.Get(button.transform).onHoldByParameter  = ShowMateriralInfo;


                //如果是已经的选中的则不能点击
                foreach (RecipeUI.SlotBox _slot in slotList.Values)
                {
                    if (_map.UID == _slot.slot.UID)
                    {
                        button.name = _map.ID.ToString();
                        button.transform.Find("Text").GetComponent <Text>().text = _map.Name + " <color=red>(E)</color>";
                        button.transform.GetComponent <Image>().color            = Color.gray;

                        OnClickInScorll.Get(button.transform).onClickByParameter = null;
                    }
                }
            }
        }
        //调整列表为置顶
        if (f_BagList.Count > 5)
        {
            setGird();
        }

        StartCoroutine(SetListToTop());
    }