Ejemplo n.º 1
0
    //! 生成内部道具
    void GenerateItemsInBag()
    {
        // 疑问:这个是排序吗?
        GameData.lstBagItems.Sort((Item x, Item y) => x.Order.CompareTo(y.Order));

        for (int i = 0; i < trsSlotItemRoot.childCount; i++)
        {
            UISlotItem       item  = trsSlotItemRoot.GetChild(i).GetComponent <UISlotItem>();
            UISelectableItem sItem = item.gameObject.AddMissingComponent <UISelectableItem>();

            if (i < GameData.lstBagItems.Count)
            {
                item.UpdateShowInfo(GameData.lstBagItems[i]);

                sItem.bSelectable = true;

                sItem.cbSelect = OnSlotSelected;
            }
            else
            {
                item.imgIcon.sprite = null;
                item.ShowIcon       = sItem.bSelectable = false;
                item.ShowQuality    = false;
                item.ShowScore      = false;
                item.ShowCount      = false;
                sItem.cbSelect      = null;
            }
        }
    }
Ejemplo n.º 2
0
    void GenerateSlotNature(Transform trsroot, GameObject objslot, List <string> lstslotid)
    {
        // 生成格子
        for (int i = trsroot.childCount; i < lstslotid.Count; i++)
        {
            var skill = GameObject.Instantiate(objslot) as GameObject;
            skill.name = objslot.name + "_" + i;
            skill.transform.SetParent(trsroot);
            skill.transform.localScale = Vector3.one;
        }

        // 生成内容
        for (int i = 0; i < trsroot.childCount; i++)
        {
            MemberNatureSlot item  = trsroot.GetChild(i).GetComponent <MemberNatureSlot>();
            UISelectableItem sItem = item.gameObject.AddMissingComponent <UISelectableItem>();

            if (i < trsroot.childCount)
            {
                // TODO::技能\喜好\性格 的贴图
                // item.imgIcon.sprite =  DataCenter.Instance.dictItem[lstslotid[i]].IconSprite;
                item.gameObject.SetActive(true);
                sItem.bSelectable = true;
                sItem.cbSelect    = OnNatureClicked;

                item.imgBg.gameObject.SetActive(true);


                // 技能是否已经解锁
                if (trsroot == trsNpcSkillRoot)
                {
                    if (_npcdata.SkillUnlocklv [i] <= GameData.nPlayerLv)
                    {
                        item.imgLock.gameObject.SetActive(false);
                    }
                    else
                    {
                        item.imgLock.gameObject.SetActive(true);
                    }
                }
                else
                {
                    item.imgLock.gameObject.SetActive(false);
                }
            }
            else
            {
                item.imgIcon.sprite = null;
                item.gameObject.SetActive(false);
                sItem.bSelectable = false;
                sItem.cbSelect    = null;

                item.imgBg.gameObject.SetActive(false);
                item.imgLock.gameObject.SetActive(false);
            }
        }
    }
Ejemplo n.º 3
0
    public override void OnClick(Button button)
    {
        if (isFocus)
        {
            base.OnClick(button);

            UISelectableItem item    = button.GetComponent <UISelectableItem>();
            bool             hasitem = false;
            if (item.type == 1)
            {
                foreach (Skill skill in Player.Instance.skillList)
                {
                    if (skill.type == item.skill.type)
                    {
                        hasitem = true;
                        break;
                    }
                }
            }
            else if (item.type == 2)
            {
                Debug.Log("222");
                foreach (Equipment equipment in Player.Instance.equipmentList)
                {
//                    Debug.Log("equiptype : " + equipment.type + "   item type : " + item.equipment.type);
                    if (equipment.type == item.equipment.type)
                    {
                        hasitem = true;
                        break;
                    }
                }
            }

            if (hasitem)
            {
                UIWindowController.Instance.itemSelect.Open(button);
            }
            else
            {
                UIWindowController.Instance.noticeWindow.Open("no such items");
            }
        }
    }
Ejemplo n.º 4
0
    private void ShowSameItemList(UISelectableItem item)
    {
        if (item.type == 1)
        {
            foreach (Skill skill in Player.Instance.skillList)
            {
                if (skill.type == item.skill.type)
                {
                    var inst = Instantiate(Resources.Load <GameObject>("Prefab/UI/Buttons/UI_Item1"), content);
                    inst.GetComponent <UISelectableItem>().skill = skill;
                    inst.GetComponent <UISelectableItem>().type  = 1;

                    inst.transform.Find("Image").GetComponent <Image>().sprite = skill.Icon;
                    inst.transform.Find("Text").GetComponent <Text>().text     = skill.m_name;
                    inst.transform.Find("isEquiped").gameObject.SetActive(skill.isEquiped);

                    Items.Add(inst);
                    inst.transform.localPosition = pos0.localPosition - (pos1.localPosition - pos0.localPosition) * (Items.Count - 1);
                }
            }
        }
        else if (item.type == 2)
        {
            foreach (Equipment equipment in Player.Instance.equipmentList)
            {
                Debug.Log("equiptype : " + equipment.type + "   item type : " + item.equipment.type);
                if (equipment.type == item.equipment.type)
                {
                    var inst = Instantiate(Resources.Load <GameObject>("Prefab/UI/Buttons/UI_Item1"), content);
                    inst.GetComponent <UISelectableItem>().equipment = equipment;
                    inst.GetComponent <UISelectableItem>().type      = 2;

                    inst.transform.Find("Image").GetComponent <Image>().sprite = equipment.Icon;
                    inst.transform.Find("Text").GetComponent <Text>().text     = equipment.name;
                    inst.transform.Find("isEquiped").gameObject.SetActive(equipment.isEquiped);

                    Items.Add(inst);
                    inst.transform.localPosition = pos0.localPosition - (pos1.localPosition - pos0.localPosition) * (Items.Count - 1);
                }
            }
        }
    }