Beispiel #1
0
    //品质UI效果
    void AddQualityUIEft(SlotBox _slot)
    {
        int oldQuality = Quality;

        if (InputBox.Count > 1)
        {
            Quality = (Quality + _slot.slot.Quality) / 2;
        }
        else
        {
            Quality = _slot.slot.Quality;
        }

        LeanTween.value(QualityValue.gameObject, oldQuality, Quality, 0.5f).setOnUpdate(
            (float q) =>
        {
            int text          = (int)q;
            QualityValue.text = text.ToString();
        }
            );
        LeanTween.value(QualityBar.gameObject, oldQuality, Quality, 0.5f).setOnUpdate(
            (float q) =>
        {
            QualityBar.size = q / 100;
        }
            );
    }
Beispiel #2
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);
        }
    }
Beispiel #3
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;
        }
    }
Beispiel #4
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;
        }
    }