private void StartFlying(PlayerEntity playerEntity, ThrowingEntity throwingEntity)
        {
            IPlayerWeaponState playerWeapon = playerEntity.weaponLogic.State;
            var     dir = BulletDirUtility.GetThrowingDir(playerWeapon);
            Vector3 vel = dir * throwingEntity.throwingData.InitVelocity;
            Vector3 pos = PlayerEntityUtility.GetThrowingEmitPosition(playerEntity);

            throwingEntity.position.Value        = pos;
            throwingEntity.throwingData.Velocity = vel;
            throwingEntity.throwingData.IsFly    = true;
            //扔掉手雷
            playerWeapon.LastGrenadeId = playerEntity.grenade.Id;

            if (SharedConfig.IsServer)
            {
                IEventArgs args = (IEventArgs)_contexts.session.commonSession.FreeArgs;

                if (!args.Triggers.IsEmpty((int)EGameEvent.WeaponState))
                {
                    SimpleParaList dama = new SimpleParaList();
                    dama.AddFields(new ObjectFields(playerWeapon));
                    dama.AddPara(new IntPara("CarryClip", playerWeapon.ReservedBulletCount));
                    dama.AddPara(new IntPara("Clip", playerWeapon.LoadedBulletCount));
                    dama.AddPara(new IntPara("ClipType", (int)playerWeapon.Caliber));
                    dama.AddPara(new IntPara("id", (int)playerWeapon.CurrentWeapon));
                    SimpleParable sp = new SimpleParable(dama);

                    args.Trigger((int)EGameEvent.WeaponState, new TempUnit[] { new TempUnit("state", sp), new TempUnit("current", (FreeData)((PlayerEntity)playerWeapon.Owner).freeData.FreeData) });
                }
            }
            playerWeapon.LastGrenadeId      = 0;
            playerWeapon.IsThrowingStartFly = false;
            //清理状态
            CastGrenade(playerEntity);
        }
예제 #2
0
        private void DoRealod(PlayerEntity playerEntity, PlayerWeaponController controller, int target)
        {
            //PlayerWeaponController controller = playerEntity.WeaponController();
            //var configAssy = controller.HeldWeaponLogicConfigAssy;
            var cfg = controller.HeldWeaponAgent.CommonFireCfg;
            var lastReservedBullet = controller.GetReservedBullet();

            target = Mathf.Min(target, lastReservedBullet);
            controller.HeldWeaponAgent.BaseComponent.Bullet           += target;
            controller.HeldWeaponAgent.RunTimeComponent.PullBoltFinish = true;
            //DebugUtil.MyLog("Bullet reload" + controller.HeldWeaponAgent.BaseComponent.Bullet, DebugUtil.DebugColor.Black);
            controller.SetReservedBullet(lastReservedBullet - target);

            IEventArgs args = (IEventArgs)(_sessonObjects).FreeArgs;

            if (!args.Triggers.IsEmpty((int)EGameEvent.WeaponState))
            {
                //TODO Implement
                SimpleParaList dama = new SimpleParaList();
                //    dama.AddFields(new ObjectFields(weaponState));
                dama.AddPara(new IntPara("CarryClip", lastReservedBullet - target));
                dama.AddPara(new IntPara("Clip", controller.HeldWeaponAgent.BaseComponent.Bullet));
                dama.AddPara(new IntPara("ClipType", (int)controller.HeldWeaponAgent.Caliber));
                dama.AddPara(new IntPara("id", (int)controller.HeldConfigId));
                SimpleParable sp = new SimpleParable(dama);
                dama.AddFields(new ObjectFields(playerEntity));
                args.Trigger((int)EGameEvent.WeaponState,
                             new TempUnit[]
                {
                    new TempUnit("state", sp), new TempUnit("current", (FreeData)playerEntity.freeData.FreeData)
                });
            }
        }
예제 #3
0
        public void KillPlayer(PlayerEntity source, PlayerEntity target, PlayerDamageInfo damage)
        {
            if (!this.args.Triggers.IsEmpty(FreeTriggerConstant.KILL_PLAYER))
            {
                if (source != null)
                {
                    args.TempUse("killer", (FreeData)source.freeData.FreeData);
                }
                args.TempUse("killed", (FreeData)target.freeData.FreeData);

                SimpleParaList dama = new SimpleParaList();
                dama.AddFields(new ObjectFields(damage));
                SimpleParable sp = new SimpleParable(dama);
                args.TempUse("damage", sp);

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

                if (source != null)
                {
                    args.Resume("killer");
                }
                args.Resume("killed");
                args.Resume("damage");
            }

            if (source != null)
            {
                source.statisticsData.Statistics.SetSrcDataByDamageInfo(damage);
            }
            if (target != null)
            {
                target.statisticsData.Statistics.SetTarDataByDamageInfo(damage);
            }
        }
        private void DoRealod(IPlayerWeaponState weaponState, int target)
        {
            target = Mathf.Min(target, weaponState.ReservedBulletCount);
            weaponState.LoadedBulletCount   += target;
            weaponState.ReservedBulletCount -= target;

            IEventArgs args = (IEventArgs)(_sessonObjects).FreeArgs;

            if (!args.Triggers.IsEmpty((int)EGameEvent.WeaponState))
            {
                SimpleParaList dama = new SimpleParaList();
                dama.AddFields(new ObjectFields(weaponState));
                dama.AddPara(new IntPara("CarryClip", weaponState.ReservedBulletCount));
                dama.AddPara(new IntPara("Clip", weaponState.LoadedBulletCount));
                dama.AddPara(new IntPara("ClipType", (int)weaponState.Caliber));
                dama.AddPara(new IntPara("id", (int)weaponState.CurrentWeapon));
                SimpleParable sp = new SimpleParable(dama);

                args.Trigger((int)EGameEvent.WeaponState, new TempUnit[] { new TempUnit("state", sp), new TempUnit("current", (FreeData)((PlayerEntity)weaponState.Owner).freeData.FreeData) });
            }

            if (weaponState.LoadedBulletCount >= weaponState.BulletCountLimit || weaponState.ReservedBulletCount < 1)
            {
                //如果前置弹夹已满,或者后备弹夹已空,这时应该执行了最后一次换弹,应附带有拉栓动作
                weaponState.IsBolted = true;
            }
        }
예제 #5
0
        private PlayerDamageInfo GetDamageInfo(IEventArgs args)
        {
            SimpleParable sp = (SimpleParable)args.GetUnit("damage");

            if (sp != null)
            {
                return
                    ((PlayerDamageInfo)((ObjectFields)((SimpleParaList)sp.GetParameters()).GetFieldList()[0]).GetObj());
            }
            else
            {
                return(new PlayerDamageInfo());
            }
        }
예제 #6
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");
            }
        }
예제 #7
0
        public override void DoAction(IEventArgs args)
        {
            if (values != null)
            {
                SimpleParaList testParaList = new SimpleParaList();

                FreeData fd = GetPlayer(args);
                if (null != fd)
                {
                    PlayerEntity player = fd.Player;
                    var          entity = args.GameContext.mapObject.GetEntityWithEntityKey(new EntityKey(player.gamePlay.UseEntityId, (int)EEntityType.MapObject));
                    if (null != entity && entity.hasDoorData)
                    {
                        testParaList.AddFields(new ObjectFields(entity.doorData));
                    }
                }

                SimpleParable sp = new SimpleParable(testParaList);
                args.TempUse("testPara", sp);

                args.TempUse(UnitTestConstant.Tester, GetPlayer(args));

                GameTrigger trigger = FreeLog.GetTrigger();

                foreach (ITestValue value in values)
                {
                    TestValue tv = value.GetCaseValue(args);
                    tv.Name = value.Name;

                    if (!dic.ContainsKey(tv.Name))
                    {
                        dic.Add(tv.Name, new List <TestValue>());
                        dic[tv.Name].Add(tv);
                    }

                    List <TestValue> list = dic[tv.Name];

                    if (!list[list.Count - 1].IsSame(tv))
                    {
                        list.Add(tv);
                    }
                }

                args.Resume("testPara");
                args.Resume(UnitTestConstant.Tester);
            }
        }
예제 #8
0
        protected void PlayerReportTrigger(GameOverPlayer gameOverPlayer, IPlayerInfo playerInfo, IFreeArgs freeArgs)
        {
            SimpleParable  unit = new SimpleParable();
            SimpleParaList list = new SimpleParaList();

            unit.SetList(list);
            list.AddFields(new ObjectFields(gameOverPlayer));
            list.AddFields(new ObjectFields(_dictGoPlayers));
            list.AddFields(new ObjectFields(_dictPlayers));
            list.AddFields(new ObjectFields(_dictLeavedPlayers));
            IEventArgs args = freeArgs as IEventArgs;

            if (null != args)
            {
                var playerEntity = playerInfo.PlayerEntity as PlayerEntity;
                args.Trigger(FreeTriggerConstant.PLAYER_REPORT, new TempUnit("report", unit),
                             new TempUnit("current", (FreeData)playerEntity.freeData.FreeData));
            }
        }
예제 #9
0
        //TODO 找到调用的位置,确认逻辑行为
        public void HandleWeaponState(Contexts contexts, PlayerEntity player)
        {
            if (!this.args.Triggers.IsEmpty(FreeTriggerConstant.WEAPON_STATE))
            {
                SimpleParaList dama = new SimpleParaList();
                //dama.AddFields(new ObjectFields(state));
                //dama.AddPara(new IntPara("CarryClip", state.ReservedBulletCount));
                //dama.AddPara(new IntPara("Clip", state.LoadedBulletCount));
                ////dama.AddPara(new IntPara("ClipType", (int)state.Caliber));
                //dama.AddPara(new IntPara("id", (int)state.CurrentWeapon));
                SimpleParable sp = new SimpleParable(dama);
                args.TempUse("state", sp);
                args.TempUse("current", (FreeData)player.freeData.FreeData);

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

                args.Resume("state");
                args.Resume("current");
            }
        }
예제 #10
0
 private void HandleArmor(IEventArgs args)
 {
     if ("ReduceDamage" == code)
     {
         FreeData fd = (FreeData)args.GetUnit("target");
         if (fd != null)
         {
             SimpleParable sp = (SimpleParable)args.GetUnit("damage");
             if (sp != null)
             {
                 PlayerDamageInfo info = (PlayerDamageInfo)((ObjectFields)((SimpleParaList)sp.GetParameters()).GetFieldList()[0]).GetObj();
                 float            da   = ReduceDamageUtil.HandleDamage(args, fd, info);
                 FloatPara        d    = (FloatPara)args.GetDefault().GetParameters().Get("damage");
                 if (d != null)
                 {
                     d.SetValue(da);
                 }
             }
         }
     }
 }
예제 #11
0
        public override void DoAction(IEventArgs args)
        {
            var msg = GameOverMessage.Allocate();

            msg.HallRoomId = args.GameContext.session.commonSession.RoomInfo.HallRoomId;

            FreeGameRule rule = (FreeGameRule)args.Rule;

            foreach (PlayerEntity player in args.GameContext.player.GetInitializedPlayerEntities())
            {
                SimpleParable  sp    = new SimpleParable();
                SimpleParaList paras = new SimpleParaList();
                sp.SetList(paras);

                var gameOverPlayer = GameOverPlayer.Allocate();

                paras.AddFields(new ObjectFields(gameOverPlayer));
                gameOverPlayer.Id = player.playerInfo.PlayerId;

                args.Act(action, new TempUnit[] { new TempUnit("basic", sp) });
            }
        }
예제 #12
0
        public float HandleDamage(PlayerEntity source, PlayerEntity target, PlayerDamageInfo damage)
        {
            if (damagePara == null)
            {
                damagePara = new FloatPara("damage", damage.damage);
            }

            damagePara.SetValue(Math.Min(damage.damage, target.gamePlay.CurModeHp));

            if (!this.args.Triggers.IsEmpty(FreeTriggerConstant.DAMAGE))
            {
                if (source != null)
                {
                    args.TempUse("source", (FreeData)source.freeData.FreeData);
                }
                args.TempUse("target", (FreeData)target.freeData.FreeData);

                SimpleParaList dama = new SimpleParaList();
                dama.AddFields(new ObjectFields(damage));
                SimpleParable sp = new SimpleParable(dama);
                args.TempUse("damage", sp);

                args.TempUsePara(damagePara);

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

                if (source != null)
                {
                    args.Resume("source");
                }

                args.Resume("target");
                args.Resume("damage");
                args.ResumePara("damage");
            }


            return((float)damagePara.GetValue());
        }
예제 #13
0
        public void HandleWeaponState(Contexts contexts, PlayerEntity player, int weaponId)
        {
            if (!args.Triggers.IsEmpty(FreeTriggerConstant.WEAPON_STATE))
            {
                SimpleParaList dama = new SimpleParaList();
                dama.AddFields(new ObjectFields(player));

                /*var weaponData = player.WeaponController().HeldWeaponAgent.ComponentScan;
                 * if (!weaponData.IsSafeVailed)
                 *  return;
                 * dama.AddPara(new IntPara("CarryClip", player.WeaponController().GetReservedBullet()));
                 * dama.AddPara(new IntPara("Clip", weaponData.Bullet));
                 * var config = SingletonManager.Get<WeaponResourceConfigManager>().GetConfigById(weaponData.ConfigId);
                 * dama.AddPara(new IntPara("ClipType", null == config ? 0 : config.Caliber));*/
                dama.AddPara(new IntPara("id", weaponId));
                SimpleParable sp = new SimpleParable(dama);
                args.TempUse("state", sp);
                args.TempUse("current", (FreeData)player.freeData.FreeData);
                args.Trigger(FreeTriggerConstant.WEAPON_STATE, new TempUnit("state", sp), new TempUnit("current", (FreeData)(player).freeData.FreeData));
                args.Resume("state");
                args.Resume("current");

                /*SimpleParaList dama = new SimpleParaList();
                 * //dama.AddFields(new ObjectFields(state));
                 * //dama.AddPara(new IntPara("CarryClip", state.ReservedBulletCount));
                 * //dama.AddPara(new IntPara("Clip", state.LoadedBulletCount));
                 * ////dama.AddPara(new IntPara("ClipType", (int)state.Caliber));
                 * //dama.AddPara(new IntPara("id", (int)state.CurrentWeapon));
                 * SimpleParable sp = new SimpleParable(dama);
                 * args.TempUse("state", sp);
                 * args.TempUse("current", (FreeData)player.freeData.FreeData);
                 *
                 * this.args.Triggers.Trigger(FreeTriggerConstant.WEAPON_STATE, args);
                 *
                 * args.Resume("state");
                 * args.Resume("current");*/
            }
        }
예제 #14
0
        private void StartFlying(PlayerEntity playerEntity, ThrowingEntity throwingEntity)
        {
            var     dir = BulletDirUtility.GetThrowingDir(playerEntity.WeaponController());
            Vector3 vel = dir * throwingEntity.throwingData.InitVelocity;
            Vector3 pos = PlayerEntityUtility.GetThrowingEmitPosition(playerEntity.WeaponController());

            throwingEntity.position.Value        = pos;
            throwingEntity.throwingData.Velocity = vel;
            throwingEntity.throwingData.IsFly    = true;

            if (SharedConfig.IsServer)
            {
                IEventArgs args = (IEventArgs)_contexts.session.commonSession.FreeArgs;

                if (!args.Triggers.IsEmpty((int)EGameEvent.WeaponState))
                {
                    SimpleParaList dama = new SimpleParaList();
                    //TODO 确认逻辑
                    dama.AddFields(new ObjectFields(playerEntity));
                    var weaponData = playerEntity.WeaponController().HeldWeaponAgent.ComponentScan;
                    if (!weaponData.IsSafeVailed)
                    {
                        return;
                    }
                    dama.AddPara(new IntPara("CarryClip", playerEntity.WeaponController().GetReservedBullet()));
                    dama.AddPara(new IntPara("Clip", weaponData.Bullet));
                    var config = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(weaponData.ConfigId);
                    dama.AddPara(new IntPara("ClipType", null == config ? 0 : config.Caliber));
                    dama.AddPara(new IntPara("id", weaponData.ConfigId));
                    SimpleParable sp = new SimpleParable(dama);

                    args.Trigger((int)EGameEvent.WeaponState, new TempUnit("state", sp), new TempUnit("current", (FreeData)(playerEntity).freeData.FreeData));
                }
            }

            //清理状态
            CastGrenade(_contexts, playerEntity);
        }
예제 #15
0
        public override void DoAction(IEventArgs args)
        {
            FreeData fd = (FreeData)args.GetUnit("target");

            if (fd != null)
            {
                SimpleParable damage = (SimpleParable)args.GetUnit("damage");
                if (damage != null)
                {
                    PlayerDamageInfo info = (PlayerDamageInfo)damage.GetFieldObject(0);

                    WeaponAllConfigs configs = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(info.weaponId);

                    if (configs != null)
                    {
                        int time = configs.InitWeaponAllConfig.RigidityDuration;
                        int per  = configs.InitWeaponAllConfig.RigidityEffect;

                        fd.EffectBufs.AddEffect(RigidityEffect, (float)per / 100, time, args);
                    }
                }
            }
        }
예제 #16
0
        private void ReduceDamage(IEventArgs args, PlayerEntity player)
        {
            SimpleParable sp = (SimpleParable)args.GetUnit("damage");

            if (sp != null)
            {
                PlayerDamageInfo damage = (PlayerDamageInfo)sp.GetFieldObject(0);
                float            da     = damage.damage;
                if (damage.part == (int)EBodyPart.Head)
                {
                    int helId = player.gamePlay.HelmetLv;
                    if (armorDic.ContainsKey(helId))
                    {
                        ArmorData ad = armorDic[helId];

                        da = ReduceDamage(args, player, damage, ad.reduce, false);
                    }
                }
                else if (damage.part == (int)EBodyPart.Chest || damage.part == (int)EBodyPart.Stomach || damage.part == (int)EBodyPart.Pelvis)
                {
                    int armor = player.gamePlay.ArmorLv;
                    if (armorDic.ContainsKey(armor))
                    {
                        ArmorData ad = armorDic[armor];

                        da = ReduceDamage(args, player, damage, ad.reduce, true);
                    }
                }

                FloatPara d = (FloatPara)args.GetDefault().GetParameters().Get("damage");
                if (d != null)
                {
                    d.SetValue(da);
                }
            }
        }
예제 #17
0
        //private List<PlayerEntity> _playerList = new List<PlayerEntity>();

        public override void DoAction(IEventArgs args)
        {
            IParable unit = args.GetUnit("report");

            if (null != unit && unit is SimpleParable)
            {
                SimpleParable sp = (SimpleParable)unit;

                GameOverPlayer goPlayer = (GameOverPlayer)sp.GetFieldObject(0);
                Dictionary <long, GameOverPlayer> goPlayerList   = (Dictionary <long, GameOverPlayer>)sp.GetFieldObject(1);
                Dictionary <long, IPlayerInfo>    playerInfoList = (Dictionary <long, IPlayerInfo>)sp.GetFieldObject(2);
                Dictionary <long, IPlayerInfo>    leavedInfoList = (Dictionary <long, IPlayerInfo>)sp.GetFieldObject(3);

                RankType rankType = (RankType)ranktype;

                IPlayerInfo playerInfo;
                playerInfoList.TryGetValue(goPlayer.Id, out playerInfo);

                if (null == playerInfo)
                {
                    return;
                }
                //逃跑玩家为所有游戏中的玩家的最后一名
                if (playerInfo.StatisticsData.IsRunaway)
                {
                    playerInfo.StatisticsData.Rank = playerInfoList.Count;
                }
                //编辑器传来的数据
                string[] items = fields.Split(',');
                foreach (var item in items)
                {
                    string[] vs = item.Split('=');
                    if (vs.Length > 1)
                    {
                        goPlayer.Statistics[int.Parse(vs[0])] = args.GetInt(vs[1]);
                    }
                    else
                    {
                        Logger.ErrorFormat("字符串解析错误,请检查模式编辑器: {0}", fields);
                    }
                }
                //团战模式填入两项人数参数
                if (rankType == RankType.Group)
                {
                    int playerCountRate = 0;
                    int teamCountRate   = 0;
                    foreach (IPlayerInfo ipi in playerInfoList.Values)
                    {
                        if (ipi.StatisticsData.GameTime >= 3 * 60 * 1000)
                        {
                            playerCountRate++;
                        }
                        if (ipi.Camp == playerInfo.Camp)
                        {
                            teamCountRate++;
                        }
                    }
                    foreach (IPlayerInfo ipi in leavedInfoList.Values)
                    {
                        if (ipi.StatisticsData.GameTime >= 3 * 60 * 1000)
                        {
                            playerCountRate++;
                        }
                    }
                    goPlayer.Statistics[(int)EStatisticsID.ModePlayerCount]    = teamCountRate;
                    goPlayer.Statistics[(int)EStatisticsID.SectionPlayerCount] = playerCountRate;
                }

                if (issend)
                {
                    switch (rankType)
                    {
                    case RankType.Group:
                        if (!playerInfo.StatisticsData.IsRunaway)
                        {
                            List <IPlayerInfo> playerSortList = playerInfoList.Values.ToList();
                            GroupRank(playerSortList);
                        }
                        break;

                    case RankType.Survival:
                        if (args.GameContext.session.commonSession.RoomInfo.ModeId != GameRules.SoloSurvival)
                        {
                            SurvivalRank(playerInfoList.Values.ToList().Union(leavedInfoList.Values.ToList()).ToList(), goPlayerList);
                            Logger.InfoFormat("组队吃鸡模式对玩家进行了排名");
                        }
                        break;

                    default:
                        break;
                    }
                    goPlayer.Statistics[(int)EStatisticsID.Rank]    = playerInfo.StatisticsData.Rank;
                    goPlayer.Statistics[(int)EStatisticsID.RankAce] = playerInfo.StatisticsData.Rank == 1 ? 1 : 0;
                    goPlayer.Statistics[(int)EStatisticsID.RankTen] = playerInfo.StatisticsData.Rank <= 10 ? 1 : 0;
                }
                else
                {
                    //不算逃跑的离开玩家的数据保存,否则丢弃数据
                    if (!playerInfo.StatisticsData.IsRunaway && rankType == RankType.Survival)
                    {
                        GameOverPlayer savedGoPlayer = goPlayer.Clone();
                        if (goPlayerList.ContainsKey(savedGoPlayer.Id))
                        {
                            Logger.ErrorFormat("房间GameOverPlayer列表中出现重复ID {0}", savedGoPlayer.Id);
                        }
                        else
                        {
                            goPlayerList.Add(savedGoPlayer.Id, savedGoPlayer);
                        }
                    }
                    //不报告的情况下,将GameOverPlayer ID设为0
                    goPlayer.Id = 0L;
                }
                Logger.InfoFormat("Player {0} reported, Rank {1}", goPlayer.Id, goPlayer.Statistics[1]);
            }
        }
예제 #18
0
        public override void DoAction(IEventArgs args)
        {
            IParable unit = args.GetUnit("report");

            if (null != unit && unit is SimpleParable)
            {
                SimpleParable sp = (SimpleParable)unit;

                GameOverPlayer goPlayer = (GameOverPlayer)sp.GetFieldObject(0);
                Dictionary <long, GameOverPlayer> goPlayerList   = (Dictionary <long, GameOverPlayer>)sp.GetFieldObject(1);
                Dictionary <long, IPlayerInfo>    playerInfoList = new Dictionary <long, IPlayerInfo>();
                Dictionary <long, IPlayerInfo>    leavedInfoList = new Dictionary <long, IPlayerInfo>();
                Dictionary <long, IPlayerInfo>    infoList       = (Dictionary <long, IPlayerInfo>)sp.GetFieldObject(2);
                Dictionary <long, IPlayerInfo>    leftList       = (Dictionary <long, IPlayerInfo>)sp.GetFieldObject(3);
                int TeamCapacity = (int)sp.GetFieldObject(4);
                Logger.InfoFormat("reporting player {0}, totoal player {1}, left player {2}", goPlayer.Id, infoList.Count, leftList.Count);
                RankType rankType = (RankType)ranktype;

                IPlayerInfo playerInfo;
                playerInfoList.TryGetValue(goPlayer.Id, out playerInfo);
                if (null == playerInfo)
                {
                    Logger.InfoFormat("no IPlayerInfo of player {0}", goPlayer.Id);
                    return;
                }

                //移除缺少数据的玩家
                IPlayerInfo availablePlayer;
                List <long> keys = infoList.Keys.ToList();
                foreach (long key in keys)
                {
                    infoList.TryGetValue(key, out availablePlayer);
                    if (availablePlayer == null || availablePlayer.StatisticsData == null)
                    {
                        Logger.InfoFormat("player {0} info not available", key);
                        continue;
                    }
                    playerInfoList.Add(key, availablePlayer);
                }
                keys = leftList.Keys.ToList();
                foreach (long key in keys)
                {
                    leftList.TryGetValue(key, out availablePlayer);
                    if (availablePlayer == null || availablePlayer.StatisticsData == null)
                    {
                        Logger.InfoFormat("left player {0} info not available", key);
                        continue;
                    }
                    leavedInfoList.Add(key, availablePlayer);
                }

                //逃跑玩家为所有游戏中的玩家的最后一名
                if (playerInfo.StatisticsData.IsRunaway)
                {
                    playerInfo.StatisticsData.Rank = playerInfoList.Count;
                }

                //编辑器传来的数据
                if (!string.IsNullOrEmpty(fields))
                {
                    string[] items = fields.Split(',');
                    foreach (var item in items)
                    {
                        string[] vs = item.Split('=');
                        if (vs.Length > 1)
                        {
                            goPlayer.Statistics[int.Parse(vs[0])] = args.GetInt(vs[1]);
                        }
                        else
                        {
                            Logger.ErrorFormat("字符串解析错误,请检查模式编辑器: {0}", fields);
                        }
                    }
                }
                //团战模式填入两项人数参数
                if (rankType == RankType.Group)
                {
                    int playerCountRate = 0;
                    int teamCountRate   = 0;
                    foreach (IPlayerInfo ipi in playerInfoList.Values)
                    {
                        if (ipi.StatisticsData.GameJoinTime > 0 && args.Rule.ServerTime - ipi.StatisticsData.GameJoinTime >= 180000L)
                        {
                            playerCountRate++;
                        }
                        if (ipi.Camp == playerInfo.Camp)
                        {
                            teamCountRate++;
                        }
                        Logger.InfoFormat("player id {0} camp {1} game join time {2} played time {3}", ipi.PlayerId, ipi.Camp, ipi.StatisticsData.GameJoinTime, args.Rule.ServerTime - ipi.StatisticsData.GameJoinTime);
                    }
                    Logger.InfoFormat("game total player count {0} report send {1}", playerInfoList.Count, issend);
                    goPlayer.Statistics[(int)EStatisticsID.ModePlayerCount]    = teamCountRate;
                    goPlayer.Statistics[(int)EStatisticsID.SectionPlayerCount] = playerCountRate;
                }

                if (issend)
                {
                    switch (rankType)
                    {
                    case RankType.Group:
                        if (!playerInfo.StatisticsData.IsRunaway)
                        {
                            List <IPlayerInfo> playerSortList = playerInfoList.Values.ToList();
                            GroupRank(playerSortList, playerInfo, TeamCapacity > 1);
                        }
                        break;

                    case RankType.Survival:
                        int modeId = args.GameContext.session.commonSession.RoomInfo.ModeId;
                        if (modeId != GameRules.SoloSurvival && modeId != GameRules.LadderSoloSurvival && modeId != GameRules.AbyssSoloSurvival)
                        {
                            SurvivalRank(playerInfoList.Values.ToList().Union(leavedInfoList.Values.ToList()).ToList(), goPlayerList, args, playerInfo);
                        }
                        break;

                    default:
                        break;
                    }
                    goPlayer.Statistics[(int)EStatisticsID.Rank]    = playerInfo.StatisticsData.Rank;
                    goPlayer.Statistics[(int)EStatisticsID.RankAce] = playerInfo.StatisticsData.Rank == 1 ? 1 : 0;
                    goPlayer.Statistics[(int)EStatisticsID.RankTen] = playerInfo.StatisticsData.Rank <= 10 ? 1 : 0;
                }
                else
                {
                    //不算逃跑的离开玩家的数据保存,否则丢弃数据
                    if (!playerInfo.StatisticsData.IsRunaway && rankType == RankType.Survival)
                    {
                        GameOverPlayer savedGoPlayer = goPlayer.Clone();
                        if (goPlayerList.ContainsKey(savedGoPlayer.Id))
                        {
                            Logger.ErrorFormat("房间GameOverPlayer列表中出现重复ID {0}", savedGoPlayer.Id);
                        }
                        else
                        {
                            goPlayerList.Add(savedGoPlayer.Id, savedGoPlayer);
                        }
                    }
                    //不报告的情况下,将GameOverPlayer ID设为0
                    goPlayer.Id = 0L;
                }
            }
        }
예제 #19
0
        public override void DoAction(IEventArgs args)
        {
            PlayerEntity playerEntity = GetPlayerEntity(args);

            if (playerEntity != null)
            {
                SimpleParable sp = (SimpleParable)args.GetUnit("damage");
                if (sp != null)
                {
                    FloatPara        d      = (FloatPara)args.GetDefault().GetParameters().Get("damage");
                    PlayerDamageInfo damage = (PlayerDamageInfo)sp.GetFieldObject(0);

                    if (damage.type != (int)EUIDeadType.Weapon && damage.type != (int)EUIDeadType.Unarmed)
                    {
                        return;
                    }

                    if (playerEntity.gamePlay.CurHelmet > 0)
                    {
                        var config = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(playerEntity.gamePlay.HelmetLv);
                        if (config != null)
                        {
                            if (config.NewWeaponCfg.ProtectivePartsList.Contains(damage.part))
                            {
                                float readDamage = damage.damage;
                                float reduce     = readDamage * config.NewWeaponCfg.DamageReduction / 100;
                                reduce = Math.Min(playerEntity.gamePlay.CurHelmet, reduce);
                                playerEntity.gamePlay.CurHelmet = Math.Max(0, playerEntity.gamePlay.CurHelmet - (int)readDamage);
                                if (reduce > 0 && playerEntity.gamePlay.CurHelmet == 0)
                                {
                                    playerEntity.gamePlay.HelmetLv = playerEntity.gamePlay.MaxHelmet = 0;
                                    SimpleProto msg = FreePool.Allocate();
                                    msg.Key = FreeMessageConstant.ChickenTip;
                                    msg.Ss.Add("word75," + config.NewWeaponCfg.Name);
                                    FreeMessageSender.SendMessage(playerEntity, msg);
                                }

                                damage.damage -= reduce;
                                playerEntity.statisticsData.Statistics.DefenseDamage += reduce;

                                d.SetValue(damage.damage);
                            }
                        }
                    }

                    if (playerEntity.gamePlay.CurArmor > 0)
                    {
                        var config = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(playerEntity.gamePlay.ArmorLv);
                        if (config != null)
                        {
                            if (config.NewWeaponCfg.ProtectivePartsList.Contains(damage.part))
                            {
                                float readDamage = damage.damage;
                                float reduce     = readDamage * config.NewWeaponCfg.DamageReduction / 100;
                                reduce = Math.Min(playerEntity.gamePlay.CurArmor, reduce);
                                playerEntity.gamePlay.CurArmor = Math.Max(0, playerEntity.gamePlay.CurArmor - (int)readDamage);
                                if (reduce > 0 && playerEntity.gamePlay.CurArmor == 0)
                                {
                                    playerEntity.gamePlay.ArmorLv = playerEntity.gamePlay.MaxArmor = 0;
                                    SimpleProto msg = FreePool.Allocate();
                                    msg.Key = FreeMessageConstant.ChickenTip;
                                    msg.Ss.Add("word75," + config.NewWeaponCfg.Name);
                                    FreeMessageSender.SendMessage(playerEntity, msg);
                                }

                                damage.damage -= reduce;
                                playerEntity.statisticsData.Statistics.DefenseDamage += reduce;

                                d.SetValue(damage.damage);
                            }
                        }
                    }
                }
            }
        }