Пример #1
0
 public PlayerWeaponBagData GetOverridedBagData(PlayerEntity playerEntity, PlayerWeaponBagData playerWeaponBagData)
 {
     if (!playerEntity.hasOverrideBag)
     {
         return(playerWeaponBagData);
     }
     if (playerEntity.overrideBag.TacticWeapon > 0)
     {
         if (null == _playerWeaponBagData)
         {
             _playerWeaponBagData = new PlayerWeaponBagData();
         }
         playerWeaponBagData.CopyTo(_playerWeaponBagData);
         bool replace = false;
         foreach (var weapon in _playerWeaponBagData.weaponList)
         {
             var slot = PlayerWeaponBagData.Index2Slot(weapon.Index);
             if (slot == Core.EWeaponSlotType.TacticWeapon)
             {
                 weapon.WeaponTplId = playerEntity.overrideBag.TacticWeapon;
                 replace            = true;
             }
         }
         if (!replace)
         {
             _playerWeaponBagData.weaponList.Add(new PlayerWeaponData
             {
                 Index       = PlayerWeaponBagData.Slot2Index(Core.EWeaponSlotType.TacticWeapon),
                 WeaponTplId = playerEntity.overrideBag.TacticWeapon,
             });
         }
         return(_playerWeaponBagData);
     }
     return(playerWeaponBagData);
 }
Пример #2
0
            public PlayerWeaponBagData CombineOverridedBagData(IPlayerWeaponSharedGetter getter, PlayerWeaponBagData playerWeaponBagData)
            {
                playerWeaponBagData.CopyTo(_playerWeaponBagData);
                if (getter.OverrideBagTactic < 1)
                {
                    return(_playerWeaponBagData);
                }
                bool replace = false;

                foreach (var weapon in playerWeaponBagData.weaponList)
                {
                    var slot = PlayerWeaponBagData.Index2Slot(weapon.Index);
                    if (slot == EWeaponSlotType.TacticWeapon)
                    {
                        weapon.WeaponTplId = getter.OverrideBagTactic;
                        replace            = true;
                    }
                }
                if (!replace)
                {
                    _playerWeaponBagData.weaponList.Add(new PlayerWeaponData
                    {
                        Index       = PlayerWeaponBagData.Slot2Index(EWeaponSlotType.TacticWeapon),
                        WeaponTplId = getter.OverrideBagTactic,
                    });
                }
                return(_playerWeaponBagData);
            }
Пример #3
0
        public void SwitchBag(int index)
        {
            if (SwitchBagByReservedType(index))
            {
                return;
            }

            var tarBag = FindWeaponBagDataBySlot(index);

            if (tarBag == null)
            {
                return;
            }
            var removedSlotList = new Byte[(int)EWeaponSlotType.Length];

            DestroyWeapon(EWeaponSlotType.ThrowingWeapon, 0);
            RefreshWeaponAppearance(EWeaponSlotType.ThrowingWeapon);
            GrenadeHandler.ClearCache();
            foreach (var weapon in tarBag.weaponList)
            {
                var slot            = PlayerWeaponBagData.Index2Slot(weapon.Index);
                var weaponAllConfig = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(weapon.WeaponTplId);
                if (slot != EWeaponSlotType.ThrowingWeapon && slot != EWeaponSlotType.TacticWeapon)
                {
                    var orient = WeaponUtil.CreateScan(weapon);
                    orient.Bullet         = weaponAllConfig.PropertyCfg.Bullet;
                    orient.ReservedBullet = weaponAllConfig.PropertyCfg.Bulletmax;
                    if (orient.Magazine > 0)
                    {
                        orient.Bullet += SingletonManager.Get <WeaponPartsConfigManager>().GetConfigById(orient.Magazine).Bullet;
                    }
                    ReplaceWeaponToSlot(slot, 0, orient);
                }
                else if (slot == EWeaponSlotType.ThrowingWeapon)
                {
                    GrenadeHandler.AddCache(weapon.WeaponTplId);
                }
                removedSlotList[(int)slot] = 1;
            }

            removedSlotList[(int)EWeaponSlotType.TacticWeapon]   = 1;
            removedSlotList[(int)EWeaponSlotType.ThrowingWeapon] = 1;
            for (int i = 1; i < removedSlotList.Length; i++)
            {
                if (removedSlotList[i] == 0)
                {
                    DestroyWeapon((EWeaponSlotType)i, 0);
                }
            }

            EWeaponSlotType newSlot = PollGetLastSlotType();

            TryHoldGrenade(true, false);
            TryArmWeaponImmediately(newSlot);
        }
Пример #4
0
        private void GenerateBagWeaponByIndex(PlayerWeaponBagData srcBagData, IPlayerWeaponProcessor controller, List <int> reservedSubType)
        {
            var removedList = new List <EWeaponSlotType>();

            for (EWeaponSlotType j = EWeaponSlotType.None + 1; j < EWeaponSlotType.Length; j++)
            {
                removedList.Add(j);
            }
            controller.GrenadeHandler.ClearCache();
            foreach (PlayerWeaponData weapon in srcBagData.weaponList)
            {
                Logger.InfoFormat("[[[[[ServerInitialize data]]]]] BagIndex:{0}|In:{1}", srcBagData.BagIndex, weapon.ToString());
                var  weaponAllConfig = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(weapon.WeaponTplId);
                bool needReserved    = true;
                if (null != reservedSubType && reservedSubType.Count != 0)
                {
                    if (weaponAllConfig.NewWeaponCfg.Type == (int)EWeaponType_Config.ThrowWeapon)
                    {
                        needReserved = reservedSubType.Contains((int)EWeaponSubType.Throw);
                    }
                    else
                    {
                        needReserved = reservedSubType.Contains(weaponAllConfig.NewWeaponCfg.SubType);
                    }
                }
                if (!needReserved)
                {
                    continue;
                }

                var slot = PlayerWeaponBagData.Index2Slot(weapon.Index);

                var weaponType = (EWeaponType_Config)weaponAllConfig.NewWeaponCfg.Type;
                if (weaponType != EWeaponType_Config.ThrowWeapon)
                {
                    var orient = WeaponUtil.CreateScan(weapon);
                    orient.Bullet         = weaponAllConfig.PropertyCfg.Bullet;
                    orient.ReservedBullet = weaponAllConfig.PropertyCfg.Bulletmax;
                    if (orient.Magazine > 0)
                    {
                        orient.Bullet += SingletonManager.Get <WeaponPartsConfigManager>().GetConfigById(orient.Magazine).Bullet;
                    }
                    controller.ReplaceWeaponToSlot(slot, srcBagData.BagIndex, orient);
                }
                else
                {
                    controller.GrenadeHandler.AddCache(weapon.WeaponTplId);
                }
                removedList.Remove(slot);
            }
            foreach (var i in removedList)
            {
                controller.DestroyWeapon(i, 0);
            }
        }
Пример #5
0
 private void GenerateGrenadeList(List <PlayerWeaponBagData> sortedList, IPlayerWeaponProcessor processor)
 {
     processor.GrenadeHandler.ClearCache();
     foreach (var value in sortedList)
     {
         foreach (var weapon in value.weaponList)
         {
             var slot = PlayerWeaponBagData.Index2Slot(weapon.Index);
             if (slot == EWeaponSlotType.ThrowingWeapon)
             {
                 processor.GrenadeHandler.AddCache(weapon.WeaponTplId);
             }
         }
     }
 }
Пример #6
0
        private List <PlayerWeaponData> CollectGrenadeList(List <PlayerWeaponBagData> sortedList)
        {
            List <PlayerWeaponData> list = new List <PlayerWeaponData>();

            foreach (var value in sortedList)
            {
                foreach (var weapon in value.weaponList)
                {
                    var slot = PlayerWeaponBagData.Index2Slot(weapon.Index);
                    if (slot == EWeaponSlotType.ThrowingWeapon)
                    {
                        list.Add(weapon);
                    }
                }
            }
            //       DebugUtil.MyLog(list.ToString(), DebugUtil.DebugColor.Blue);
            return(list);
        }
Пример #7
0
        private void GenerateInitialWeapons(PlayerWeaponBagData srcBagData, IPlayerWeaponProcessor controller)
        {
            PlayerWeaponBagData bagData = BagTaticsCache.CombineOverridedBagData(controller, srcBagData);
            var helper = controller.GrenadeHelper;

            helper.ClearCache();

            foreach (var weapon in bagData.weaponList)
            {
                DebugUtil.MyLog("BagIndex:{0}|In:{1}", DebugUtil.DebugColor.Blue, bagData.BagIndex, weapon.ToString());

                var slot = PlayerWeaponBagData.Index2Slot(weapon.Index);

                var weaponAllConfig = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(weapon.WeaponTplId);
                var weaponType      = (EWeaponType_Config)weaponAllConfig.NewWeaponCfg.Type;
                if (weaponType != EWeaponType_Config.ThrowWeapon)
                {
                    var orient = WeaponUtil.CreateScan(weapon);
                    orient.Bullet         = weaponAllConfig.PropertyCfg.Bullet;
                    orient.ReservedBullet = weaponAllConfig.PropertyCfg.Bulletmax;
                    if (orient.Magazine > 0)
                    {
                        orient.Bullet += SingletonManager.Get <WeaponPartsConfigManager>().GetConfigById(orient.Magazine).Bullet;
                    }
                    orient.ClipSize = orient.Bullet;
                    controller.ReplaceWeaponToSlot(slot, srcBagData.BagIndex, orient);
                    //if(isdefaultBag)
                    //    controller.PickUpWeapon(weaponInfo);
                    //else
                    //    controller.ReplaceWeaponToSlot(slot)
                }
                else
                {
                    controller.GrenadeHelper.AddCache(weapon.WeaponTplId);
                }
            }
        }
        private void MountWeaponAndFillBullet(PlayerEntity playerEntity, PlayerWeaponBagData srcBagData)
        {
            if (null == playerEntity)
            {
                Logger.Error("PlayerEntity is null");
                return;
            }
            var bagData = _overrideWeaponController.GetOverridedBagData(playerEntity, srcBagData);

            _removeSlotList.Clear();
            for (var slot = EWeaponSlotType.None + 1; slot < EWeaponSlotType.Length; slot++)
            {
                _removeSlotList.AddLast(slot);
            }
            playerEntity.grenadeInventoryHolder.Inventory.Recycle();
            var  firstSlot      = EWeaponSlotType.Length;
            bool grenadeMounted = false;

            if (null != bagData)
            {
                foreach (var weapon in bagData.weaponList)
                {
                    var slot = PlayerWeaponBagData.Index2Slot(weapon.Index);
                    _removeSlotList.Remove(slot);
                    if (slot < firstSlot)
                    {
                        firstSlot = slot;
                    }
                    var weaponType = _weaponConfigManager.GetWeaponType(weapon.WeaponTplId);
                    var weaponId   = weapon.WeaponTplId;
                    var weaponInfo = weapon.ToWeaponInfo();

                    weaponInfo.Bullet         = _weaponPropertyConfigManager.GetBullet(weaponId);
                    weaponInfo.ReservedBullet = _weaponPropertyConfigManager.GetBulletMax(weaponId);

                    if (weaponType == EWeaponType.ThrowWeapon)
                    {
                        if (!grenadeMounted)
                        {
                            playerEntity.playerAction.Logic.ReplaceWeaponToSlot(slot, weaponInfo);
                            grenadeMounted = true;
                        }
                        else
                        {
                            playerEntity.grenadeInventoryHolder.Inventory.AddCache(weaponInfo.Id);
                        }
                    }
                    else
                    {
                        playerEntity.playerAction.Logic.ReplaceWeaponToSlot(slot, weaponInfo);
                    }
                }
                playerEntity.weaponState.BagIndex = bagData.BagIndex;
            }
            if (firstSlot < EWeaponSlotType.Length)
            {
                playerEntity.playerAction.Logic.TryMountWeapon(firstSlot);
            }
            foreach (var slot in _removeSlotList)
            {
                playerEntity.playerAction.Logic.RemoveWeapon(slot);
            }
        }
        public bool SwitchBagByReservedType(int index)
        {
            if (null == RelatedServerUpdate.ReservedWeaponSubType || RelatedServerUpdate.ReservedWeaponSubType.Count == 0)
            {
                return(false);
            }

            var tarBag = FindWeaponBagDataBySlot(index);

            if (tarBag == null)
            {
                return(true);
            }

            DestroyWeapon(EWeaponSlotType.ThrowingWeapon, 0);
            RefreshWeaponAppearance(EWeaponSlotType.ThrowingWeapon);
            GrenadeHandler.ClearCache();
            RelatedGamePlay.ArmorLv  = RelatedGamePlay.CurArmor = RelatedGamePlay.MaxArmor = 0;
            RelatedGamePlay.HelmetLv = RelatedGamePlay.CurHelmet = RelatedGamePlay.MaxHelmet = 0;

            var removedSlotList = new Byte[(int)EWeaponSlotType.Length];

            foreach (var weapon in tarBag.weaponList)
            {
                bool needReserved    = false;
                var  weaponAllConfig = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(weapon.WeaponTplId);

                if (weaponAllConfig.NewWeaponCfg.Type == (int)EWeaponType_Config.ThrowWeapon)
                {
                    needReserved = RelatedServerUpdate.ReservedWeaponSubType.Contains((int)EWeaponSubType.Throw);
                }
                else
                {
                    needReserved = RelatedServerUpdate.ReservedWeaponSubType.Contains(weaponAllConfig.NewWeaponCfg.SubType);
                }

                if (!needReserved)
                {
                    continue;
                }

                if (weaponAllConfig.NewWeaponCfg.Type == (int)EWeaponType_Config.Armor)
                {
                    RelatedGamePlay.ArmorLv  = weaponAllConfig.NewWeaponCfg.Id;
                    RelatedGamePlay.MaxArmor = RelatedGamePlay.CurArmor = weaponAllConfig.NewWeaponCfg.Durable;
                    continue;
                }

                if (weaponAllConfig.NewWeaponCfg.Type == (int)EWeaponType_Config.Helmet)
                {
                    RelatedGamePlay.HelmetLv  = weaponAllConfig.NewWeaponCfg.Id;
                    RelatedGamePlay.MaxHelmet = RelatedGamePlay.CurHelmet = weaponAllConfig.NewWeaponCfg.Durable;
                    continue;
                }

                var slot = PlayerWeaponBagData.Index2Slot(weapon.Index);
                if (slot != EWeaponSlotType.ThrowingWeapon && slot != EWeaponSlotType.TacticWeapon)
                {
                    var orient = WeaponUtil.CreateScan(weapon);
                    orient.Bullet         = weaponAllConfig.PropertyCfg.Bullet;
                    orient.ReservedBullet = weaponAllConfig.PropertyCfg.Bulletmax;
                    if (orient.Magazine > 0)
                    {
                        orient.Bullet += SingletonManager.Get <WeaponPartsConfigManager>().GetConfigById(orient.Magazine)
                                         .Bullet;
                    }

                    ReplaceWeaponToSlot(slot, 0, orient);
                }
                else if (slot == EWeaponSlotType.ThrowingWeapon)
                {
                    GrenadeHandler.AddCache(weapon.WeaponTplId);
                }

                removedSlotList[(int)slot] = 1;
            }

            for (int i = 1; i < removedSlotList.Length; i++)
            {
                if (removedSlotList[i] == 0)
                {
                    DestroyWeapon((EWeaponSlotType)i, 0);
                }
            }

            EWeaponSlotType newSlot = PollGetLastSlotType();

            TryHoldGrenade(true, false);
            TryArmWeaponImmediately(newSlot);
            return(true);
        }