Beispiel #1
0
        private static string putOnPart(FreeData fd, int weaponType, FreeItemInfo info, string toInv = "", ServerRoom room = null)
        {
            WeaponResConfigItem weapon = GetWeapon(fd, weaponType);

            if (weapon != null)
            {
                foreach (EWeaponPartType part in SingletonManager.Get <WeaponPartsConfigManager>().GetAvaliablePartTypes(weapon.Id))
                {
                    int p        = FreeWeaponUtil.GetWeaponPart(part);
                    int detailId = WeaponUtil.GetRealAttachmentId(info.id, weapon.Id);
                    if (SingletonManager.Get <WeaponPartsConfigManager>().IsPartMatchWeapon(detailId, weapon.Id))
                    {
                        if ("p" + p == info.subType)
                        {
                            string        inv = "w" + weaponType + p;
                            ItemInventory ii  = fd.freeInventory.GetInventoryManager().GetInventory(inv);
                            if (ii != null && (ii.posList.Count == 0 ||
                                               toInv.StartsWith("w" + weaponType)))
                            {
                                if (ii.posList.Count > 0)
                                {
                                    DropPart(inv, fd, room);
                                }
                                return(inv);
                            }
                        }
                    }
                }
            }

            return(null);
        }
Beispiel #2
0
        public static TipShowData GetTip(string key)
        {
            TipData td = chickenDic[key];

            if (td.cat == 2 && key.Contains(","))
            {
                WeaponResConfigItem weapon = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(td.id);

                if (weapon.Type == (int)EWeaponType_Config.PrimeWeapon)
                {
                    if (HasTip("w1"))
                    {
                        return(new TipShowData(td.cat, td.id, chickenDic["w1"].id, 1));
                    }
                    else if (HasTip("w2"))
                    {
                        return(new TipShowData(td.cat, td.id, chickenDic["w2"].id, 1));
                    }
                }
                else if (weapon.Type == (int)EWeaponType_Config.SubWeapon)
                {
                    if (HasTip("w3"))
                    {
                        return(new TipShowData(td.cat, td.id, chickenDic["w3"].id, 1));
                    }
                }
            }

            return(new TipShowData(td.cat, td.id, 0, td.count));
        }
Beispiel #3
0
        public static ThrowingEntity CreateThrowingEntity(
            ThrowingContext throwingContext,
            IEntityIdGenerator entityIdGenerator,
            PlayerWeaponController controller,
            int serverTime, Vector3 dir, float initVel,
            WeaponResConfigItem newWeaponConfig,
            ThrowingConfig throwingConfig)
        {
            int throwingEntityId = entityIdGenerator.GetNextEntityId();

            var     emitPost       = PlayerEntityUtility.GetThrowingEmitPosition(controller);
            Vector3 velocity       = dir * initVel;
            var     throwingEntity = throwingContext.CreateEntity();

            throwingEntity.AddEntityKey(new EntityKey(throwingEntityId, (int)EEntityType.Throwing));

            throwingEntity.AddThrowingData(
                velocity,
                false,
                false,
                0,
                serverTime,
                false,
                initVel,
                throwingConfig,
                newWeaponConfig.SubType
                );

            throwingEntity.AddPosition();
            throwingEntity.position.Value = emitPost;
            throwingEntity.AddOwnerId(controller.Owner);
            throwingEntity.isFlagSyncNonSelf = true;
            throwingEntity.AddLifeTime(DateTime.Now, throwingConfig.CountdownTime + 2000);
            return(throwingEntity);
        }
Beispiel #4
0
        public IKillInfoItem CreateKillInfo(string killerName, long killerTeamId, int killerWeaponId, int killType, string deadName, long deadTeamId, EUIDeadType deathType)
        {
            Logger.InfoFormat(
                "KillMessage:KillName={0},killerTeamId={1},killerWeaponId={2}, killType={3},deadName={4},deadTeamId={5},deathType={6}",
                killerName, killerTeamId, killerWeaponId, killType, deadName, deadTeamId, deathType);
            //            if (!IsInited)
            //                return;
            IKillInfoItem item = new KillInfoItem();

            item.createTime     = SingletonManager.Get <FreeUiManager>().Contexts1.session.currentTimeObject.CurrentTime;
            item.killerName     = killerName;
            item.killerTeamId   = killerTeamId;
            item.killerWeaponId = killerWeaponId;
            item.killType       = killType;
            item.deadName       = deadName;
            item.deadTeamId     = deadTeamId;
            item.deathType      = deathType;

            WeaponResConfigItem weaponConfig = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(killerWeaponId);

            if (null != weaponConfig)
            {
                WeaponAvatarConfigItem config = SingletonManager.Get <WeaponAvatarConfigManager>().GetConfigById(weaponConfig.AvatorId);
                if (null != config)
                {
                    item.weaponAsset = new AssetInfo(config.IconBundle, config.KillIcon);
                }
            }
            return(item);
        }
Beispiel #5
0
        public static int GetClipType(Contexts contexts, int weaponKey, FreeData fd)
        {
            var weaponAgent            = fd.Player.WeaponController().GetWeaponAgent(FreeWeaponUtil.GetSlotType(weaponKey));
            WeaponResConfigItem weapon = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(weaponAgent.ConfigId);

            return(weapon.Caliber);
        }
Beispiel #6
0
        public void OnHitPlayer(Contexts contexts, PlayerEntity src, PlayerEntity target, RaycastHit hit, MeleeAttackInfo attackInfo, MeleeFireLogicConfig config, int seq)
        {
            var       baseDamage = GetPlayerFactor(hit, config) * GetBaseDamage(attackInfo, config);
            Collider  collider   = hit.collider;
            EBodyPart part       = BulletPlayerUtility.GetBodyPartByHitBoxName(collider);

            //有效命中

            /*if (target.gamePlay.IsLastLifeState(EPlayerLifeState.Alive))
             * {
             *  src.statisticsData.Statistics.ShootingPlayerCount++;
             * }*/

            WeaponResConfigItem newConfig = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(src.WeaponController().HeldWeaponAgent.ConfigId);

            if (null != newConfig && newConfig.SubType == (int)EWeaponSubType.Hand)
            {
                BulletPlayerUtility.ProcessPlayerHealthDamage(contexts, _damager, src, target, new PlayerDamageInfo(Mathf.CeilToInt(baseDamage), (int)EUIDeadType.Unarmed, (int)part, 0), _damageInfoCollector);
            }
            else
            {
                BulletPlayerUtility.ProcessPlayerHealthDamage(contexts, _damager, src, target, new PlayerDamageInfo(Mathf.CeilToInt(baseDamage), (int)EUIDeadType.Weapon, (int)part, src.WeaponController().HeldWeaponAgent.ConfigId), _damageInfoCollector);
            }

            //由于动画放在客户端做了,服务器调用的命令会被忽视,需要发送事件到客户端
//            if (target.hasStateInterface && target.stateInterface.State.CanBeenHit())
//            {
//                target.stateInterface.State.BeenHit();
//            }

            ClientEffectFactory.AddBeenHitEvent(src, target.entityKey.Value, BulletHitHandler.GeneraterUniqueHitId(src, seq), contexts.session.currentTimeObject.CurrentTime);
            ClientEffectFactory.AddHitPlayerEffectEvent(src, target.entityKey.Value, hit.point, hit.point - target.position.Value);
        }
Beispiel #7
0
 public IFireLogic GetFireLogic(WeaponResConfigItem newWeaponConfig,
                                DefaultWeaponAbstractFireFireLogicConfig config)
 {
     if (!_cache.ContainsKey(newWeaponConfig.Id))
     {
         var defaultCfg = config as DefaultFireLogicConfig;
         if (null != defaultCfg)
         {
             _cache[newWeaponConfig.Id] = CreateDefaultFireLogic(newWeaponConfig, defaultCfg);
         }
         var meleeCfg = config as MeleeFireLogicConfig;
         if (null != meleeCfg)
         {
             _cache[newWeaponConfig.Id] = new MeleeFireLogic(meleeCfg);
         }
         var throwingCfg = config as ThrowingFireLogicConfig;
         if (null != throwingCfg)
         {
             _cache[newWeaponConfig.Id] = new ThrowingFireLogic(
                 newWeaponConfig,
                 throwingCfg,
                 _componentsFactory);
         }
     }
     if (_cache.ContainsKey(newWeaponConfig.Id))
     {
         return(_cache[newWeaponConfig.Id]);
     }
     if (newWeaponConfig.Type != (int)EWeaponType_Config.TacticWeapon)
     {
         Logger.ErrorFormat("no firelogic for weapon {0}", newWeaponConfig.Id);
     }
     return(null);
 }
Beispiel #8
0
        public static TipShowData GetCompareTip(BagItem item)
        {
            if (item.cat == 2)
            {
                WeaponResConfigItem weapon = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(item.id);

                if (weapon.Type == (int)EWeaponType_Config.PrimeWeapon)
                {
                    if (HasTip("w1"))
                    {
                        return(new TipShowData(item.cat, item.id, chickenDic["w1"].id, 1));
                    }
                    else if (HasTip("w2"))
                    {
                        return(new TipShowData(item.cat, item.id, chickenDic["w2"].id, 1));
                    }
                }
                else if (weapon.Type == (int)EWeaponType_Config.SubWeapon)
                {
                    if (HasTip("w3"))
                    {
                        return(new TipShowData(item.cat, item.id, chickenDic["w3"].id, 1));
                    }
                }
            }

            return(new TipShowData(item.cat, item.id, 0, 1));
        }
Beispiel #9
0
 public ThrowingFactory(ThrowingContext throwingContext, IEntityIdGenerator entityIdGenerator, WeaponResConfigItem newWeaponConfig, ThrowingConfig throwingConfig)
 {
     _throwingContext   = throwingContext;
     _entityIdGenerator = entityIdGenerator;
     _newWeaponConfig   = newWeaponConfig;
     _config            = throwingConfig;
 }
        public PlayerDamageInfo(float damage, int type, int part, int weaponId, bool isOverWall = false, bool isKnife = false, bool instantDeath = false,
                                Vector3 hitPoint = default(Vector3), Vector3 hitDirection = default(Vector3))
        {
            this.damage      = damage;
            this.type        = type;
            this.part        = part;
            this.weaponId    = weaponId;
            IsOverWall       = isOverWall;
            KillType         = 0;
            KillFeedbackType = 0;
            InstantDeath     = instantDeath;

            HitPoint     = hitPoint;
            HitDirection = hitDirection;

            WeaponResConfigItem weapon = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(weaponId);

            if (weapon != null)
            {
                IsKnife = weapon.Type == (int)EWeaponType_Config.MeleeWeapon;
            }
            else
            {
                IsKnife = false;
            }
        }
Beispiel #11
0
        private static string putOnPart(FreeData fd, int weaponType, FreeItemInfo info, string toInv = "", ServerRoom room = null)
        {
            WeaponResConfigItem weapon = GetWeapon(fd, weaponType);

            if (weapon != null)
            {
                int detailId         = WeaponPartUtil.GetWeaponFstMatchedPartId(info.id, weapon.Id);
                var weaponconfigMngr = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(weapon.Id);
                foreach (EWeaponPartType part in weaponconfigMngr.ApplyPartsSlot)
                {
                    int p = FreeWeaponUtil.GetWeaponPart(part);
                    if (weaponconfigMngr.IsPartMatchWeapon(detailId))
                    {
                        if ("p" + p == info.subType)
                        {
                            string        inv = "w" + weaponType + p;
                            ItemInventory ii  = fd.freeInventory.GetInventoryManager().GetInventory(inv);
                            if (ii != null && (ii.posList.Count == 0 ||
                                               toInv.StartsWith("w" + weaponType)))
                            {
                                if (ii.posList.Count > 0)
                                {
                                    DropPart(inv, fd, room);
                                }
                                return(inv);
                            }
                        }
                    }
                }
            }

            return(null);
        }
Beispiel #12
0
        public static ThrowingEntity CreateThrowingEntity(PlayerWeaponController controller, int serverTime,
                                                          Vector3 dir, Vector3 viePos, float initVel,
                                                          WeaponResConfigItem newWeaponConfig,
                                                          ThrowingConfig throwingConfig)
        {
            int throwingEntityId = EntityIdGenerator.GetNextEntityId();


            Vector3        velocity       = dir * initVel;
            ThrowingEntity throwingEntity = ThrowingContext.CreateEntity();

            throwingEntity.AddEntityKey(new EntityKey(throwingEntityId, (int)EEntityType.Throwing));
            // throwingEntity.AddThrowingData(velocity, false, false, 0, serverTime, false, initVel, throwingConfig,
            //     newWeaponConfig.SubType);
            throwingEntity.AddThrowingData(throwingConfig, newWeaponConfig, initVel, 0, serverTime, velocity, newWeaponConfig.SubType);
            throwingEntity.AddPosition();
            //TODO:EmitPos,ViewPos做射线检测取合适的点
            throwingEntity.position.Value = viePos;
            throwingEntity.AddOwnerId(controller.Owner);
            throwingEntity.isFlagSyncNonSelf = true;
            throwingEntity.AddLifeTime(DateTime.Now, throwingConfig.CountdownTime + 2000);
            _logger.InfoFormat("CreateThrowing from {0} with velocity {1}, entity key {2}",
                               throwingEntity.position.Value, throwingEntity.throwingData.Velocity, throwingEntity.entityKey);
            return(throwingEntity);
        }
 public WeaponBagItemInfo(PlayerWeaponData playerWeaponData, WeaponResConfigItem newWeaponConfig, WeaponAvatarConfigItem weaponAvatarConfigItem)
 {
     _playerWeaponData   = playerWeaponData;
     _weaponConfig       = newWeaponConfig;
     _weaponAvatarConfig = weaponAvatarConfigItem;
     if (_playerWeaponData.Muzzle > 0)
     {
         _muzzleAsset = GetWeaponPartIcon(_playerWeaponData.Muzzle);
     }
     if (_playerWeaponData.Magazine > 0)
     {
         _magazineAsset = GetWeaponPartIcon(_playerWeaponData.Magazine);
     }
     if (_playerWeaponData.Stock > 0)
     {
         _stockAsset = GetWeaponPartIcon(_playerWeaponData.Stock);
     }
     if (_playerWeaponData.UpperRail > 0)
     {
         _upperAsset = GetWeaponPartIcon(_playerWeaponData.UpperRail);
     }
     if (_playerWeaponData.LowerRail > 0)
     {
         _lowerAsset = GetWeaponPartIcon(_playerWeaponData.LowerRail);
     }
 }
Beispiel #14
0
 public WeaponBagItemInfo(PlayerWeaponData playerWeaponData, WeaponResConfigItem newWeaponConfig, WeaponAvatarConfigItem weaponAvatarConfigItem)
 {
     _playerWeaponData   = playerWeaponData;
     _weaponConfig       = newWeaponConfig;
     _weaponAvatarConfig = weaponAvatarConfigItem;
     if (_playerWeaponData.Muzzle > 0)
     {
         _muzzleAsset = SingletonManager.Get <WeaponPartsConfigManager>().GetAsset(_playerWeaponData.Muzzle);
     }
     if (_playerWeaponData.Magazine > 0)
     {
         _magazineAsset = SingletonManager.Get <WeaponPartsConfigManager>().GetAsset(_playerWeaponData.Magazine);
     }
     if (_playerWeaponData.Stock > 0)
     {
         _magazineAsset = SingletonManager.Get <WeaponPartsConfigManager>().GetAsset(_playerWeaponData.Stock);
     }
     if (_playerWeaponData.UpperRail > 0)
     {
         _magazineAsset = SingletonManager.Get <WeaponPartsConfigManager>().GetAsset(_playerWeaponData.UpperRail);
     }
     if (_playerWeaponData.LowerRail > 0)
     {
         _magazineAsset = SingletonManager.Get <WeaponPartsConfigManager>().GetAsset(_playerWeaponData.LowerRail);
     }
 }
Beispiel #15
0
 private bool NoReloadAction(WeaponResConfigItem config)
 {
     if (null == config)
     {
         return(true);
     }
     return(config.Type == (int)EWeaponType_Config.ThrowWeapon || config.Type == (int)EWeaponType_Config.MeleeWeapon);
 }
Beispiel #16
0
        public ThrowingFireLogic(

            WeaponResConfigItem newWeaponConfig,
            ThrowingFireLogicConfig config,
            IWeaponLogicComponentsFactory componentsFactory)
        {
            _config          = config;
            _throwingFactory = componentsFactory.CreateThrowingFactory(newWeaponConfig, config.Throwing);
        }
Beispiel #17
0
 public static bool VertifyWeaponConfigId(int weaponId, out WeaponResConfigItem config)
 {
     config = null;
     if (weaponId == 0)
     {
         return(false);
     }
     config = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(weaponId);
     return(config != null);
 }
Beispiel #18
0
 public IFireActionLogic CreateFireActionLogic(WeaponResConfigItem config)
 {
     if (SingletonManager.Get <WeaponResourceConfigManager>().IsSpecialType(config.Id, ESpecialWeaponType.SniperFrie))
     {
         return(new SpecialFireActionLogic());
     }
     else
     {
         return(new DefaultFireActionLogic());
     }
 }
        private void LoadWeaponObject(SceneObjectEntity sceneObjectEntity, WeaponResConfigItem weaponCfg)
        {
            var avatarId = weaponCfg.AvatorId;

            if (sceneObjectEntity.weaponObject.WeaponAvatarId > 0)
            {
                avatarId = sceneObjectEntity.weaponObject.WeaponAvatarId;
            }
            AssetInfo thdPersonAsset = SingletonManager.Get <WeaponAvatarConfigManager>().GetThirdPersonWeaponModel(avatarId);

            if (!sceneObjectEntity.hasMultiUnityObject)
            {
                sceneObjectEntity.AddMultiUnityObject();
            }
            else
            {
                sceneObjectEntity.multiUnityObject.Prepare();
            }
            if (!sceneObjectEntity.hasWeaponAttachment)
            {
                sceneObjectEntity.AddWeaponAttachment();
            }
            else
            {
                sceneObjectEntity.weaponAttachment.Reset();
            }
            LoadNecessaryAssetAsync(sceneObjectEntity, thdPersonAsset);
            List <int> weaponParts = sceneObjectEntity.weaponObject.CollectParts();

            for (int i = 0; i < weaponParts.Count; i++)
            {
                AssetInfo partAssetInfo = SingletonManager.Get <WeaponPartsConfigManager>().GetAsset(weaponParts[i]);
                var       partAssetData = new PartAssetData();
                partAssetData.PartId       = weaponParts[i];
                partAssetData.PartSlotType = (int)SingletonManager.Get <WeaponPartsConfigManager>().GetPartType(weaponParts[i]);
                LoadPartAssetAsync(sceneObjectEntity, partAssetInfo, partAssetData);
            }

            //加载特效
            List <AssetInfo> effectAssetInfo =
                SingletonManager.Get <WeaponAvatarConfigManager>().GetEffectAsset(avatarId);

            foreach (var effect in effectAssetInfo)
            {
                LoadEffectAssetAsync(sceneObjectEntity, effect);
            }

            sceneObjectEntity.effects.AddGlobalEffect(GlobalEffectManager.GlobalGroundPropFlash);
        }
Beispiel #20
0
        public void HandleWeaponFire(Contexts contexts, PlayerEntity player, WeaponResConfigItem weapon)
        {
            if (!this.args.Triggers.IsEmpty(FreeTriggerConstant.WEAPON_FIRE))
            {
                SimpleParaList dama = new SimpleParaList();
                dama.AddFields(new ObjectFields(weapon));
                SimpleParable sp = new SimpleParable(dama);
                args.TempUse("weapon", sp);
                args.TempUse("current", (FreeData)player.freeData.FreeData);

                this.args.Triggers.Trigger(FreeTriggerConstant.WEAPON_FIRE, args);

                args.Resume("weapon");
                args.Resume("current");
            }
        }
Beispiel #21
0
        private void RefreshDurableEquimentTips(WeaponResConfigItem data)
        {
            if (data == null)
            {
                return;
            }
            //刷新topGroup
            _viewModel.attrGroupActiveSelf = false;
            _viewModel.typeText            = GetDurableTypeText((EWeaponType_Config)data.Type);
            _viewModel.nameText            = data.Name;
            _viewModel.infoOneActiveSelf   = true;
            _viewModel.infoOneText         =
                data.Durable > 0 ? I2.Loc.ScriptLocalization.client_common.word36 + data.Durable : "";

            _viewModel.infoTwoText =
                data.Weight > 0 ? I2.Loc.ScriptLocalization.client_common.word25 + data.Weight : "";
        }
Beispiel #22
0
        public IWeaponLogic CreateWeaponLogic(WeaponResConfigItem newCfg,
                                              WeaponConfig config,
                                              IWeaponSoundLogic soundLogic,
                                              IWeaponEffectLogic effectLogic)
        {
            IWeaponLogic rc = null;
            var          weaponLogicConfig = config.WeaponLogic;

            if (weaponLogicConfig is WeaponConfigNs.DefaultWeaponBehaviorConfig)
            {
                rc = new Behavior.DefaultWeaponLogic();
            }
            else if (weaponLogicConfig is DoubleWeaponBehaviorConfig)
            {
                rc = new DoubleWeaponLogic(null, null);
            }
            return(rc);
        }
Beispiel #23
0
        private IFireLogic CreateDefaultFireLogic(WeaponResConfigItem newWeaponConfig,
                                                  DefaultFireLogicConfig config)
        {
            var fireLogic = new DefaultFireLogic();

            fireLogic.RegisterLogic(_componentsFactory.CreateAccuracyLogic(config.AccuracyLogic));
            fireLogic.RegisterLogic(_componentsFactory.CreateSpreadLogic(config.SpreadLogic));
            fireLogic.RegisterLogic(_componentsFactory.CreateKickbackLogic(config.KickbackLogic));

            fireLogic.RegisterLogic(_componentsFactory.CreateFireCheckLogic(config.FireModeLogic));
            fireLogic.RegisterLogic(_componentsFactory.CreateFireActionLogic(newWeaponConfig));
            fireLogic.RegisterLogic(_componentsFactory.CreateFireBulletCounterLogic(config.FireCounter));
            fireLogic.RegisterLogic(_componentsFactory.CreateAutoFireLogic(config.FireModeLogic));
            fireLogic.RegisterLogic(_componentsFactory.CreateBulletFireLogic(config.Bullet));
            fireLogic.RegisterLogic(_componentsFactory.CreateSpecialReloadCheckLogic(config.Basic));
            fireLogic.RegisterLogic(_componentsFactory.CreateFireCommandLogic(config));
            fireLogic.RegisterLogic(_componentsFactory.CreateShowFireInMap(config));
            return(fireLogic);
        }
        public void OnHitPlayer(Contexts contexts, PlayerEntity src, PlayerEntity target, RaycastHit hit,
                                MeleeAttackInfo attackInfo, MeleeFireLogicConfig config, int seq)
        {
            EBodyPart part       = BulletPlayerUtil.GetBodyPartByHitBoxName(hit.collider);
            var       baseDamage = MeleeHitUtil.GetPlayerFactor(hit, config, part) *
                                   MeleeHitUtil.GetBaseDamage(attackInfo, config);

            if (src.hasStatisticsData)
            {
                src.statisticsData.Statistics.AttackType = (int)attackInfo.AttackType;
            }

            //有效命中

            /*if (target.gamePlay.IsLastLifeState(EPlayerLifeState.Alive))
             * {
             *  src.statisticsData.Statistics.ShootingPlayerCount++;
             * }*/
            var playerWeaponId            = src.WeaponController().HeldConfigId;
            WeaponResConfigItem newConfig =
                SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(playerWeaponId);
            EUIDeadType euiDeadType = (null != newConfig && newConfig.SubType == (int)EWeaponSubType.Hand)
                            ? EUIDeadType.Unarmed
                            : EUIDeadType.Weapon;

            BulletPlayerUtil.ProcessPlayerHealthDamage(contexts, _damager, src, target,
                                                       new PlayerDamageInfo(Mathf.CeilToInt(baseDamage), (int)euiDeadType, (int)part,
                                                                            src.WeaponController().HeldWeaponAgent.ConfigId, false, false, false, hit.point,
                                                                            target.position.Value - src.position.Value));

            //   Logger.InfoFormat("[Hit] process damage sucess,dvalue:{0}", baseDamage);
            //由于动画放在客户端做了,服务器调用的命令会被忽视,需要发送事件到客户端
            //            if (target.hasStateInterface && target.stateInterface.State.CanBeenHit())
            //            {
            //                target.stateInterface.State.BeenHit();
            //            }

            ClientEffectFactory.AddBeenHitEvent(src, target, AttackUtil.GeneraterUniqueHitId(src, seq),
                                                contexts.session.currentTimeObject.CurrentTime);
            int audioId = SingletonManager.Get <AudioWeaponManager>().FindById(playerWeaponId).HitList.Body;

            ClientEffectFactory.AddHitPlayerEffectEvent(src, target.entityKey.Value, hit.point, audioId, part);
        }
Beispiel #25
0
        public static bool CanAddToBag(IEventArgs args, FreeData fd, int cat, int id, int count)
        {
            bool         can      = true;
            float        capacity = GetCapacity(fd);
            float        weight   = GetWeight(fd);
            FreeItemInfo info     = FreeItemConfig.GetItemInfo(cat, id);

            if (cat == (int)ECategory.Avatar)
            {
                float oldCap = GetCapacity(fd, cat, id);

                can = Math.Round(capacity - weight, 3) >= oldCap - info.capacity;
            }

            if (cat == (int)ECategory.GameItem || cat == (int)ECategory.WeaponPart)
            {
                can = Math.Round(capacity - weight, 3) >= info.weight * count;
            }

            if (cat == (int)ECategory.Weapon)
            {
                WeaponResConfigItem item = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(id);
                if (item.Type == (int)EWeaponType_Config.ThrowWeapon)
                {
                    can = Math.Round(capacity - weight, 3) >= info.weight * count;
                }
            }

            if (!can)
            {
                UseCommonAction use = new UseCommonAction();
                use.key    = "showBottomTip";
                use.values = new List <ArgValue>();
                use.values.Add(new ArgValue("msg", "{desc:10073}"));

                args.TempUse("current", fd);
                use.Act(args);
                args.Resume("current");
            }

            return(can);
        }
Beispiel #26
0
        public static int CanAddToBagCount(IEventArgs args, FreeData fd, int cat, int id, int count)
        {
            if (count > 1)
            {
                int          canCount = 0;
                float        capacity = GetCapacity(fd);
                float        weight   = GetWeight(fd);
                FreeItemInfo info     = FreeItemConfig.GetItemInfo(cat, id);

                if (cat == (int)ECategory.GameItem || cat == (int)ECategory.WeaponPart)
                {
                    canCount = (int)(Math.Round(capacity - weight, 3) / info.weight);
                }

                if (cat == (int)ECategory.Weapon)
                {
                    WeaponResConfigItem item = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(id);
                    if (item.Type == (int)EWeaponType_Config.ThrowWeapon)
                    {
                        canCount = (int)(Math.Round(capacity - weight, 3) / info.weight);
                    }
                }

                int realCount = Math.Min(count, canCount);

                if (realCount == 0)
                {
                    UseCommonAction use = new UseCommonAction();
                    use.key    = "showBottomTip";
                    use.values = new List <ArgValue>();
                    use.values.Add(new ArgValue("msg", "{desc:10073}"));

                    args.TempUse("current", fd);
                    use.Act(args);
                    args.Resume("current");
                }

                return(realCount);
            }

            return(CanAddToBag(args, fd, cat, id, count) ? 1 : 0);
        }
Beispiel #27
0
 public static void ShowSplitUI(ServerRoom room, FreeData fd, string key)
 {
     // 分拆道具
     if (key.StartsWith(ChickenConstant.BagDefault))
     {
         ItemPosition ip        = FreeItemManager.GetItemPosition(room.ContextsWrapper.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager());
         FreeItemInfo info      = FreeItemConfig.GetItemInfo(ip.key.GetKey());
         var          stackable = true;
         if (info.cat == (int)ECategory.Weapon)
         {
             WeaponResConfigItem item = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(info.id);
             if (item.Type != (int)EWeaponType_Config.ThrowWeapon)
             {
                 stackable = false;
             }
         }
         else
         {
             if (info.stack <= 1)
             {
                 stackable = false;
             }
         }
         SimpleProto data = FreePool.Allocate();
         if (!stackable || ip.count <= 1)
         {
             data.Key = FreeMessageConstant.ChickenTip;
             data.Ss.Add("word78");
             FreeMessageSender.SendMessage(fd.Player, data);
             return;
         }
         data.Key = FreeMessageConstant.ShowSplitUI;
         data.Ins.Add(info.cat);
         data.Ins.Add(info.id);
         data.Ins.Add(ip.count);
         data.Ss.Add(key);
         data.Ss.Add(ip.GetKey().GetName());
         FreeMessageSender.SendMessage(fd.Player, data);
         PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, fd.Player.gamePlay);
     }
 }
Beispiel #28
0
        public PlayerDamageInfo(float damage, int type, int part, int weaponId, bool isOverWall = false, bool isKnife = false)
        {
            this.damage      = damage;
            this.type        = type;
            this.part        = part;
            this.weaponId    = weaponId;
            IsOverWall       = isOverWall;
            KillType         = 0;
            KillFeedbackType = 0;

            WeaponResConfigItem weapon = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(weaponId);

            if (weapon != null)
            {
                IsKnife = weapon.Type == (int)EWeaponType_Config.MeleeWeapon;
            }
            else
            {
                IsKnife = false;
            }
        }
Beispiel #29
0
        public static int CanAddToBagCount(IEventArgs args, FreeData fd, int cat, int id, int count)
        {
            if (count > 1 && cat != (int)ECategory.Avatar)
            {
                int          canCount = 0;
                float        capacity = GetCapacity(fd);
                float        weight   = GetWeight(fd);
                FreeItemInfo info     = FreeItemConfig.GetItemInfo(cat, id);

                if (cat == (int)ECategory.GameItem || cat == (int)ECategory.WeaponPart)
                {
                    canCount = (int)(Math.Round(capacity - weight, 3) / info.weight);
                }

                if (cat == (int)ECategory.Weapon)
                {
                    WeaponResConfigItem item = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(id);
                    if (item.Type == (int)EWeaponType_Config.ThrowWeapon)
                    {
                        canCount = (int)(Math.Round(capacity - weight, 3) / info.weight);
                    }
                    if (item.Type == (int)EWeaponType_Config.Armor || item.Type == (int)EWeaponType_Config.Helmet)
                    {
                        canCount = count;
                    }
                }

                int realCount = Math.Min(count, canCount);
                if (realCount == 0)
                {
                    SimpleProto msg = FreePool.Allocate();
                    msg.Key = FreeMessageConstant.ChickenTip;
                    msg.Ss.Add("word73");
                    FreeMessageSender.SendMessage(fd.Player, msg);
                }
                return(realCount);
            }
            return(CanAddToBag(args, fd, cat, id, count) ? 1 : 0);
        }
Beispiel #30
0
        public static bool CanAddToBag(IEventArgs args, FreeData fd, int cat, int id, int count)
        {
            bool         can      = true;
            float        capacity = GetCapacity(fd);
            float        weight   = GetWeight(fd);
            FreeItemInfo info     = FreeItemConfig.GetItemInfo(cat, id);

            if (info == null)
            {
                return(false); // 无效道具
            }
            if (cat == (int)ECategory.Avatar)
            {
                float oldCap = GetCapacity(fd, cat, id);

                can = Math.Round(capacity - weight, 3) >= oldCap - info.capacity;
            }
            if (cat == (int)ECategory.GameItem || cat == (int)ECategory.WeaponPart)
            {
                can = Math.Round(capacity - weight, 3) >= info.weight * count;
            }
            if (cat == (int)ECategory.Weapon)
            {
                WeaponResConfigItem item = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(id);
                if (item.Type == (int)EWeaponType_Config.ThrowWeapon)
                {
                    can = Math.Round(capacity - weight, 3) >= info.weight * count;
                }
            }

            if (!can)
            {
                SimpleProto msg = FreePool.Allocate();
                msg.Key = FreeMessageConstant.ChickenTip;
                msg.Ss.Add("word73");
                FreeMessageSender.SendMessage(fd.Player, msg);
            }
            return(can);
        }