Example #1
0
    void ClickInBag(GameObject go, object parameter)
    {
        Parameter.Box p     = (Parameter.Box)parameter;
        CharBag.Goods goods = (CharBag.Goods)p.obj;

    #if _Debug
        Debug.Log("ok!!" + "  Name:" + goods.Name + "  ID:" + p.ID);
    #endif

        SlotBox slotbox = new SlotBox();

        if (SlotList.ContainsKey(p.ID))
        {
            slotbox = SlotList[p.ID];
            slotbox.button.transform.Find("Text").GetComponent <Text>().text            = goods.Name;
            slotbox.button.transform.Find("Bottom/Image").GetComponent <Image>().sprite = Materiral.GetMaterialIcon(goods.MateriralType, goods.ID);
            slotbox.button.transform.Find("Bottom/Image").GetComponent <Image>().color  = new Color(1, 1, 1, 1f);

            //把物品添加到合成系统的slotlist中
            slotbox.slot   = goods;
            SlotList[p.ID] = slotbox;

            //CloseBag
            _bagInstance.CloseBagMenu(gameObject);
        }
    }
Example #2
0
    void SetPropertyPlane()
    {
        Quality                  = 0;
        QualityBar.size          = 0;
        QualityValue.text        = "0";
        QualitySkillPoint1.value = (float)recipe.EffetBox.Eft1.NeedQuality / 100;
        QualitySkillPoint1.transform.Find("Handle Slide Area/Handle/Text").GetComponent <Text>().text = recipe.EffetBox.Eft1.NeedQuality.ToString();
        QualitySkillPoint2.value = (float)recipe.EffetBox.Eft2.NeedQuality / 100;
        QualitySkillPoint2.transform.Find("Handle Slide Area/Handle/Text").GetComponent <Text>().text = recipe.EffetBox.Eft2.NeedQuality.ToString();
        QualitySkillPoint3.value = (float)recipe.EffetBox.Eft3.NeedQuality / 100;
        QualitySkillPoint3.transform.Find("Handle Slide Area/Handle/Text").GetComponent <Text>().text = recipe.EffetBox.Eft3.NeedQuality.ToString();

        QualityEffect.transform.GetChild(0).GetComponent <Text>().text = "";

        foreach (SlotBox slot in SlotList.Values)
        {
            Parameter.Box parameter = new Parameter.Box();
            //parameter.ID = slot.slot.UID;
            //parameter.callback = ClickInBag;

            parameter.obj = slot;
            GameObject _slotButton = slot.button.transform.Find("Bottom/Image").gameObject;
            EventTriggerListener.Get(_slotButton).parameter          = parameter;
            EventTriggerListener.Get(_slotButton).onClickByParameter = InputMaterial;
        }
    }
Example #3
0
    void RemoveGoods(GameObject go, object parameter)
    {
        Parameter.Box p = (Parameter.Box)parameter;
        //CharBag.Goods goods = (CharBag.Goods)p.obj;

        //如果货架上有商品,则添加道具到背包
        if (goodslist[p.ID - 1].Name != null && goodslist[p.ID - 1].ID != 0)
        {
            CharBag.AddGoods(goodslist[p.ID - 1]);
            goodslist[p.ID - 1] = new CharBag.Goods();
        }

        string path = p.ID.ToString() + "/itemIcon";

        transform.Find(path).GetComponent <SpriteRenderer>().sprite = null;

        //取消显示价格
        string priceiconpath = p.ID.ToString() + "/price/icon";
        string pricepath     = p.ID.ToString() + "/price/text";

        transform.Find(priceiconpath).gameObject.SetActive(false);
        transform.Find(pricepath).gameObject.SetActive(false);

        _bagInstance.CloseBagMenu(gameObject);
        ChangeRecipeUiState();

        PlayerData.ShopGoodsData.SaveShopGoods(goodslist);
    }
Example #4
0
    void ShowMateriralInfo(GameObject go, object parameter)
    {
        Parameter.Box _p    = (Parameter.Box)parameter;
        CharBag.Goods goods = (CharBag.Goods)_p.obj;

        ItemInfoUI info = Instantiate(iteminfo).GetComponent <ItemInfoUI>();

        info.Ini();
        info.OpenItemInfo(goods);
    }
Example #5
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());
    }
Example #6
0
    //打开特殊物品背包
    void OpenSpecialItemBagAll(GameObject obj)
    {
        _bagInstance = Instantiate(_bagUI).GetComponent <BagUI>();
        ////初始化
        _bagInstance.Initialize(2);

        Parameter.Box p = new Parameter.Box();
        p.callback = ClickInBag;
        _bagInstance.SetGoodsName(-1);

        ChangeRecipeUiState();
    }
Example #7
0
    //打开背包
    void OpenBag(int slotID)
    {
        _bagInstance = Instantiate(_bagUI).GetComponent <BagUI>();
        ////初始化
        _bagInstance.Initialize(2);

        Parameter.Box p = new Parameter.Box();
        p.ID              = slotID;
        p.callback        = ClickInBag;
        p.callbackByEvent = RemoveGoods;
        //如果货架上有商品,则添加道具到背包
        if (goodslist[slotID - 1].Name != null && goodslist[slotID - 1].ID != 0)
        {
            p.obj = goodslist[slotID - 1];
        }
        _bagInstance.OpenBagMenuInShop(p);

        ChangeRecipeUiState();
    }
Example #8
0
    //上架商品
    void ClickInBag(GameObject go, object parameter)
    {
        Parameter.Box p     = (Parameter.Box)parameter;
        CharBag.Goods goods = (CharBag.Goods)p.obj;

        //如果货架上有商品,则添加道具到背包
        if (goodslist[p.ID - 1].Name != null && goodslist[p.ID - 1].ID != 0)
        {
            CharBag.AddGoods(goodslist[p.ID - 1]);
        }

        //添加选中的商品到商品列
        goodslist[p.ID - 1] = goods;
        string path = p.ID.ToString() + "/itemIcon";

        transform.Find(path).GetComponent <SpriteRenderer>().sprite = Materiral.GetMaterialIcon(goods.MateriralType, goods.ID);

        //显示商品价格
        string priceiconpath = p.ID.ToString() + "/price/icon";
        string pricepath     = p.ID.ToString() + "/price/text";

        transform.Find(priceiconpath).gameObject.SetActive(true);
        transform.Find(pricepath).gameObject.SetActive(true);
        transform.Find(pricepath).GetComponent <TextMesh>().text = goods.Price.ToString();


        //移除背包中的商品
        CharBag.RemoveGoods(goods.UID);

        _bagInstance.CloseBagMenu(gameObject);
        ChangeRecipeUiState();

        PlayerData.ShopGoodsData.SaveShopGoods(goodslist);
        CharBag.SaveBagGoods();

        questManager.CheckQuestListWithGoods(QuestManager.QuestTypeList.PutGoods, goods, 0);

        //更新物品信息
        PlayerInfo.AddGoodsInfo(goods.MateriralType, goods.ID, PlayerInfo.GoodsInfoType.PutCount);
    }
Example #9
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());
    }
Example #10
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());
    }
Example #11
0
    void InputMaterial(GameObject go, object parameter)
    {
        //如果已经放入则不能再放入
        if (InputBox.Contains(parameter))
        {
            return;
        }

        //判断状态
        if (ripeState != RecipeStat.WaitInput)
        {
            return;
        }

        //改变状态
        ChangeRecipeStat(RecipeStat.Compose);

        InputBox.Add(parameter);
        Parameter.Box pro         = (Parameter.Box)parameter;
        SlotBox       _slot       = (SlotBox)pro.obj;
        GameObject    _slotButton = _slot.button.transform.Find("Bottom/Image").gameObject;

        //合成槽效果
        _slotButton.GetComponent <Image>().color = Color.gray;
        GameObject count = _slot.button.transform.Find("Count").gameObject;

        count.SetActive(true);
        count.transform.GetChild(0).GetComponent <Text>().text = InputBox.Count.ToString();

        //飞向属性栏
        GameObject _btn = Instantiate(btn_recipeSlot);

        _btn.transform.Find("Text").GetComponent <Text>().text            = _slot.slot.Name;
        _btn.transform.Find("Bottom/Image").GetComponent <Image>().sprite = Materiral.GetMaterialIcon(_slot.slot.MateriralType, _slot.slot.ID);
        _btn.transform.Find("Bottom").GetComponent <Image>().enabled      = false;
        _btn.transform.position   = _slot.button.transform.position;
        _btn.transform.localScale = _slot.button.transform.localScale;
        _btn.transform.SetParent(Plane.transform, false);

        Vector3       _movepos = new Vector3();
        Vector3       tmp      = GetPropertyPos(PropertyBox.Count + 1);
        RectTransform _box     = PropertyListGrid.GetComponent <RectTransform>();

        _movepos = new Vector3(tmp.x + _box.position.x, tmp.y + _box.position.y);

        float actionTime = 0.65f;

        LeanTween.move(_btn.gameObject, _movepos, actionTime).setEase(LeanTweenType.easeOutQuart);
        LeanTween.scale(_btn.gameObject, new Vector3(0.1f, 0.1f, 1), actionTime).setDestroyOnComplete(true);

        //属性栏UI效果
        if (_slot.slot.Property != null)
        {
            AddQualityUIEft(_slot);
            AddPropertyUIEft(_slot.slot);
            ComposeProperty();
        }
        else
        {
            AddQualityUIEft(_slot);
            ShowComposeButton();
            //改变状态
            ChangeRecipeStatByWait(RecipeStat.WaitInput, 0.5f);
            return;
        }
    }
Example #12
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;
        }
    }