Пример #1
0
        void CreateLogic(ItemObject itemObj)
        {
            if (mLogics.ContainsKey(itemObj.instanceId))
            {
                return;
            }

            ItemAsset.Equip equip = itemObj.GetCmpt <ItemAsset.Equip>();

            if (null == equip)
            {
                return;
            }

            GameObject obj = equip.CreateLogicObj();

            if (null == obj)
            {
                return;
            }

            PEEquipmentLogic equ = obj.GetComponent <PEEquipmentLogic>();

            if (null == equ)
            {
                Debug.LogError("Equip can't find:" + itemObj.nameText);
                GameObject.Destroy(obj);
                return;
            }
            obj.transform.parent = m_EquipmentLogicParent;

            equ.InitEquipment(Entity, itemObj);

            mLogics[itemObj.instanceId] = equ;
        }
Пример #2
0
    //public static bool CanEquip(ItemObject item, int sex)
    //{
    //    PeSex targetSex = (sex == 1) ? Pathea.PeSex.Female : Pathea.PeSex.Male;
    //    return CanEquip(item, targetSex);
    //}

    public static bool CanEquip(ItemObject item, PeSex targetSex)
    {
        if (null == item)
        {
            return(false);
        }

        ItemAsset.Equip equip = item.GetCmpt <ItemAsset.Equip>();
        if (null == equip)
        {
            return(false);
        }

        if (equip.equipPos == 0)
        {
            return(false);
        }

        if (!Pathea.PeGender.IsMatch(equip.sex, targetSex))
        {
            return(false);
        }

        return(true);
    }
Пример #3
0
        void EquipSheild()
        {
            if (entity.NpcCmpt.EqSelect.BetterAtkObj != null)
            {
                AttackMode m_Atkmode = entity.NpcCmpt.EqSelect.BetterAtkObj.protoData.weaponInfo.attackModes[0];
                if (m_Atkmode.type == AttackType.Ranged)
                {
                    return;
                }
            }

            ItemObject m_BetterDefObj = null;

            if (entity.NpcCmpt.EqSelect.SetSelectObjsDef(entity, EeqSelect.protect))
            {
                m_BetterDefObj = entity.NpcCmpt.EqSelect.GetBetterDefObj();
            }

            if (m_BetterDefObj == null)
            {
                return;
            }

            ItemAsset.Equip equip = m_BetterDefObj.GetCmpt <ItemAsset.Equip>();
            if (null == equip)
            {
                return;
            }

            bool HasEquipUsed = false;

            for (int i = 0; i < entity.equipmentCmpt._ItemList.Count; ++i)
            {
                ItemObject      item       = entity.equipmentCmpt._ItemList[i];
                ItemAsset.Equip existEquip = item.GetCmpt <ItemAsset.Equip>();
                if (null != existEquip)
                {
                    if (System.Convert.ToBoolean(equip.equipPos & existEquip.equipPos))
                    {
                        HasEquipUsed = true;
                        break;
                    }
                }
            }

            if (HasEquipUsed && entity.motionEquipment.sheild == null)
            {
                return;
            }
            //Def
            if ((!HasEquipUsed && m_BetterDefObj != null))// entity.motionEquipment.sheild == null
            {
                SelectItem.EquipByObj(entity, m_BetterDefObj);
            }
            else if ((HasEquipUsed && m_BetterDefObj != null && entity.motionEquipment.sheild.m_ItemObj != m_BetterDefObj))
            {
                SelectItem.EquipByObj(entity, m_BetterDefObj);
            }
        }
Пример #4
0
 void RemoveItemEff(ItemObject itemObj)
 {
     ItemAsset.Equip equip = itemObj.GetCmpt <ItemAsset.Equip>();
     if (null != equip)
     {
         equip.RemoveBuff(mSkEntity);
     }
 }
Пример #5
0
 void ApplyItemEff(ItemObject itemObj)
 {
     ItemAsset.Equip equip = itemObj.GetCmpt <ItemAsset.Equip>();
     if (null != equip)
     {
         if (mSkEntity == null)
         {
             mSkEntity = GetComponent <SkEntity>();
         }
         equip.AddBuff(mSkEntity);
     }
 }
Пример #6
0
 void ReduceWeaponDurability(ItemObject itemObj)
 {
     if (null != itemObj)
     {
         if (GameConfig.IsMultiMode)
         {
             PlayerNetwork.mainPlayer.RequestWeaponDurability(Entity.Id, itemObj.instanceId);
         }
         else
         {
             ItemAsset.Equip equipCmpt = itemObj.GetCmpt <ItemAsset.Equip>();
             equipCmpt.ExpendAttackDurability(mSkEntity);
         }
     }
 }
Пример #7
0
        void CreateModel(ItemObject itemObj)
        {
            if (mViewCmpt == null)
            {
                mViewCmpt = Entity.biologyViewCmpt;
            }
            if (null == mViewCmpt.modelTrans)
            {
                return;
            }
            ItemAsset.Equip equip = itemObj.GetCmpt <ItemAsset.Equip>();

            if (null == equip)
            {
                return;
            }

            GameObject obj = equip.CreateGameObj();

            if (null == obj)
            {
                return;
            }

            PEEquipment equ = obj.GetComponent <PEEquipment>();

            if (null == equ)
            {
                Debug.LogError("Equip can't find:" + itemObj.nameText);
                GameObject.Destroy(obj);
                return;
            }

            //IgnoreCollision
//			PETools.PEUtil.IgnoreCollision(obj, gameObject);
            equ.InitEquipment(Entity, itemObj);
            mEquipments.Add(equ);
            HideEquipmentByFirstPerson(equ, m_HideEquipmentByFirstPerson);
            HideEquipmentByVehicle(equ, m_HideEquipmentByVehicle);
            HidEquipmentByRagdoll(equ, m_HideEquipmentByRagdoll);
            mMotionEquip.SetEquipment(equ, true);
            PreLoadEquipmentEffect(equ);
        }
Пример #8
0
    void RefreshEquipmentList()
    {
        for (int i = 0; i < 10; i++)
        {
            mEquipment[i].SetItem(null);
        }

        foreach (ItemObject item in equipmentCmpt._ItemList)
        {
            ItemAsset.Equip equip = item.GetCmpt <ItemAsset.Equip>();

            for (int i = 0; i < 10; i++)
            {
                if (Convert.ToBoolean(equip.equipPos & (int)mEquipment[i].ItemMask))
                {
                    mEquipment[i].SetItem(item);
                }
            }
        }
    }
Пример #9
0
 void ReduceArmorDurability(float damage, SkEntity caster)
 {
     if (GameConfig.IsMultiMode)
     {
         int[] equipIds = mItemList.Select(iter => null != iter ? iter.instanceId : -1).ToArray();
         PlayerNetwork.mainPlayer.RequestArmorDurability(Entity.Id, equipIds, damage, caster);
     }
     else
     {
         for (int i = 0; i < mItemList.Count; ++i)
         {
             ItemObject itemObj = mItemList[i];
             if (null != itemObj)
             {
                 ItemAsset.Equip equipCmpt = itemObj.GetCmpt <ItemAsset.Equip>();
                 equipCmpt.ExpendDefenceDurability(mSkEntity, damage);
             }
         }
     }
 }
Пример #10
0
 IEnumerator PreLoad()
 {
     if (mItemList != null)
     {
         //Object asset;
         for (int i = 0; i < mItemList.Count; i++)                       // using foreach may cause exception when mItemList changed out of this method
         {
             ItemObject itemObj = mItemList [i];
             if (!ISAvatarModel(itemObj))
             {
                 ItemAsset.Equip equip = itemObj.GetCmpt <ItemAsset.Equip> ();
                 if (null != equip)
                 {
                     AssetsLoader.Instance.AddReq(new AssetReq(equip.protoData.resourcePath));
                     yield return(new WaitForSeconds(0.2f));
                 }
             }
         }
     }
 }
Пример #11
0
    void RefreshEqList()
    {
        ClearEqList();
        //lz-2016.11.23 错误 #6922 Crush bug
        if (null != equipmentCmpt && null != equipmentCmpt._ItemList && equipmentCmpt._ItemList.Count > 0)
        {
            foreach (ItemObject item in equipmentCmpt._ItemList)
            {
                ItemAsset.Equip equip = item.GetCmpt <ItemAsset.Equip>();

                if (null != equip && null != mEquipmentList && mEquipmentList.Count >= 10)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        if (Convert.ToBoolean(equip.equipPos & (int)mEquipmentList[i].ItemMask))
                        {
                            mEquipmentList[i].SetItem(item);
                        }
                    }
                }
            }
        }
    }
Пример #12
0
        public bool PutOnEquipment(ItemObject itemObj, bool addToReceiver = true, Receiver receiver = null, bool netRequest = false)
        {
            if (!netRequest && null != mViewCmpt && mViewCmpt.IsRagdoll)
            {
                return(false);
            }

            Receiver currentReceiver = (null == receiver)?mItemReciver:receiver;

            if (null == itemObj)
            {
                return(false);
            }

            ItemAsset.Equip equip = itemObj.GetCmpt <ItemAsset.Equip>();

            if (null == equip)
            {
                return(false);
            }

            if (!Pathea.PeGender.IsMatch(equip.sex, Entity.ExtGetSex()))
            {
                return(false);
            }

            if (mItemList.Contains(itemObj))
            {
                return(false);
            }
            SkillTreeUnitMgr learntSkills = Entity.GetCmpt <SkillTreeUnitMgr>();

            if (!netRequest && learntSkills != null && RandomMapConfig.useSkillTree)
            {
                if (!learntSkills.CheckEquipEnable(equip.protoData.itemClassId, equip.itemObj.level))
                {
                    return(false);
                }
            }
            m_TakeOffEquip.Clear();
            for (int i = 0; i < mItemList.Count; ++i)
            {
                ItemObject      item       = mItemList[i];
                ItemAsset.Equip existEquip = item.GetCmpt <ItemAsset.Equip>();
                if (null != existEquip)
                {
                    if (System.Convert.ToBoolean(equip.equipPos & existEquip.equipPos))
                    {
                        m_TakeOffEquip.Add(item);
                    }
                }
            }
            for (int i = 0; i < mEquipments.Count; ++i)
            {
                if (m_TakeOffEquip.Contains(mEquipments[i].m_ItemObj) && !netRequest && !mEquipments[i].CanTakeOff())
                {
                    return(false);
                }
            }

            if (!netRequest && addToReceiver && null != currentReceiver)
            {
                if (!currentReceiver.CanAddItemList(m_TakeOffEquip))
                {
                    //lz-2016.08.15 如果是NPC的背包满了要单独提示
                    if (currentReceiver is NpcPackageCmpt)
                    {
                        PeTipMsg.Register(PELocalization.GetString(82209013), PeTipMsg.EMsgLevel.Warning);
                    }
                    else
                    {
                        PeTipMsg.Register(PELocalization.GetString(82209001), PeTipMsg.EMsgLevel.Warning);
                    }
                    return(false);
                }
            }

            for (int i = mItemList.Count - 1; i >= 0; i--)
            {
                if (m_TakeOffEquip.Contains(mItemList[i] as ItemObject))
                {
                    mItemList.RemoveAt(i);
                }
            }
            mItemList.Add(itemObj);

            if (addToReceiver && null != currentReceiver)
            {
                currentReceiver.AddItemList(m_TakeOffEquip);
            }

            //Do change
            for (int i = 0; i < m_TakeOffEquip.Count; ++i)
            {
                ItemObject item = m_TakeOffEquip[i];
                RemoveItemEff(item);
                RemoveModel(item);
                mEquipType &= ~item.protoData.equipType;
                EventArg removeEvtArg = new EventArg();
                removeEvtArg.isAdd   = false;
                removeEvtArg.itemObj = item;
                changeEventor.Dispatch(removeEvtArg, this);
            }

            ApplyItemEff(itemObj);
            AddModel(itemObj);
            mEquipType |= itemObj.protoData.equipType;

            EventArg evtArg = new EventArg();

            evtArg.isAdd   = true;
            evtArg.itemObj = itemObj;
            changeEventor.Dispatch(evtArg, this);

            if (0 != (itemObj.protoData.equipPos & (1 << 4)))
            {
                mainHandEquipment = itemObj;
            }

            if (OnEquipmentChange != null)
            {
                OnEquipmentChange();
            }

            //lz-2016.08.22 引导检测玩家穿装备
            if (Entity.IsMainPlayer)
            {
                InGameAidData.CheckPutOnEquip(itemObj.protoId);
            }

            m_EquipmentDirty = true;

            return(true);
        }
Пример #13
0
        public bool NetTryPutOnEquipment(ItemObject itemObj, bool addToReceiver = true, Receiver receiver = null)
        {
            if (null != mViewCmpt && mViewCmpt.IsRagdoll)
            {
                return(false);
            }
            Receiver currentReceiver = (null == receiver)?mItemReciver:receiver;

            if (null == itemObj)
            {
                return(false);
            }
            if (mItemList.Contains(itemObj))
            {
                return(false);
            }

            ItemAsset.Equip equip = itemObj.GetCmpt <ItemAsset.Equip>();

            if (null == equip)
            {
                return(false);
            }

            if (!Pathea.PeGender.IsMatch(equip.sex, Entity.ExtGetSex()))
            {
                return(false);
            }
            SkillTreeUnitMgr learntSkills = Entity.GetCmpt <SkillTreeUnitMgr>();

            if (learntSkills != null && RandomMapConfig.useSkillTree)
            {
                if (!learntSkills.CheckEquipEnable(equip.protoData.itemClassId, equip.itemObj.level))
                {
                    return(false);
                }
            }

            m_TakeOffEquip.Clear();
            for (int i = 0; i < mItemList.Count; ++i)
            {
                ItemObject item = mItemList[i];
                if (item == itemObj)
                {
                    return(false);
                }
                ItemAsset.Equip existEquip = item.GetCmpt <ItemAsset.Equip>();
                if (null != existEquip)
                {
                    if (System.Convert.ToBoolean(equip.equipPos & existEquip.equipPos))
                    {
                        m_TakeOffEquip.Add(item);
                    }
                }
            }

            for (int i = 0; i < mEquipments.Count; ++i)
            {
                if (m_TakeOffEquip.Contains(mEquipments[i].m_ItemObj) && !mEquipments[i].CanTakeOff())
                {
                    return(false);
                }
            }

            if (null != currentReceiver)
            {
                if (!currentReceiver.CanAddItemList(m_TakeOffEquip))
                {
                    return(false);
                }
            }

            return(true);
        }