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);
                    }
                }
            }
        }
示例#2
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);
                }
            }
        }
示例#3
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);
                            }
                        }
                    }
                }
            }
        }
示例#4
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;
                }
            }
        }
示例#5
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]);
            }
        }