Exemplo n.º 1
0
    public bool Dress(int id)
    {
        ObjectInfo info = ObjectsInfo._Instance.GetObjectInfo(id);

        if (!(info.type == ObjectType.Equip))
        {
            return(false);
        }

        if (info.applicationType != ApplicationType.Common && !info.applicationType.ToString().Equals(playerStatus.heroType.ToString()))
        {
            return(false);
        }

        GameObject parent = null;

        switch (info.dressType)
        {
        case DressType.Accessory:
            parent = accessory;
            break;

        case DressType.Armor:
            parent = armor;
            break;

        case DressType.Headgear:
            parent = headgear;
            break;

        case DressType.LeftHand:
            parent = leftHand;
            break;

        case DressType.RightHand:
            parent = rightHand;
            break;

        case DressType.Shoe:
            parent = shoe;
            break;
        }

        EquipmentItem equipmentItem = parent.GetComponentInChildren <EquipmentItem>();

        if (equipmentItem == null)
        {
            GameObject item = NGUITools.AddChild(parent, equipmentItemPrefabs);
            item.transform.localPosition = Vector3.zero;
            item.GetComponent <EquipmentItem>().SetInfo(info);
        }
        else
        {
            Inventory._Instance.GetItem(equipmentItem.currentItemId);
            equipmentItem.SetInfo(info);
        }
        UpdateProperty();
        return(true);
    }
Exemplo n.º 2
0
    // 处理物品穿戴功能
    public bool Dress(int id)
    {
        ObjectInfo info = ObjectsInfo._instance.GetObjectInfoById(id);

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

        GameObject parent = null;

        switch (info.dressType)
        {
        case DressType.Head:
            parent = head;
            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;
        }
        EquipmentItem item = parent.GetComponentInChildren <EquipmentItem>();

        if (item != null)
        {
            Inventory._instance.GetId(item.id);
            item.SetInfo(info);
        }
        else
        {
            GameObject itemGo = NGUITools.AddChild(parent, equipmentItem);
            itemGo.transform.localPosition = Vector3.zero;
            itemGo.GetComponent <EquipmentItem>().SetInfo(info);
        }
        UpdateProperty();
        return(true);
    }
Exemplo n.º 3
0
    public bool Dress(int id)  //是否穿戴成功
    {
        ObjectsInfo info = ObjectsInfo.instance.GetObjectsInfoById(id);

        if (info.type != ObjectsType.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:
            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;
        }

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

        if (item != null)                      //已经穿戴同类型的装备
        {
            Inventory.instance.GetId(item.id); //把已经穿戴的装备卸下,放回物品栏
            MinusProperty(item.id);            //减去之前装备的属性值

            item.SetInfo(info);                //换上新的装备,设置信息
            PlusProperty(id);                  //加上现在装备的属性值
        }
        else  //没有穿戴同类型的装备
        {
            GameObject itemGo = NGUITools.AddChild(parent, equipmentItem);
            itemGo.transform.localPosition = Vector3.zero;
            itemGo.GetComponent <EquipmentItem>().SetInfo(info);
            PlusProperty(id);  //增加装备属性值
        }

        return(true);
    }
Exemplo n.º 4
0
    /// <summary>
    /// 穿戴功能
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public bool Dress(int id)
    {
        ObjectInfo info = ObjectsInfo.instance.GetObjectInfoById(id);

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

        GameObject parent = null;

        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;

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

        if (item != null)
        {
            Inventory.instance.GetId(item.id);
            item.SetInfo(info);
        }
        else
        {
            var tempItem = GameObject.Instantiate(equipmentItem);
            tempItem.transform.SetParent(parent.transform);
            tempItem.transform.localPosition = Vector3.zero;
            tempItem.GetComponent <EquipmentItem>().SetInfo(info);
        }

        return(true);
    }