示例#1
0
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name="slot"></param>
        /// <param name="part"></param>
        public void DeleteSlotWeaponPart(EWeaponSlotType slot, EWeaponPartType part)
        {
            if (slot == EWeaponSlotType.None)
            {
                return;
            }
            WeaponEntity entity = GetWeaponAgent(slot).Entity;

            if (entity == null)
            {
                throw new ExWeaponNotFoundException("{0} slot weapon not found", slot);
                return;
            }

            WeaponPartsStruct lastParts = entity.weaponBasicData.GetParts();
            var parts = WeaponPartsUtil.ModifyParts(
                entity.weaponBasicData.GetParts(), part,
                UniversalConsts.InvalidIntId);

            entity.weaponBasicData.ApplyParts(parts);
            if (slot == HeldSlotType)
            {
                RefreshHeldWeaponAttachment();
            }
            var newParts = WeaponPartsUtil.ModifyParts(lastParts, part, UniversalConsts.InvalidIntId);

            newParts = newParts.ApplyDefaultParts(entity.weaponBasicData.ConfigId);
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = entity.ToWeaponScan();
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = newParts;
            RefreshModelWeaponParts(refreshData);
        }
示例#2
0
 public WeaponBaseAgent(Func <EntityKey> in_holdExtractor, Func <EntityKey> in_emptyExtractor,
                        EWeaponSlotType slot, GrenadeCacheHandler grenadeHandler)
 {
     weaponKeyExtractor = in_holdExtractor;
     emptyKeyExtractor  = in_emptyExtractor;
     handledSlot        = slot;
 }
示例#3
0
 public static void BindCustomizeWeaponKey(this WeaponBagContainer bagContainer, EntityKey entityKey)
 {
     for (EWeaponSlotType i = EWeaponSlotType.None; i < EWeaponSlotType.Length; i++)
     {
         bagContainer[i].Remove(entityKey);
     }
 }
示例#4
0
        public bool ReplaceWeaponToSlot(EWeaponSlotType slotType, WeaponInfo weaponInfo)
        {
            WeaponInfo lastWp;

            return(ReplaceWeaponToSlot(slotType, weaponInfo, true, out lastWp));
            //  return lastWp;
        }
示例#5
0
 public virtual void OnWeaponPickup(IPlayerWeaponProcessor controller, EWeaponSlotType slot)
 {
     if (controller.AudioController != null)
     {
         controller.AudioController.PlaySimpleAudio(EAudioUniqueId.PikcupWeapon);
     }
 }
示例#6
0
        private bool ReplaceCommonWeapon(EWeaponSlotType slotType, WeaponScanStruct orient, int bagIndex)
        {
            //  if (vertify)
            if (!processHelper.FilterVailed(orient, slotType))
            {
                return(false);
            }
            bool refreshAppearance = true;

            logger.InfoFormat("replace weapon:{0}: ", orient);
            //特殊全局性武器只取武器背包第0个索引值
            var weaponAgent = GetWeaponAgent(slotType);
            WeaponPartsRefreshStruct refreshParams = new WeaponPartsRefreshStruct();
            WeaponEntity             newEntity     = weaponAgent.ReplaceWeapon(Owner, orient, ref refreshParams);

            if (newEntity == null)
            {
                return(false);
            }
            SyncBagWeapon(slotType, newEntity.entityKey.Value);
            if (refreshAppearance)
            {
                RefreshModelWeaponParts(refreshParams);
            }
            return(true);
        }
        public override void DoAction(IEventArgs args)
        {
            FreeRuleEventArgs fr = (FreeRuleEventArgs)args;

            IGameUnit unit = GetPlayer(args);

            if (unit != null)
            {
                PlayerEntity p = ((FreeData)unit).Player;

                int index = FreeUtil.ReplaceInt(weaponKey, args);

                EWeaponSlotType currentSlot = p.GetBagLogicImp().GetCurrentWeaponSlot();

                if (index > 0)
                {
                    currentSlot = FreeWeaponUtil.GetSlotType(index);
                }

                Debug.LogFormat("remove weapon: " + index);

                p.playerAction.Logic.DropWeapon(currentSlot);

                //SimpleProto message = new SimpleProto();
                //message.Key = FreeMessageConstant.ChangeAvatar;
                //message.Ins.Add((int)currentSlot);
                //message.Ks.Add(6);
                //p.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, message);
            }
        }
        public static void WeaponToHand(PlayerEntity player, EWeaponSlotType slot)
        {
            var pos = WeaponInPackage.EndOfTheWorld;

            switch (slot)
            {
            case EWeaponSlotType.PrimeWeapon:
                pos = WeaponInPackage.PrimaryWeaponOne;
                break;

            case EWeaponSlotType.SecondaryWeapon:
                pos = WeaponInPackage.PrimaryWeaponTwo;
                break;

            case EWeaponSlotType.PistolWeapon:
                pos = WeaponInPackage.SideArm;
                break;

            case EWeaponSlotType.MeleeWeapon:
                pos = WeaponInPackage.MeleeWeapon;
                break;

            case EWeaponSlotType.ThrowingWeapon:
                pos = WeaponInPackage.ThrownWeapon;
                break;

            case EWeaponSlotType.TacticWeapon:
                pos = WeaponInPackage.TacticWeapon;
                break;

            default:
                break;
            }
            player.appearanceInterface.Appearance.MountWeaponToHand(pos);
        }
 public override void Drop(PlayerEntity player, EWeaponSlotType slot, IUserCmd cmd)
 {
     if (slot == EWeaponSlotType.ThrowingWeapon)
     {
         DoDropGrenade(player, slot, cmd);
     }
 }
示例#10
0
        public bool SetWeaponPartByPartId(EWeaponSlotType slot, int matchedPartId)
        {
            var agent = GetWeaponAgent(slot);

            if (!agent.IsValid())
            {
                return(false);
            }
            WeaponPartsStruct lastParts = agent.PartsScan;
            bool match = SingletonManager.Get <WeaponPartsConfigManager>().IsPartMatchWeapon(matchedPartId, agent.ResConfig.Id);

            if (!match)
            {
                return(false);
            }
            var attachments = WeaponPartUtil.ModifyPartItem(lastParts,
                                                            SingletonManager.Get <WeaponPartsConfigManager>().GetPartType(matchedPartId), matchedPartId);

            agent.BaseComponent.ApplyParts(attachments);
            if (slot == HeldSlotType)
            {
                RefreshHeldWeaponAttachment();
            }
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = agent.ComponentScan;
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = agent.PartsScan;
            RefreshModelWeaponParts(refreshData);
            DebugUtil.MyLog("Set Weapon part:" + refreshData, DebugUtil.DebugColor.Green);
            return(true);
        }
示例#11
0
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name ="slot"></param>
        /// <param name ="partType"></param>
        public void DeleteWeaponPart(EWeaponSlotType slot, EWeaponPartType partType)
        {
            var agent = GetWeaponAgent(slot);

            if (!agent.IsValid())
            {
                return;
            }
            WeaponPartsStruct lastParts = agent.PartsScan;
            var newParts = WeaponPartUtil.ModifyPartItem(lastParts, partType, 0);

            agent.BaseComponent.ApplyParts(newParts);
            if (slot == HeldSlotType)
            {
                RefreshHeldWeaponAttachment();
            }
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = agent.ComponentScan;
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = newParts;
            RefreshModelWeaponParts(refreshData);
            DebugUtil.MyLog("Delete Weapon part:" + refreshData, DebugUtil.DebugColor.Green);
        }
示例#12
0
 public Err_WeaponLogicErrCode OnWpDrop(EWeaponSlotType in_slot)
 {
     return(OnWpProcess(in_slot, (WeaponSlotBaseHandler controller) =>
     {
         return controller.OnDrop();
     }));
 }
示例#13
0
        public static int?GetWeaponInSlot(this PlayerEntity playerEntity, EWeaponSlotType slot)
        {
            var weaponBag = playerEntity.GetWeaponBagComponent((EWeaponBagIndex)playerEntity.bagState.CurBag);

            if (null != weaponBag)
            {
                switch (slot)
                {
                case EWeaponSlotType.PrimeWeapon:
                    return(weaponBag.PrimeWeapon);

                case EWeaponSlotType.SecondaryWeapon:
                    return(weaponBag.SecondaryWeapon);

                case EWeaponSlotType.PistolWeapon:
                    return(weaponBag.PistolWeapon);

                case EWeaponSlotType.MeleeWeapon:
                    return(weaponBag.MeleeWeapon);

                case EWeaponSlotType.ThrowingWeapon:
                    return(weaponBag.ThrowingWeapon);

                case EWeaponSlotType.TacticWeapon:
                    return(weaponBag.TacticWeapon);
                }
            }
            return(null);
        }
示例#14
0
 //TODO 保证背包索引和槽位都合法的情况下,一定有武器
 public static bool HasWeapon(this PlayerEntity playerEntity, EWeaponSlotType slot)
 {
     return(slot > EWeaponSlotType.None &&
            playerEntity.bagState.CurBag > (int)EWeaponBagIndex.None &&
            playerEntity.bagState.CurBag < (int)EWeaponBagIndex.Length &&
            slot < EWeaponSlotType.Length);
 }
 public void RemoveWeapon(EWeaponSlotType slot)
 {
     if (_weaponBagLogic.RemoveWeapon(slot))
     {
         OnInterrupt();
     }
 }
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name="slot"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool SetWeaponPart(EWeaponSlotType slot, int id)
        {
            var agent = GetWeaponAgent(slot);

            if (!agent.IsValid())
            {
                return(false);
            }
            WeaponPartsStruct lastParts = agent.BaseComponent.CreateParts();
            int  realAttachId           = WeaponUtil.GetRealAttachmentId(id, agent.ResConfig.Id);
            bool match = SingletonManager.Get <WeaponPartsConfigManager>().IsPartMatchWeapon(realAttachId, agent.ResConfig.Id);

            if (!match)
            {
                return(false);
            }
            var attachments = WeaponPartUtil.ModifyPartItem(
                agent.BaseComponent.CreateParts(),
                SingletonManager.Get <WeaponPartsConfigManager>().GetPartType(realAttachId),
                realAttachId);

            agent.BaseComponent.ApplyParts(attachments);
            if (slot == HeldSlotType)
            {
                RefreshHeldWeaponAttachment();
            }
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = agent.ComponentScan;
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = agent.BaseComponent.CreateParts();
            RefreshModelWeaponParts(refreshData);
            return(true);
        }
        public int GetReservedBullet(Entity entity, EWeaponSlotType slot)
        {
            var playerEntity = entity as PlayerEntity;
            var weaponComp   = playerEntity.GetWeaponComponentBySlot(slot);

            return(weaponComp.ReservedBullet);
        }
        /// <summary>
        /// API:parts
        /// </summary>
        /// <param name                          ="slot"></param>
        /// <param name                          ="partType"></param>
        public void DeleteWeaponPart(EWeaponSlotType slot, EWeaponPartType partType)
        {
            var agent = GetWeaponAgent(slot);

            if (!agent.IsValid())
            {
                return;
            }
            WeaponPartsStruct lastParts = agent.BaseComponent.CreateParts();
            var parts = WeaponPartUtil.ModifyPartItem(
                agent.BaseComponent.CreateParts(), partType,
                UniversalConsts.InvalidIntId);

            agent.BaseComponent.ApplyParts(parts);
            if (slot == HeldSlotType)
            {
                RefreshHeldWeaponAttachment();
            }
            var newParts = WeaponPartUtil.ModifyPartItem(lastParts, partType, UniversalConsts.InvalidIntId);

            WeaponPartUtil.CombineDefaultParts(ref newParts, agent.BaseComponent.ConfigId);
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = agent.ComponentScan;
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = newParts;
            RefreshModelWeaponParts(refreshData);
        }
示例#19
0
 public void SetReservedBullet(EWeaponSlotType slot, int count)
 {
     if (slot.IsSlotWithBullet())
     {
         ModeController.SetReservedBullet(this, slot, count);
     }
 }
示例#20
0
        public int GetReservedBullet(Entity entity, EWeaponSlotType slot)
        {
            var playerEntity = entity as PlayerEntity;
            var caliber      = GetCaliber(playerEntity, slot);

            return(GetReservedBullet(playerEntity, caliber));
        }
示例#21
0
        public bool ReplaceWeaponToSlot(EWeaponSlotType slotType, WeaponInfo weaponInfo, bool vertify = true)
        {
            WeaponInfo lastWp;

            return(ReplaceWeaponToSlot(slotType, weaponInfo, vertify, out lastWp));
            //  return lastWp;
        }
示例#22
0
        public int SetReservedBullet(Entity playerEntity, EWeaponSlotType slot, int count)
        {
            var player  = playerEntity as PlayerEntity;
            var caliber = GetCaliber(playerEntity, slot);

            return(SetReservedBullet(playerEntity, caliber, count));
        }
示例#23
0
        public bool ReplaceWeaponToSlot(EWeaponSlotType slotType, WeaponInfo weaponInfo, bool vertify, out WeaponInfo lastWp)
        {
            lastWp = WeaponInfo.Empty;
            if (vertify)
            {
                if (slotType == EWeaponSlotType.None)
                {
                    return(false);
                }
                var weaonCfg = SingletonManager.Get <WeaponConfigManager>().GetConfigById(weaponInfo.Id);
                if (weaonCfg == null)
                {
                    return(false);
                }
            }
            var errCode = _weaponBagLogic.AddWeaponToSlot(slotType, weaponInfo, out lastWp);

            if (errCode == Util.Err_WeaponLogicErrCode.Sucess)
            {
                _slotAuxiliary.OnWpStuffEnd(slotType, lastWp.Id);
                return(true);
            }
            else
            {
                throw new System.Exception("Add weapon to slot failed");
            }
            return(false);
        }
示例#24
0
        public void OnPickup(Entity playerEntity, EWeaponSlotType slot)
        {
            var player = playerEntity as PlayerEntity;

            Logger.DebugFormat("{0} OnPickup", player.entityKey.Value);
            LockPlayerBag(player);
        }
示例#25
0
        public static int Slot2Index(EWeaponSlotType slotType)
        {
            switch (slotType)
            {
            case EWeaponSlotType.None:
                return(0);

            case EWeaponSlotType.PrimeWeapon:
            case EWeaponSlotType.SecondaryWeapon:
                return(1);

            case EWeaponSlotType.PistolWeapon:
                return(2);

            case EWeaponSlotType.MeleeWeapon:
                return(3);

            case EWeaponSlotType.ThrowingWeapon:
                return(4);

            case EWeaponSlotType.TacticWeapon:
                return(7);

            default:
                Logger.ErrorFormat("slot {0} is illegal", slotType);
                return(0);
            }
        }
        public bool SetWeaponPartByPartId(EWeaponSlotType slot, int matchedPartId)
        {
            var agent = GetWeaponAgent(slot);

            if (!agent.CanApplyPart)
            {
                return(false);
            }
            WeaponPartsStruct lastParts = agent.PartsScan;
            bool match = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(agent.ConfigId).IsPartMatchWeapon(matchedPartId);

            if (!match)
            {
                return(false);
            }
            var attachments = WeaponPartUtil.ModifyPartItem(lastParts,
                                                            SingletonManager.Get <WeaponPartsConfigManager>().GetPartType(matchedPartId), matchedPartId);

            agent.BaseComponent.ApplyParts(attachments);
            if (slot == HeldSlotType && processHelper.FilterRefreshWeapon())
            {
                ApperanceRefreshABreath(HeldWeaponAgent.BreathFactor);
            }
            WeaponPartsRefreshStruct refreshData = new WeaponPartsRefreshStruct();

            refreshData.weaponInfo = agent.ComponentScan;
            refreshData.slot       = slot;
            refreshData.oldParts   = lastParts;
            refreshData.newParts   = agent.PartsScan;
            RefreshWeaponModelAndParts(refreshData);
            DebugUtil.MyLog("Set Weapon part:" + refreshData, DebugUtil.DebugColor.Green);
            return(true);
        }
示例#27
0
        public static WeaponInPackage ToWeaponInPackage(this EWeaponSlotType slot)
        {
            switch (slot)
            {
            case EWeaponSlotType.PrimeWeapon:
                return(WeaponInPackage.PrimaryWeaponOne);

            case EWeaponSlotType.SecondaryWeapon:
                return(WeaponInPackage.PrimaryWeaponTwo);

            case EWeaponSlotType.PistolWeapon:
                return(WeaponInPackage.SideArm);

            case EWeaponSlotType.MeleeWeapon:
                return(WeaponInPackage.MeleeWeapon);

            case EWeaponSlotType.ThrowingWeapon:
                return(WeaponInPackage.ThrownWeapon);

            case EWeaponSlotType.TacticWeapon:
                return(WeaponInPackage.TacticWeapon);

            default:
                return(WeaponInPackage.ThrownWeapon);
            }
        }
示例#28
0
        /// <summary>
        /// wewapon from body to hand
        /// </summary>
        public virtual Err_WeaponLogicErrCode OnSwitchIn(EWeaponSlotType from, System.Action <EWeaponSlotType, int> onSameSpeciesSwitch)
        {
            var slot = _weapon.GetSlotType();

            if (_weapon.Id < 1)
            {
                if (Logger.IsDebugEnabled)
                {
                    Logger.DebugFormat("no weapon in slot {0}", slot);
                }
                return(Err_WeaponLogicErrCode.Err_IdNotExisted);
            }

            if (slot == from)
            {
                // 如果要切换到的位置和当前位置一致不作处理
                return(Err_WeaponLogicErrCode.Err_SameWeaponPosition);
            }

            // 如果切换到的位置有枪,设置当前武器
            if (_weapon.Id > 0)
            {
                _playerWeaponActionLogic.DrawWeapon(slot);
                return(Err_WeaponLogicErrCode.Sucess);
                //     Core.Audio.GameAudioMedium.PerformOnGunSwitch(_weapon.Id);
                // _playerSoundManager.PlayOnce(XmlConfig.EPlayerSoundType.ChangeWeapon);
            }
            return(Err_WeaponLogicErrCode.Err_Default);
        }
示例#29
0
        public void DeleteWeaponPart(EWeaponSlotType slot, EWeaponPartType part)
        {
            if (slot == EWeaponSlotType.None)
            {
                return;
            }
            var weaponComp = GetWeaponComponentBySlot(slot);

            if (null == weaponComp)
            {
                Logger.ErrorFormat("error : weaponcompent in slot {0} is null", slot);
                return;
            }
            var weapon    = GetWeaponComponentBySlot(slot);
            var lastParts = weapon.GetParts();

            if (null != weaponComp)
            {
                var parts = WeaponPartsUtil.ModifyParts(
                    weaponComp.GetParts(),
                    part,
                    UniversalConsts.InvalidIntId);
                weaponComp.ApplyParts(parts);
            }

            if (slot == CurWeaponSlot)
            {
                RefreshCurrentWeaponAttachmentLogic();
            }

            var newParts = WeaponPartsUtil.ModifyParts(lastParts, part, UniversalConsts.InvalidIntId);

            newParts = newParts.ApplyDefaultParts(weapon.Id);
            RefreshWeaponPartsModel(weapon.Id, slot, lastParts, newParts);
        }
示例#30
0
        public static WeaponInPackage ToWeaponInPackage(this EWeaponSlotType slot)
        {
            switch (slot)
            {
            case EWeaponSlotType.PrimeWeapon1:
                return(WeaponInPackage.PrimaryWeaponOne);

            case EWeaponSlotType.PrimeWeapon2:
                return(WeaponInPackage.PrimaryWeaponTwo);

            case EWeaponSlotType.SubWeapon:
                return(WeaponInPackage.SideArm);

            case EWeaponSlotType.MeleeWeapon:
                return(WeaponInPackage.MeleeWeapon);

            case EWeaponSlotType.GrenadeWeapon:
                return(WeaponInPackage.ThrownWeapon);

            case EWeaponSlotType.TacticWeapon:
                return(WeaponInPackage.TacticWeapon);

            default:
                Logger.ErrorFormat("slot {0} is illegal for weapon ", slot);
                return(WeaponInPackage.ThrownWeapon);
            }
        }