Пример #1
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);
        }
Пример #2
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);
        }