Example #1
0
    public bool Dress(int id)
    {
        ObjectInfo info = ObjectsInfo.instance.GetObjectInfoById(id);

        GameObject parent = null;

        if (info.type == ObjcetType.Drug)
        {
            return(false);
        }
        switch (info.dressType)
        {
        case DressType.Headgear:
            parent = headgear;
            break;

        case DressType.Armor:
            parent = armor;
            break;

        case DressType.RightHand:
            parent = RightHand;
            break;

        case DressType.LeftHand:
            parent = leftHand;
            break;

        case DressType.Shoe:
            parent = shoe;
            break;

        case DressType.Accessory:
            parent = accessory;
            break;
        }
        EquipItem item = parent.GetComponentInChildren <EquipItem>();

        if (item != null)
        {
            Inventory.instance.GetId(item.id);
            item.SetInfo(info);
        }
        else
        {
            GameObject itemGo = Instantiate(EquipItem);
            itemGo.transform.parent        = parent.gameObject.transform;
            itemGo.transform.localPosition = Vector3.zero;
            itemGo.GetComponent <EquipItem>().SetInfo(info);
            itemGo.transform.parent.GetChild(0).gameObject.SetActive(false);
            Inventory.instance.PlussProperty(id);
        }
        return(true);
    }
Example #2
0
    public bool Dress_load(int id)
    {
        objectInfo info   = ObjectsInfo.instance.FindObjecInfoById(id);
        GameObject parent = null;

        switch (info.dressType)
        {
        case DressType.Headgear:
            parent = headgear;
            break;

        case DressType.Armor:
            parent = armor;
            break;

        case DressType.LeftHand:
            parent = lefthand;
            break;

        case DressType.RightHand:
            parent = righthand;
            break;

        case DressType.Shoe:
            parent = shoe;
            break;

        case DressType.Accessory:
            parent = accessory;
            break;
        }

        EquipItem item = parent.GetComponentInChildren <EquipItem>();

        if (item != null)
        {
            EquipAndBag.instance.getId(item.id);//装备卸下,放回
            MinProperty(item.id);
            item.SetInfo(info);
            plusProperty(info.id);
        }
        else
        {
            GameObject itemGo = Instantiate(equip_item);
            itemGo.transform.SetParent(parent.transform);
            itemGo.transform.position = parent.transform.position;
            itemGo.GetComponent <EquipItem>().SetInfo(info);
            plusProperty(id);
        }

        //UpdateProperty ();
        return(true);
    }
Example #3
0
    public override void OnFirstOpen()
    {
        base.OnFirstOpen();

        wndPrepare = ViewManager.Get <WndPrepare>("WndPrepare");

        bagContainer     = GetGameObject("bagContainer");
        bagContainerRect = bagContainer.GetComponent <RectTransform>();

        bagMoveHeight = bagContainerRect.rect.height +
                        GetRectTransform("bagContainer/closeBtn").rect.height + 10;

        bagContainerRect.anchoredPosition = new Vector2(0, -bagMoveHeight);

        sellEquipGo = GetGameObject("bagContainer/sell");
        equipPrice  = GetText("bagContainer/sell/text");

        GameObject bagGrid = GetGameObject("bagContainer/bagList/grid");

        bagListRect = GetRectTransform("bagContainer/bagList");

        AddUIButton("bagContainer/closeBtn", (go) => { SetVisible(false); });

        //18个装备格子
        for (int i = 0; i < 18; i++)
        {
            var        equipItem = new EquipItem();
            GameObject go        = GameObject.Instantiate(bagGrid, bagListRect);

            equipItem.Init(go, i);
            equipItem.SetInfo(equipModel.GetEquip(i));
            equipItems[i] = equipItem;
        }
        bagGrid.SetActive(false);

        TimeManager.Regist((id) => { GameObject.Destroy(GetComponent <GridLayoutGroup>("bagContainer/bagList")); }
                           , 0.5f, 0, 1);
    }