Beispiel #1
0
    //处理装备的穿戴与脱下
    public bool DressEquipment(int id)
    {
        ObjectOnInfo info = ObjectInfo._instance.GetObjctInfoById(id);

        if (info.type != ObjectType.Equip)
        {
            return(false);
        }
        if (ps.heroType == HeroType.Magician)
        {
            if (info.applicationType == ApplicationType.Swordman)
            {
                return(false);
            }
        }
        if (ps.heroType == HeroType.Swordman)
        {
            if (info.applicationType == ApplicationType.Magician)
            {
                return(false);
            }
        }

        GameObject parent = null;

        switch (info.dressType)
        {
        case DressType.Headgear:
            //print("----这是头盔");
            parent = headgear;
            break;

        case DressType.Armor:
            //print("----这是盔甲");
            parent = armor;
            break;

        case DressType.Left_Hand:
            parent = left_Hand;
            //print("------这是左手");
            break;

        case DressType.Right_Hand:
            //print("----这是右手");
            parent = right_Hand;
            break;

        case DressType.Shoe:
            //print("----这是鞋子");
            parent = shoe;
            break;

        case DressType.Accessory:
            //print("----这是饰品");
            parent = accessory;
            break;

        default:
            break;
        }
        EquipmentItem item = parent.GetComponentInChildren <EquipmentItem>();

        // EquipmentItem._instance.setInfo(info);
        if (item != null)
        {
            Inventory._instance.GetId(item.id); //把已经穿戴的装备脱下放回背包
            item.setInfo(info);                 // 更新新装备
        }
        else
        {
            GameObject itemGo = NGUITools.AddChild(parent, equipment);
            itemGo.transform.localPosition = Vector3.zero;
            itemGo.GetComponent <EquipmentItem>().setInfo(info);
        }
        UpdateProperty();
        return(true);
    }