예제 #1
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);
            }
        }
예제 #2
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);
                }
            }
        }