Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="orient"></param>
        /// <param name="pickupSuccess"></param>
        /// <param name="arm"></param>
        /// <returns>generate scene object</returns>
        public bool PickUpWeapon(WeaponScanStruct orient, ref bool pickupSuccess, bool arm = true)
        {
            var slotType = processHelper.GetMatchedSlotType(orient.ConfigId);

            if (!processHelper.FilterVailed(orient, slotType))
            {
                return(false);
            }
            if (!processHelper.FilterPickup(slotType))
            {
                return(false);
            }
            if (ReplaceWeaponToSlot(slotType, orient))
            {
                if (arm)
                {
                    TryArmWeaponImmediately(slotType);
                }
                onWeaponPickEvt(this, slotType);
                pickupSuccess = true;
                return(slotType != EWeaponSlotType.ThrowingWeapon);
            }

            return(false);
        }
Пример #2
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);
        }
Пример #3
0
        public static WeaponScanStruct CreateScan(PlayerWeaponData weaponData)
        {
            WeaponScanStruct val = new WeaponScanStruct();

            val.ConfigId = weaponData.WeaponTplId;
            if (weaponData.WeaponAvatarTplId == 0)
            {
                var config = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(weaponData.WeaponTplId);
                val.AvatarId = config.AvatorId;
            }
            else
            {
                val.AvatarId = weaponData.WeaponTplId;
            }
            val.UpperRail = weaponData.UpperRail;
            val.LowerRail = weaponData.LowerRail;
            val.Magazine  = weaponData.Magazine;
            val.Muzzle    = weaponData.Muzzle;
            val.Stock     = weaponData.Stock;
            val.SideRail  = weaponData.SideRail;
            val.Bore      = weaponData.Bore;
            val.Feed      = weaponData.Feed;
            val.Interlock = weaponData.Interlock;
            val.Trigger   = weaponData.Trigger;
            val.Brake     = weaponData.Brake;
            return(val);
        }
Пример #4
0
        public bool PickUpWeapon(WeaponScanStruct orient, ref bool pickupSuccess, bool arm = true)
        {
            var slotType = weaponProcessor.GetMatchedSlot(orient.ConfigId);

            if (!weaponProcessor.FilterVailed(orient, slotType))
            {
                return(false);
            }
            if (!weaponProcessor.FilterPickup(slotType))
            {
                return(false);
            }
            if (ReplaceWeaponToSlot(slotType, orient))
            {
                if (arm)
                {
                    TryArmWeapon(slotType);
                }
                if (onWeaponPickEvt != null)
                {
                    onWeaponPickEvt(this, slotType);
                }
                pickupSuccess = slotType != EWeaponSlotType.ThrowingWeapon;
                return(pickupSuccess);
            }
            return(false);
        }
Пример #5
0
        public static WeaponScanStruct CreateScan()
        {
            WeaponScanStruct val = new WeaponScanStruct();

            val.ConfigId = EmptyHandId;
            return(val);
        }
Пример #6
0
        //public static WeaponScanStruct CreateScan(Components.SceneObject.WeaponObjectComponent weaponObject)
        //{
        //    WeaponScanStruct val = new WeaponScanStruct();
        //    val.Assign(weaponObject.ConfigId);
        //    val.AvatarId = weaponObject.WeaponAvatarId;
        //    val.UpperRail = weaponObject.UpperRail;
        //    val.LowerRail = weaponObject.LowerRail;
        //    val.Magazine = weaponObject.Magazine;
        //    val.Muzzle = weaponObject.Muzzle;
        //    val.Stock = weaponObject.Stock;
        //    return val;
        //}

        public static WeaponScanStruct CreateScan(int configId)
        {
            WeaponScanStruct val = new WeaponScanStruct();

            val.ConfigId = configId;
            return(val);
        }
 private void DoDrawArmWeaponWithActionFromEmpty(WeaponScanStruct destWeapon, int lastWeaponId,
                                                 WeaponDrawAppearanceStruct appearanceStruct)
 {
     WeaponToHand(destWeapon.ConfigId, lastWeaponId, appearanceStruct.targetSlot, appearanceStruct.armOnLeft);
     DoArmFinished(destWeapon, appearanceStruct.targetSlot);
     RelatedCharState.Select(RelatedAppearence.RemountP3WeaponOnRightHand, appearanceStruct.drawParam);
 }
Пример #8
0
        public static WeaponScanStruct SetWeaponInfoAttachment(WeaponScanStruct weaponInfo, EWeaponPartType type, int id)
        {
            switch (type)
            {
            case EWeaponPartType.LowerRail:
                weaponInfo.LowerRail = id;
                break;

            case EWeaponPartType.UpperRail:
                weaponInfo.UpperRail = id;
                break;

            case EWeaponPartType.Muzzle:
                weaponInfo.Muzzle = id;
                break;

            case EWeaponPartType.Magazine:
                weaponInfo.Magazine = id;
                break;

            case EWeaponPartType.Stock:
                weaponInfo.Stock = id;
                break;
            }

            return(weaponInfo);
        }
Пример #9
0
        public static WeaponScanStruct CreateScan(WeaponEntity entity)
        {
            WeaponScanStruct val = new WeaponScanStruct();

            val.ConfigId = entity.weaponBasicData.ConfigId;
            return(val);
        }
Пример #10
0
 public bool ReplaceWeaponToSlot(EWeaponSlotType slotType, int bagIndex, WeaponScanStruct orient)
 {
     if (TryHoldGrenade(orient.ConfigId))
     {
         return(true);
     }
     return(ReplaceCommonWeapon(slotType, orient, bagIndex));
 }
Пример #11
0
        public static WeaponScanStruct CreateScan(int configId, System.Action <WeaponScanStruct> initFunc)
        {
            WeaponScanStruct val = new WeaponScanStruct();

            val.ConfigId = configId;
            initFunc(val);
            return(val);
        }
Пример #12
0
 /// <summary>
 ///通用填充武器逻辑
 /// </summary>
 /// <param name="slotType"></param>
 /// <param name="orient"></param>
 /// <returns></returns>
 public bool ReplaceWeaponToSlot(EWeaponSlotType slotType, WeaponScanStruct orient)
 {
     if (TryHoldGrenade(orient.ConfigId))
     {
         return(true);
     }
     return(ReplaceCommonWeapon(slotType, orient, HeldBagPointer));
 }
 /// 没动作,直接刷新装备
 private void DoDrawArmWeaponWithoutAction(WeaponScanStruct destWeapon, int lastWeaponId,
                                           WeaponDrawAppearanceStruct appearanceStruct)
 {
     WeaponToHand(destWeapon.ConfigId, lastWeaponId, appearanceStruct.targetSlot, appearanceStruct.armOnLeft);
     OnDrawWeaponCallback(destWeapon, appearanceStruct.targetSlot);
     // DoArmFinished(destWeapon, appearanceStruct.targetSlot);
     //  RelatedAppearence.RemountP3WeaponOnRightHand();
 }
Пример #14
0
        public void UnArmHeldWeapon(Action onfinish)
        {
            WeaponScanStruct weaponInfo = HeldWeaponAgent.ComponentScan;

            AppearanceSpecific();
            float holsterParam = WeaponUtil.GetHolsterParam(HeldSlotType);

            RelatedStateInterface.CharacterUnmount(() => OnUnArmWeaponCallback(weaponInfo.ConfigId, onfinish), holsterParam);
        }
 /// 有动作,从旧装备上画新装备
 private void DoDrawArmWeaponWithActionFromOtherWeapon(WeaponScanStruct destWeapon, int lastWeaponId,
                                                       WeaponDrawAppearanceStruct appearanceStruct)
 {
     RelatedCharState.SwitchWeapon(() =>
     {
         WeaponToHand(destWeapon.ConfigId, lastWeaponId, appearanceStruct.targetSlot,
                      CompareUtility.IsApproximatelyEqual(appearanceStruct.drawParam,
                                                          AnimatorParametersHash.Instance.DrawLeftValue));
         onWeaponSwitchEvt(this, destWeapon.ConfigId, EInOrOff.Off);
     }, () => OnDrawWeaponCallback(destWeapon, appearanceStruct.targetSlot), appearanceStruct.switchParam);
 }
        public virtual IEntity CreateSceneWeaponObjectEntity(WeaponScanStruct weaponScan, Vector3 position)
        {
            var entity = _sceneObjectContext.CreateEntity();

            entity.AddEntityKey(new EntityKey(_equipGenerator.GetNextEntityId(), (short)EEntityType.SceneObject));
            entity.isFlagSyncNonSelf = true;
            entity.AddPosition(position);
            entity.AddWeaponObject();
            entity.weaponObject.GameCopyFrom(weaponScan);
            entity.AddFlagImmutability(_currentTime.CurrentTime);
            return(entity);
        }
Пример #17
0
 //用于weaponEntity创建
 public static void SyncSelf(this WeaponBasicDataComponent weaponComp, WeaponScanStruct weaponInfo)
 {
     weaponComp.ConfigId       = weaponInfo.ConfigId;
     weaponComp.WeaponAvatarId = weaponInfo.AvatarId;
     weaponComp.Bullet         = weaponInfo.Bullet;
     weaponComp.ReservedBullet = weaponInfo.ReservedBullet;
     weaponComp.UpperRail      = weaponInfo.UpperRail;
     weaponComp.LowerRail      = weaponInfo.LowerRail;
     weaponComp.Magazine       = weaponInfo.Magazine;
     weaponComp.Muzzle         = weaponInfo.Muzzle;
     weaponComp.Stock          = weaponInfo.Stock;
 }
Пример #18
0
 internal bool FilterVailed(WeaponScanStruct orient, EWeaponSlotType slot)
 {
     if (slot == EWeaponSlotType.None)
     {
         return(false);
     }
     if (orient.IsUnSafeOrEmpty())
     {
         return(false);
     }
     return(Getter.ModeController.IsSlotValid(slot));
 }
Пример #19
0
 /// 有动作,从旧装备上画新装备
 private void DoDrawArmWeaponWithActionFromOtherWeapon(WeaponScanStruct destWeapon, int lastWeaponId,
                                                       WeaponDrawAppearanceStruct appearanceStruct)
 {
     RelatedCharState.SwitchWeapon(
         () =>
     {
         WeaponToHand(destWeapon.ConfigId, lastWeaponId, appearanceStruct.targetSlot,
                      appearanceStruct.armOnLeft);
         onWeaponSwitchEvt(this, destWeapon.ConfigId, EInOrOff.Off);
     },
         () => OnDrawWeaponCallback(destWeapon, appearanceStruct.targetSlot), appearanceStruct.switchParam);
 }
Пример #20
0
        public static WeaponScanStruct CreateScan(PlayerWeaponData weaponData)
        {
            WeaponScanStruct val = new WeaponScanStruct();

            val.ConfigId  = weaponData.WeaponTplId;
            val.AvatarId  = weaponData.WeaponTplId;
            val.UpperRail = weaponData.UpperRail;
            val.LowerRail = weaponData.LowerRail;
            val.Magazine  = weaponData.Magazine;
            val.Muzzle    = weaponData.Muzzle;
            val.Stock     = weaponData.Stock;
            return(val);
        }
Пример #21
0
 /// <summary>
 /// sync WeaponBasicDataComponent from WeaponScanStruct
 /// </summary>
 /// <param name="weaponComp"></param>
 /// <param name="weaponInfo"></param>
 public static void SyncSelf(this WeaponBasicDataComponent weaponComp, WeaponScanStruct weaponInfo)
 {
     weaponComp.ConfigId       = weaponInfo.ConfigId;
     weaponComp.WeaponAvatarId = weaponInfo.AvatarId;
     DebugUtil.MyLog("Bullet Sync" + weaponInfo.Bullet, DebugUtil.DebugColor.Black);
     weaponComp.Bullet         = weaponInfo.Bullet;
     weaponComp.ReservedBullet = weaponInfo.ReservedBullet;
     weaponComp.UpperRail      = weaponInfo.UpperRail;
     weaponComp.LowerRail      = weaponInfo.LowerRail;
     weaponComp.Magazine       = weaponInfo.Magazine;
     weaponComp.Muzzle         = weaponInfo.Muzzle;
     weaponComp.Stock          = weaponInfo.Stock;
     weaponComp.ClipSize       = weaponInfo.ClipSize;
 }
Пример #22
0
        public static WeaponPartsStruct CreateParts(this WeaponScanStruct info)
        {
            var result = new WeaponPartsStruct
            {
                LowerRail = info.LowerRail,
                UpperRail = info.UpperRail,
                Magazine  = info.Magazine,
                Muzzle    = info.Muzzle,
                Stock     = info.Stock,
            };

            CombineDefaultParts(ref result, info.ConfigId);
            return(result);
        }
Пример #23
0
        public static WeaponScanStruct Explicit(PlayerWeaponData weaponData)
        {
            WeaponScanStruct scan = new WeaponScanStruct();

            scan.ConfigId = weaponData.WeaponTplId;

            scan.AvatarId  = weaponData.WeaponAvatarTplId;
            scan.Muzzle    = weaponData.Muzzle;
            scan.Stock     = weaponData.Stock;
            scan.Magazine  = weaponData.Magazine;
            scan.UpperRail = weaponData.UpperRail;
            scan.LowerRail = weaponData.LowerRail;
            return(scan);
        }
        public virtual IEntity CreateDropSceneWeaponObjectEntity(WeaponScanStruct weaponScan, Vector3 position, int lifeTime)
        {
            var entity = CreateSceneWeaponObjectEntity(weaponScan, position);

            if (lifeTime > 0)
            {
                var sceneObjectEntity = entity as SceneObjectEntity;
                if (null != sceneObjectEntity)
                {
                    sceneObjectEntity.AddLifeTime(DateTime.Now, lifeTime);
                }
            }
            return(entity);
        }
Пример #25
0
        public static void SyncSelf(this WeaponScanStruct weaponScan, WeaponEntity weaponEntity)
        {
            var weaponBasicData = weaponEntity.weaponBasicData;

            weaponScan.Assign(weaponEntity.entityKey.Value, weaponBasicData.ConfigId);
            weaponScan.AvatarId       = weaponBasicData.WeaponAvatarId;
            weaponScan.UpperRail      = weaponBasicData.UpperRail;
            weaponScan.LowerRail      = weaponBasicData.LowerRail;
            weaponScan.Magazine       = weaponBasicData.Magazine;
            weaponScan.Muzzle         = weaponBasicData.Muzzle;
            weaponScan.Bullet         = weaponBasicData.Bullet;
            weaponScan.Stock          = weaponBasicData.Stock;
            weaponScan.ReservedBullet = weaponBasicData.ReservedBullet;
            weaponScan.FireMode       = (EFireMode)weaponBasicData.FireMode;
            weaponScan.PullBolt       = weaponBasicData.PullBolt;
        }
        private void DoArmFinished(WeaponScanStruct weapon, EWeaponSlotType slot)
        {
            //TODO:
            logger.InfoFormat("DoArmFinished {0}", HeldSlotType);
            SetHeldSlotType(slot);



            if (weapon.Bullet <= 0)
            {
                if (SharedConfig.CurrentGameMode == EGameMode.Normal)
                {
                    //TODO 判断弹药数量是否足够,如果弹药不足,弹提示框
                    RelatedCharState.ReloadEmpty(() => { });
                }
            }
        }
Пример #27
0
        public virtual IEntity CreateDropSceneWeaponObjectEntity(WeaponScanStruct weaponScan, Vector3 position, int lifeTime)
        {
            var entity = CreateSceneWeaponObjectEntity(weaponScan, position);

            if (lifeTime > 0)
            {
                var sceneObjectEntity = entity as SceneObjectEntity;
                if (null != sceneObjectEntity)
                {
                    sceneObjectEntity.AddLifeTime(DateTime.Now, lifeTime);
                }
            }
            if (WeaponUtil.IsC4p(weaponScan.ConfigId))
            {
                (entity as SceneObjectEntity).AddCastFlag((int)EPlayerCastState.C4Pickable);
            }
            return(entity);
        }
Пример #28
0
        /// <summary>
        /// 手雷武器替换操作:当前ConfigId必须已存在于库存,将手雷ENity替换 为当前configId
        /// </summary>
        /// <param name="Owner"></param>
        /// <param name="orient"></param>
        /// <param name="refreshParams"></param>
        /// <returns></returns>
        public override WeaponEntity ReplaceWeapon(EntityKey Owner, WeaponScanStruct orient, ref WeaponPartsRefreshStruct refreshParams)
        {
            if (bagCacheHelper.ShowCount(orient.ConfigId) == 0)
            {
                return(null);
            }
            refreshParams.lastWeaponKey = WeaponKey;
            ReleaseWeapon();
            bagCacheHelper.SetCurr(orient.ConfigId);
            WeaponPartsStruct parts = orient.CreateParts();

            refreshParams.weaponInfo   = orient;
            refreshParams.slot         = handledSlot;
            refreshParams.oldParts     = new WeaponPartsStruct();
            refreshParams.newParts     = parts;
            refreshParams.armInPackage = true;
            return(bagCacheHelper.GetGrenadeEntity());
        }
Пример #29
0
 /// <summary>
 /// sync WeaponBasicDataComponent from WeaponScanStruct
 /// </summary>
 /// <param name="weaponComp"></param>
 /// <param name="weaponInfo"></param>
 public static void SyncSelf(this WeaponBasicDataComponent weaponComp, WeaponScanStruct weaponInfo)
 {
     weaponComp.ConfigId       = weaponInfo.ConfigId;
     weaponComp.WeaponAvatarId = weaponInfo.AvatarId;
     weaponComp.Bullet         = weaponInfo.Bullet;
     weaponComp.ReservedBullet = weaponInfo.ReservedBullet;
     weaponComp.UpperRail      = weaponInfo.UpperRail;
     weaponComp.LowerRail      = weaponInfo.LowerRail;
     weaponComp.Magazine       = weaponInfo.Magazine;
     weaponComp.Muzzle         = weaponInfo.Muzzle;
     weaponComp.Stock          = weaponInfo.Stock;
     weaponComp.SideRail       = weaponInfo.SideRail;
     weaponComp.Bore           = weaponInfo.Bore;
     weaponComp.Feed           = weaponInfo.Feed;
     weaponComp.Brake          = weaponInfo.Brake;
     weaponComp.Interlock      = weaponInfo.Interlock;
     weaponComp.Trigger        = weaponInfo.Trigger;
 }
Пример #30
0
 public void GameCopyFrom(WeaponScanStruct remote)
 {
     ConfigId       = remote.ConfigId;
     WeaponAvatarId = remote.AvatarId;
     UpperRail      = remote.UpperRail;
     LowerRail      = remote.LowerRail;
     SideRail       = remote.SideRail;
     Stock          = remote.Stock;
     Muzzle         = remote.Muzzle;
     Magazine       = remote.Magazine;
     Bullet         = remote.Bullet;
     ReservedBullet = remote.ReservedBullet;
     Bore           = remote.Bore;
     Feed           = remote.Feed;
     Trigger        = remote.Trigger;
     Interlock      = remote.Interlock;
     Brake          = remote.Brake;
 }