Example #1
0
    //更新 穿上装备后 的人物 属性
    void UpdateProperty()
    {
        this.attack = 0;
        this.def    = 0;
        this.speed  = 0;

        UIEquipmentItem headgearItem = headgear.GetComponentInChildren <UIEquipmentItem>();

        PlusProperty(headgearItem);
        UIEquipmentItem armorItem = armor.GetComponentInChildren <UIEquipmentItem>();

        PlusProperty(armorItem);
        UIEquipmentItem leftHandItem = leftHand.GetComponentInChildren <UIEquipmentItem>();

        PlusProperty(leftHandItem);
        UIEquipmentItem rightHandItem = rightHand.GetComponentInChildren <UIEquipmentItem>();

        PlusProperty(rightHandItem);
        UIEquipmentItem shoeItem = shoe.GetComponentInChildren <UIEquipmentItem>();

        PlusProperty(shoeItem);
        UIEquipmentItem accessoryItem = accessory.GetComponentInChildren <UIEquipmentItem>();

        PlusProperty(accessoryItem);
    }
Example #2
0
 void PlusProperty(UIEquipmentItem item)
 {
     if (item != null)
     {
         ObjectInfo equipInfo = ObjectsInfo._instance.GetObjectInfoById(item.itemId);
         this.attack += equipInfo.attack;
         this.def    += equipInfo.def;
         this.speed  += equipInfo.speed;
     }
 }
Example #3
0
 bool isHover = false;//是否在装备上
 private void Awake()
 {
     Instance = this;
     sprite   = GetComponent <UISprite>();
 }
Example #4
0
    //穿上装备
    //处理装备穿戴功能
    public bool Dress(int id)
    {
        ObjectInfo info = ObjectsInfo._instance.GetObjectInfoById(id);

        if (info.type != ObjectType.Equip)
        {
            return(false);//穿戴不成功
        }
        if (ps.heroType == PlayerType.Magician)
        {
            if (info.applicationType == ApplicationType.Swordman)
            {
                return(false);
            }
        }
        if (ps.heroType == PlayerType.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;
        }
        UIEquipmentItem item = parent.GetComponentInChildren <UIEquipmentItem>();

        if (item != null)
        {                                              //说明已经穿戴了同样类型的装备
            UIInventory.Instance.GetItem(item.itemId); //把已经穿戴的装备卸下,放回物品栏
            item.SetItemInfo(info);
        }
        else
        {//没有穿戴同样类型的装备
            GameObject itemGo = NGUITools.AddChild(parent, equipmentItem);
            itemGo.transform.localPosition = Vector3.zero;
            itemGo.GetComponent <UIEquipmentItem>().SetItemInfo(info);
        }
        UpdateProperty();
        return(true);
    }