Beispiel #1
0
        // This constructor takes a game in parameter.
        // This will allow us to use the same framework for multiple games.
        public Character(Game myGame, string mycharacterName, string myplayerName)
        {
            if (myGame == null)
            {
                logger.Log("No Game found in Character creation. An error might happen.");
                throw new ArgumentNullException(nameof(Game));
            }

            logger.Log(String.Format("Inside ultimate character constructor : game {0}, characterName {1} and playerName {2}", myGame, mycharacterName, myplayerName));
            CharacterName = mycharacterName;
            PlayerName    = myplayerName;
            GameName      = myGame.Name;

            BaseAttr    = myGame.BaseAttributes;
            Skills      = myGame.Skills;
            Stats       = myGame.Stats;
            SpendPoints = myGame.SpendPoints;
            Metier      = (Profession)myGame.professions.Where(p => p.name == "mendiant").FirstOrDefault();
            CareerName  = Metier == null ? "mendiant" : Metier.name;

            IGameRule rules = myGame.rules;

            try
            {
                rules.SetBaseAttr(this);
                rules.SetStats(this);
                rules.SetSpendablePoints(this);
                rules.SetSkills(this);
                rules.SetCareerSkills(this);
            }
            catch (Exception ex)
            {
                logger.Log(String.Format("Error in Character Creation : {0} ", ex.Message));
            }
        }
 public GameManager(IPlayerInteractionService interactionService,
                    IGameStatusUpdateService statusUpdateService,
                    IGameRule rules)
 {
     _interactionService  = interactionService;
     _statusUpdateService = statusUpdateService;
     _gameRules           = rules;
 }
        protected override void ExecuteUserCmd(PlayerEntity playerEntity, IUserCmd cmd)
        {
            playerEntity.stage.Value   = EPlayerLoginStage.Running;
            playerEntity.isInitialized = true;
            FreeRuleEventArgs args = (FreeRuleEventArgs)contexts.session.commonSession.FreeArgs;
            IGameRule         rule = (IGameRule)args.Rule;

            rule.PlayerEnter(contexts, playerEntity);
        }
Beispiel #4
0
        public GameController(IPlayField playField, IGameRule gameRule)
        {
            if (playField == null)
                throw new ArgumentNullException("playField");

            if (gameRule == null)
                throw new ArgumentNullException("gameRule");

            _playField = playField;
            _gameRule = gameRule;
        }
 private static bool IsADrawRule(IGameRule rule)
 {
     try
     {
         ((GameIsADrawRule)rule).GetType();
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
        protected override void ExecuteUserCmd(PlayerEntity playerEntity, IUserCmd cmd)
        {
            playerEntity.stage.Value = GameRules.IsChicken(contexts.session.commonSession.RoomInfo.ModeId)
                ? EPlayerLoginStage.WaitStart
                : EPlayerLoginStage.Running;

            playerEntity.isInitialized      = true;
            playerEntity.gamePlay.CoverInit = true;
            FreeRuleEventArgs args = (FreeRuleEventArgs)contexts.session.commonSession.FreeArgs;
            IGameRule         rule = (IGameRule)args.Rule;

            rule.PlayerEnter(contexts, playerEntity);

            _logger.InfoFormat("PlayerEnter :{0}", playerEntity.entityKey);
        }
        public static void DoProcessPlayerHealthDamage(Contexts contexts, IGameRule gameRule, PlayerEntity srcPlayer,
                                                       PlayerEntity playerEntity, PlayerDamageInfo damage, IDamageInfoCollector damageInfoCollector)
        {
            List <PlayerEntity> teamList = OnePlayerHealthDamage(contexts, gameRule, srcPlayer, playerEntity, damage, damageInfoCollector, false);

            if (null != teamList)
            {
                //队友
                foreach (PlayerEntity other in teamList)
                {
                    PlayerDamageInfo damageInfo = new PlayerDamageInfo(other.gamePlay.InHurtedHp, (int)EUIDeadType.NoHelp, (int)EBodyPart.Chest, 0);
                    OnePlayerHealthDamage(contexts, gameRule, null, other, damageInfo, damageInfoCollector, true);
                }
            }
        }
Beispiel #8
0
        public void SetGameMode(int mode, int mapId)
        {
            _contexts.session.serverSessionObjects.GameRule = mode;
            _contexts.session.commonSession.RoomInfo.ModeId = mode;
            _contexts.session.commonSession.RoomInfo.MapId  = mapId;
            FreeRuleEventArgs args = new FreeRuleEventArgs(_contexts);

            _contexts.session.commonSession.FreeArgs = args;
            _rule = new FreeGameRule(this);

            RoomInfo info = _contexts.session.commonSession.RoomInfo;

            SimpleParaList spl = (SimpleParaList)args.GetDefault().GetParameters();

            spl.AddFields(new ObjectFields(info));
        }
Beispiel #9
0
        public void SetGameMode(int mode, int mapId)
        {
            ContextsWrapper.contexts.session.serverSessionObjects.GameRule = mode;
            ContextsWrapper.RoomInfo.ModeId = mode;
            ContextsWrapper.RoomInfo.MapId  = mapId;
            FreeRuleEventArgs args = new FreeRuleEventArgs(ContextsWrapper.contexts);

            ContextsWrapper.FreeArgs = args;
            rule = new FreeGameRule(this);


            SimpleParaList spl = (SimpleParaList)args.GetDefault().GetParameters();

            spl.AddFields(new ObjectFields(ContextsWrapper.RoomInfo));
            spl.AddPara(new BoolPara("hxMode", SharedConfig.IsHXMod));
            spl.AddPara(new StringPara("version", FreeRuleConfig.GetVersion()));
        }
Beispiel #10
0
        public static Enum.GameRule?GameRuleToEnum(IGameRule gameRule)
        {
            Enum.GameRule?ruleType = null;

            var ts = new TypeSwitch()
                     .Case((Age x) => ruleType              = Enum.GameRule.Age)
                     .Case((Boredom x) => ruleType          = Enum.GameRule.Boredom)
                     .Case((Hunger x) => ruleType           = Enum.GameRule.Hunger)
                     .Case((Sleep x) => ruleType            = Enum.GameRule.Sleep)
                     .Case((SleepDeprivation x) => ruleType = Enum.GameRule.SleepDeprevation)
                     .Case((Starvation x) => ruleType       = Enum.GameRule.Starvation)
                     .Case((Munchies x) => ruleType         = Enum.GameRule.Munchies)
                     .Case((Crazy x) => ruleType            = Enum.GameRule.Crazy);

            ts.Switch(gameRule);

            return(ruleType);
        }
Beispiel #11
0
        static public IGameRule CreateRuleInstance(int index)
        {
            TypeAssetPath assetPath = list.GetTypeAssetPath(index);

            if (assetPath.typeName.Length > 0)
            {
                IGameRule gameRule = (IGameRule)GetInstance(assetPath.DLLName, assetPath.typeName);
                if (gameRule != null)
                {
                    return(gameRule);
                }
                else
                {
                    Log.Write("Load GameRule error!");
                }
            }
            return(null);
        }
        public static void DoProcessPlayerHealthDamage(Contexts contexts, IPlayerDamager damager, PlayerEntity srcPlayer, PlayerEntity playerEntity, PlayerDamageInfo damage, IDamageInfoCollector damageInfoCollector)
        {
            IGameRule gameRule = null != damager ? damager.GameRule : null;

            DoProcessPlayerHealthDamage(contexts, gameRule, srcPlayer, playerEntity, damage, damageInfoCollector);
        }
        public static void ProcessDamageStatistics(Contexts contexts, IGameRule gameRule, PlayerEntity srcPlayer, PlayerEntity targetPlayer, PlayerDamageInfo damage)
        {
            if (null == targetPlayer)
            {
                return;
            }

            bool isTargetDead = targetPlayer.gamePlay.IsDead();

            if (isTargetDead)
            {
                targetPlayer.isFlagCompensation = false;
            }

            //攻击者
            if (null != srcPlayer)
            {
                bool isTeammate = srcPlayer.playerInfo.TeamId == targetPlayer.playerInfo.TeamId;

                bool isKill    = isTargetDead;
                bool isHitDown = targetPlayer.gamePlay.IsHitDown();
                bool isCrit    = damage.part == (int)EBodyPart.Head;



                targetPlayer.statisticsData.AddOtherInfo(srcPlayer.entityKey.Value, srcPlayer.WeaponController().HeldConfigId, isKill, isHitDown, damage.damage, srcPlayer.playerInfo, System.DateTime.Now.Ticks / 10000);

                //添加别人对自己的伤害记录(受伤不算)
                if (targetPlayer.gamePlay.IsLastLifeState(EPlayerLifeState.Alive) && !isTeammate)
                {
                    //添加自己对别人的伤害记录

                    srcPlayer.statisticsData.AddOpponentInfo(targetPlayer.entityKey.Value, srcPlayer.WeaponController().HeldConfigId, isKill, isHitDown, damage.damage, targetPlayer.playerInfo, targetPlayer.statisticsData.Statistics.DeadCount);
                    //总伤害量
                    srcPlayer.statisticsData.Statistics.TotalDamage += damage.damage;
                    //有效伤害
                    srcPlayer.statisticsData.Statistics.PlayerDamage += damage.damage;
                }

                if (isTargetDead)
                {
                    if (!isTeammate)
                    {
                        //击杀数
                        srcPlayer.statisticsData.Statistics.KillCount++;
                        srcPlayer.statisticsData.Statistics.LastKillTime = (int)DateTime.Now.Ticks / 10000;
                        //爆头击杀(不包括近战)
                        if (isCrit && !damage.IsKnife)
                        {
                            srcPlayer.statisticsData.Statistics.CritKillCount++;
                        }
                        //连杀数
                        srcPlayer.statisticsData.Statistics.EvenKillCount++;
                        if (srcPlayer.statisticsData.Statistics.EvenKillCount > srcPlayer.statisticsData.Statistics.MaxEvenKillCount)
                        {
                            srcPlayer.statisticsData.Statistics.MaxEvenKillCount = srcPlayer.statisticsData.Statistics.EvenKillCount;
                        }
                        //最大击杀距离
                        srcPlayer.statisticsData.Statistics.MaxKillDistance = Mathf.Max(srcPlayer.statisticsData.Statistics.MaxKillDistance,
                                                                                        UnityEngine.Vector3.Distance(srcPlayer.position.Value, targetPlayer.position.Value));
                        if (damage.WeaponType == EWeaponSubType.Pistol)
                        {
                            //手枪击杀
                            srcPlayer.statisticsData.Statistics.PistolKillCount++;
                        }
                        else if (damage.WeaponType == EWeaponSubType.Grenade)
                        {
                            //手雷击杀
                            srcPlayer.statisticsData.Statistics.GrenadeKillCount++;
                        }
                    }
                    else
                    {
                        //击杀队友
                        srcPlayer.statisticsData.Statistics.KillTeamCount++;
                    }
                }

                if (isHitDown && !isTeammate)
                {
                    //击倒数
                    srcPlayer.statisticsData.Statistics.HitDownCount++;
                }

                //总爆头数(不包括近战)
                if (isCrit && !damage.IsKnife && !isTeammate)
                {
                    srcPlayer.statisticsData.Statistics.CritCount++;
                }
            }

            //受击者
            //承受伤害量
            targetPlayer.statisticsData.Statistics.TotalBeDamage += damage.damage;
            if (isTargetDead)
            {
                //死亡次数
                targetPlayer.statisticsData.Statistics.DeadCount++;
                targetPlayer.statisticsData.Statistics.LastDeadTime = (int)DateTime.Now.Ticks / 10000;
                if (null == srcPlayer)
                {
                    targetPlayer.statisticsData.SetDeadType(damage.type);
                }
                else
                {
                    targetPlayer.statisticsData.AddKillerInfo(srcPlayer.entityKey.Value, srcPlayer.WeaponController().HeldConfigId, damage.type, srcPlayer.playerInfo);
                }
                if (SharedConfig.IsServer && null != gameRule)
                {
                    //死亡顺序(非自杀与队友击杀)
                    if (null != srcPlayer && srcPlayer.playerInfo.TeamId != targetPlayer.playerInfo.TeamId)
                    {
                        gameRule.Contexts.session.serverSessionObjects.DeathOrder++;
                        targetPlayer.statisticsData.Statistics.DeathOrder = gameRule.Contexts.session.serverSessionObjects.DeathOrder;
                    }
                    else
                    {
                        targetPlayer.statisticsData.Statistics.DeathOrder = -1;
                    }

                    //存活时间
                    IEventArgs args      = (IEventArgs)gameRule.Contexts.session.commonSession.FreeArgs;
                    int        startTime = FreeUtil.ReplaceInt("{startWaitTime}", args);
                    int        curTime   = FreeUtil.ReplaceInt("{serverTime}", args);
                    targetPlayer.statisticsData.Statistics.AliveTime = (int)((curTime - startTime) * 0.001f);
                    if (null != srcPlayer)
                    {
                        //一血
                        if (targetPlayer.statisticsData.Statistics.DeathOrder == 1)
                        {
                            srcPlayer.statisticsData.Statistics.GetFirstBlood = true;
                        }
                        //助攻数
                        foreach (var other in targetPlayer.statisticsData.Battle.OtherDict.Values)
                        {
                            if (other.PlayerKey == srcPlayer.entityKey.Value)
                            {
                                continue;
                            }
                            PlayerEntity otherEntity = gameRule.Contexts.player.GetEntityWithEntityKey(other.PlayerKey);
                            if (null != otherEntity && srcPlayer.playerInfo.TeamId == otherEntity.playerInfo.TeamId)
                            {
                                otherEntity.statisticsData.Statistics.AssistCount++;
                                if (System.DateTime.Now.Ticks / 10000 - other.timestamp <= 3000)
                                {
                                    int feedbackType = 0;
                                    feedbackType |= 1 << (int)EUIKillFeedbackType.Cooperate;
                                    SimpleProto message = FreePool.Allocate();
                                    message.Key = FreeMessageConstant.ScoreInfo;
                                    message.Ks.Add(3);
                                    message.Bs.Add(false);
                                    message.Ss.Add(FreeUtil.ReplaceVar(otherEntity.playerInfo.PlayerName, args));
                                    message.Ins.Add(0);
                                    message.Ins.Add(0);
                                    message.Ins.Add(feedbackType);
                                    FreeMessageSender.SendMessage(otherEntity, message);
                                }
                            }
                        }
                    }
                }

                //Send Message
                if (SharedConfig.IsServer)
                {
                    SendStatisticsMessage(targetPlayer);
                }
                else if (SharedConfig.IsOffline)
                {
                    targetPlayer.statisticsData.IsShow = true;
                }
            }
        }
Beispiel #14
0
        private static List <PlayerEntity> OnePlayerHealthDamage(Contexts contexts, IGameRule gameRule, PlayerEntity srcPlayer, PlayerEntity playerEntity, PlayerDamageInfo damage, IDamageInfoCollector damageInfoCollector, bool isTeam)
        {
            if (playerEntity.gamePlay.IsDead())
            {
                return(null);
            }

            if ((DateTime.Now.Ticks / 10000L) - playerEntity.statisticsData.Statistics.LastHitDownTime <= 1000 && !damage.InstantDeath)
            {
                return(null);
            }

            float curHp      = playerEntity.gamePlay.CurHp;
            float realDamage = damage.damage;

            if (gameRule != null)
            {
                realDamage = gameRule.HandleDamage(srcPlayer, playerEntity, damage);
            }
            if (null != damageInfoCollector)
            {
                damageInfoCollector.SetPlayerDamageInfo(srcPlayer, playerEntity, realDamage, (EBodyPart)damage.part);
            }
            if (!SharedConfig.IsOffline && !SharedConfig.IsServer)
            {
                return(null);
            }

            float ret = playerEntity.gamePlay.DecreaseHp(realDamage);

            _logger.InfoFormat("[hit] after CurrHp :" + playerEntity.gamePlay.CurHp);
            damage.damage = ret;

            //玩家状态
            List <PlayerEntity> teamList = CheckUpdatePlayerStatus(playerEntity, damage, !isTeam && gameRule != null ? gameRule.Contexts : null);

            //保存最后伤害来源
            StatisticsData statisticsData = playerEntity.statisticsData.Statistics;

            if (statisticsData.DataCollectSwitch)
            {
                if (playerEntity.gamePlay.IsLastLifeState(EPlayerLifeState.Alive))
                {
                    statisticsData.IsHited = true;
                    if (null != srcPlayer)
                    {
                        statisticsData.LastHurtKey = srcPlayer.entityKey.Value;
                    }
                    else
                    {
                        statisticsData.LastHurtKey = EntityKey.Default;
                    }
                    statisticsData.LastHurtType     = damage.type;
                    statisticsData.LastHurtPart     = damage.part;
                    statisticsData.LastHurtWeaponId = damage.weaponId;
                }

                //击倒人头
                if (statisticsData.IsHited && (damage.type == (int)EUIDeadType.NoHelp || damage.type == (int)EUIDeadType.Poison || damage.type == (int)EUIDeadType.Bomb ||
                                               damage.type == (int)EUIDeadType.Drown || damage.type == (int)EUIDeadType.Bombing || damage.type == (int)EUIDeadType.Fall))
                {
                    if (gameRule != null)
                    {
                        PlayerEntity lastEntity = gameRule.Contexts.player.GetEntityWithEntityKey(statisticsData.LastHurtKey);
                        if (null != lastEntity)
                        {
                            srcPlayer = lastEntity;
                            if (srcPlayer.playerInfo.TeamId == playerEntity.playerInfo.TeamId)
                            {
                                damage.type     = statisticsData.LastHurtType;
                                damage.part     = statisticsData.LastHurtPart;
                                damage.weaponId = statisticsData.LastHurtWeaponId;
                            }
                            else
                            {
                                damage.type = (int)EUIDeadType.NoHelp;
                            }
                        }
                    }
                }

                if (playerEntity.gamePlay.IsHitDown())
                {
                    statisticsData.LastHitDownTime = (DateTime.Now.Ticks / 10000L);
                    SimpleProto message = FreePool.Allocate();
                    message.Key = FreeMessageConstant.ScoreInfo;
                    int feedbackType = 0;
                    message.Ks.Add(3);
                    message.Bs.Add(true);
                    if (null != srcPlayer)
                    {
                        if (srcPlayer.playerInfo.TeamId != playerEntity.playerInfo.TeamId)
                        {
                            feedbackType |= 1 << (int)EUIKillFeedbackType.Hit;
                        }
                        message.Ss.Add(srcPlayer.playerInfo.PlayerName);
                        message.Ds.Add(srcPlayer.playerInfo.TeamId);
                        message.Ins.Add(damage.weaponId);
                    }
                    else
                    {
                        message.Ss.Add("");
                        message.Ds.Add(-1);
                        message.Ins.Add(0);
                    }
                    message.Ins.Add((int)EUIKillType.Hit);
                    message.Ins.Add(feedbackType);
                    message.Ss.Add(playerEntity.playerInfo.PlayerName);
                    message.Ds.Add(playerEntity.playerInfo.TeamId);
                    message.Ins.Add(damage.type);
                    SendMessageAction.sender.SendMessage(contexts.session.commonSession.FreeArgs as IEventArgs, message, 4, string.Empty);
                }

                if (playerEntity.gamePlay.IsDead())
                {
                    //UI击杀信息
                    int killType = 0;
                    if (damage.part == (int)EBodyPart.Head)
                    {
                        killType |= (int)EUIKillType.Crit;
                    }
                    damage.KillType = killType;
                    playerEntity.playerInfo.SpecialFeedbackType = 0;
                    //UI击杀反馈
                    if (null != srcPlayer && srcPlayer.playerInfo.TeamId != playerEntity.playerInfo.TeamId)
                    {
                        int feedbackType = 0;
                        if (damage.part == (int)EBodyPart.Head)
                        {
                            //爆头
                            feedbackType |= 1 << (int)EUIKillFeedbackType.CritKill;
                        }
                        if (damage.IsOverWall)
                        {
                            //穿墙击杀
                            feedbackType |= 1 << (int)EUIKillFeedbackType.ThroughWall;
                        }
                        if (SharedConfig.IsServer && null != gameRule && gameRule.Contexts.session.serverSessionObjects.DeathOrder == 0 && srcPlayer.playerInfo.TeamId != playerEntity.playerInfo.TeamId)
                        {
                            //一血
                            feedbackType |= 1 << (int)EUIKillFeedbackType.FirstBlood;
                        }
                        if (playerEntity.playerInfo.PlayerId == srcPlayer.statisticsData.Statistics.RevengeKillerId)
                        {
                            //复仇
                            feedbackType |= 1 << (int)EUIKillFeedbackType.Revenge;
                            srcPlayer.statisticsData.Statistics.RevengeKillerId = 0L;
                        }
                        if (srcPlayer.playerInfo.JobAttribute == (int)EJobAttribute.EJob_Hero)
                        {
                            //英雄击杀
                            feedbackType |= 1 << (int)EUIKillFeedbackType.HeroKO;
                            playerEntity.playerInfo.SpecialFeedbackType = (int)EUIKillFeedbackType.HeroKO;
                        }
                        //武器
                        WeaponResConfigItem newConfig = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(damage.weaponId);
                        if (null != newConfig)
                        {
                            if (newConfig.SubType == (int)EWeaponSubType.Melee)
                            {
                                feedbackType |= 1 << (int)EUIKillFeedbackType.MeleeWeapon;
                                playerEntity.playerInfo.SpecialFeedbackType = (int)EUIKillFeedbackType.MeleeWeapon;
                            }
                            else if (newConfig.SubType == (int)EWeaponSubType.BurnBomb)
                            {
                                feedbackType |= 1 << (int)EUIKillFeedbackType.Burning;
                            }
                            else if (newConfig.SubType == (int)EWeaponSubType.Grenade)
                            {
                                feedbackType |= 1 << (int)EUIKillFeedbackType.Grenade;
                            }
                        }
                        if (feedbackType == 0)
                        {
                            //普通击杀
                            feedbackType = 1 << (int)EUIKillFeedbackType.Normal;
                        }
                        damage.KillFeedbackType = feedbackType;
                    }
                }

                //数据统计
                ProcessDamageStatistics(contexts, gameRule, srcPlayer, playerEntity, damage);
            }

            //击杀|击倒
            if (null != gameRule && playerEntity.gamePlay.IsDead())
            {
                gameRule.KillPlayer(srcPlayer, playerEntity, damage);
            }

            _logger.DebugFormat("change player hp entityId:{0}, health {1}->{2}, state {3}, srcPlayerId:{4}, playerId:{5}, hurtType:{6}, weaponId:{7}", playerEntity.entityKey.Value.EntityId, curHp, playerEntity.gamePlay.CurHp, playerEntity.gamePlay.LifeState, (srcPlayer != null) ? srcPlayer.playerInfo.PlayerId : 0, playerEntity.playerInfo.PlayerId, damage.type, damage.weaponId);

            return(teamList);
        }
Beispiel #15
0
 void Initialize()
 {
     GameRule      = new TimeGameRule(DEFAULT_TIME);
     SelectedStage = StageType.BATTLE_FIELD;
 }
        private static List <PlayerEntity> OnePlayerHealthDamage(Contexts contexts, IGameRule gameRule, PlayerEntity srcPlayer, PlayerEntity playerEntity, PlayerDamageInfo damage, bool isTeam)
        {
            GamePlayComponent gamePlay = playerEntity.gamePlay;

            if (gamePlay.IsDead())
            {
                return(null);
            }

            float realDamage = gameRule == null ? damage.damage : gameRule.HandleDamage(srcPlayer, playerEntity, damage);

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

            if (srcPlayer != null)
            {
                try
                {
                    //受伤梯形标记
                    if (SharedConfig.IsServer)
                    {
                        if (damage.type == (int)EUIDeadType.Weapon || damage.type == (int)EUIDeadType.Unarmed)
                        {
                            if (weaponConfig != null && weaponConfig.SubType != (int)EWeaponSubType.Grenade)
                            {
                                BulletStatisticsUtil.SetPlayerDamageInfoS(srcPlayer, playerEntity, realDamage, (EBodyPart)damage.part);
                            }
                        }
                    }
                    else
                    {
                        BulletStatisticsUtil.SetPlayerDamageInfoC(srcPlayer, playerEntity, realDamage, (EBodyPart)damage.part);
                    }
                }
                catch (Exception e)
                {
                    _logger.Error("受伤梯形标记", e);
                }
            }

            if (!SharedConfig.IsOffline && !SharedConfig.IsServer)
            {
                return(null);
            }

            if (!playerEntity.hasStatisticsData)
            {
                return(null);
            }

            StatisticsData statisticsData = playerEntity.statisticsData.Statistics;


            var now = gameRule == null ? playerEntity.time.ClientTime : gameRule.ServerTime;

            if (now - statisticsData.LastHitDownTime <= 1000 && !damage.InstantDeath)
            {
                return(null);
            }

            damage.damage = gamePlay.DecreaseHp(realDamage);

            //玩家状态
            List <PlayerEntity> teamList = CheckUpdatePlayerStatus(playerEntity, damage, isTeam ? null : contexts, (int)now);

            //保存最后伤害来源
            if (statisticsData.DataCollectSwitch)
            {
                try
                {
                    if (gamePlay.IsLastLifeState(EPlayerLifeState.Alive))
                    {
                        //statisticsData.IsHited = true;
                        statisticsData.LastHurtKey      = null != srcPlayer ? srcPlayer.entityKey.Value : EntityKey.Default;
                        statisticsData.LastHurtType     = damage.type;
                        statisticsData.LastHurtPart     = damage.part;
                        statisticsData.LastHurtWeaponId = damage.weaponId;
                    }

                    //击倒人头
                    if ((gamePlay.IsLifeState(EPlayerLifeState.Dying) || gamePlay.IsDead()) &&
                        (damage.type == (int)EUIDeadType.NoHelp || damage.type == (int)EUIDeadType.Poison || damage.type == (int)EUIDeadType.Bomb ||
                         damage.type == (int)EUIDeadType.Drown || damage.type == (int)EUIDeadType.Bombing || damage.type == (int)EUIDeadType.Fall))
                    {
                        PlayerEntity lastEntity = contexts.player.GetEntityWithEntityKey(statisticsData.LastHurtKey);
                        if (null != lastEntity)
                        {
                            srcPlayer = lastEntity;
                            if (srcPlayer.playerInfo.TeamId == playerEntity.playerInfo.TeamId)
                            {
                                damage.type     = statisticsData.LastHurtType;
                                damage.part     = statisticsData.LastHurtPart;
                                damage.weaponId = statisticsData.LastHurtWeaponId;
                            }
                            else
                            {
                                damage.type = (int)EUIDeadType.NoHelp;
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    _logger.Error("计算玩家战报信息失败", e);
                }

                if (gamePlay.IsHitDown())
                {
                    try
                    {
                        statisticsData.LastHitDownTime = now;
                        SimpleProto message = FreePool.Allocate();
                        message.Key = FreeMessageConstant.ScoreInfo;
                        int feedbackType = 0;
                        message.Ks.Add(3);
                        message.Bs.Add(true);
                        if (null != srcPlayer)
                        {
                            if (srcPlayer.playerInfo.TeamId != playerEntity.playerInfo.TeamId)
                            {
                                feedbackType |= 1 << (int)EUIKillFeedbackType.Hit;
                            }
                            message.Ss.Add(srcPlayer.playerInfo.PlayerName);
                            message.Ds.Add(srcPlayer.playerInfo.TeamId);
                            message.Ins.Add(damage.weaponId);
                        }
                        else
                        {
                            message.Ss.Add("");
                            message.Ds.Add(-1);
                            message.Ins.Add(0);
                        }
                        message.Ins.Add((int)EUIKillType.Hit);
                        message.Ins.Add(feedbackType);
                        message.Ss.Add(playerEntity.playerInfo.PlayerName);
                        message.Ds.Add(playerEntity.playerInfo.TeamId);
                        message.Ins.Add(damage.type);
                        SendMessageAction.sender.SendMessage(contexts.session.commonSession.FreeArgs as IEventArgs, message, 4, string.Empty);
                    }
                    catch (Exception e)
                    {
                        _logger.Error("计算玩家ScoreInfo信息失败", e);
                    }
                }

                if (gamePlay.IsDead())
                {
                    try
                    {
                        //UI击杀信息
                        int killType = 0;
                        if (damage.part == (int)EBodyPart.Head)
                        {
                            killType |= (int)EUIKillType.Crit;
                        }
                        damage.KillType = killType;
                        playerEntity.playerInfo.SpecialFeedbackType = 0;
                        //UI击杀反馈
                        if (null != srcPlayer && srcPlayer.playerInfo.TeamId != playerEntity.playerInfo.TeamId)
                        {
                            int feedbackType = 0;
                            if (damage.part == (int)EBodyPart.Head)
                            {
                                //爆头
                                feedbackType |= 1 << (int)EUIKillFeedbackType.CritKill;
                            }
                            if (damage.IsOverWall)
                            {
                                //穿墙击杀
                                feedbackType |= 1 << (int)EUIKillFeedbackType.ThroughWall;
                            }
                            if (SharedConfig.IsServer && null != gameRule && contexts.session.serverSessionObjects.DeathOrder == 0 && srcPlayer.playerInfo.TeamId != playerEntity.playerInfo.TeamId)
                            {
                                //一血
                                feedbackType |= 1 << (int)EUIKillFeedbackType.FirstBlood;
                            }
                            if (playerEntity.playerInfo.PlayerId == srcPlayer.statisticsData.Statistics.RevengeKillerId)
                            {
                                //复仇
                                feedbackType |= 1 << (int)EUIKillFeedbackType.Revenge;
                                srcPlayer.statisticsData.Statistics.RevengeKillerId = 0L;
                            }
                            if (srcPlayer.gamePlay.JobAttribute == (int)EJobAttribute.EJob_Hero)
                            {
                                //英雄击杀
                                feedbackType |= 1 << (int)EUIKillFeedbackType.HeroKO;
                                playerEntity.playerInfo.SpecialFeedbackType = (int)EUIKillFeedbackType.HeroKO;
                            }
                            //武器
                            if (null != weaponConfig)
                            {
                                switch ((EWeaponSubType)weaponConfig.SubType)
                                {
                                case EWeaponSubType.Melee:
                                    feedbackType |= 1 << (int)EUIKillFeedbackType.MeleeWeapon;
                                    playerEntity.playerInfo.SpecialFeedbackType = (int)EUIKillFeedbackType.MeleeWeapon;
                                    break;

                                case EWeaponSubType.BurnBomb:
                                    feedbackType |= 1 << (int)EUIKillFeedbackType.Burning;
                                    break;

                                case EWeaponSubType.Grenade:
                                    feedbackType |= 1 << (int)EUIKillFeedbackType.Grenade;
                                    break;

                                default:
                                    break;
                                }
                            }
                            if (feedbackType == 0)
                            {
                                //普通击杀
                                feedbackType = 1 << (int)EUIKillFeedbackType.Normal;
                            }
                            damage.KillFeedbackType = feedbackType;
                        }
                    }
                    catch (Exception e)
                    {
                        _logger.Error("计算玩家战报信息失败", e);
                    }
                }

                //数据统计
                ProcessDamageStatistics(contexts, gameRule, srcPlayer, playerEntity, damage);
            }

            //击杀|击倒
            if (gamePlay.IsDead())
            {
                gameRule.KillPlayer(srcPlayer, playerEntity, damage);
                try
                {
                    if (damage.HitPoint != Vector3.zero && damage.HitDirection != Vector3.zero && playerEntity.hasRagDoll)
                    {
                        playerEntity.ragDoll.ForceAtPosition = Vector3.zero;
                        switch (damage.type)
                        {
                        case (int)EUIDeadType.Weapon:
                            var config = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(damage.weaponId);
                            if (weaponConfig.Type == (int)EWeaponType_Config.ThrowWeapon)
                            {
                                playerEntity.ragDoll.RigidBodyTransformName = "Bip01 Spine1";
                                playerEntity.ragDoll.Impulse = (damage.HitDirection.normalized + new Vector3(0, 1.732f)).normalized *
                                                               config.S_Ragdoll.RagdollForce * DamageFactor(realDamage);
                            }
                            else
                            {
                                foreach (var pair in Joint2BodyPart)
                                {
                                    if (pair.Value == (EBodyPart)damage.part)
                                    {
                                        playerEntity.ragDoll.RigidBodyTransformName = pair.Key.Substring(0, pair.Key.LastIndexOf("_"));
                                        break;
                                    }
                                }

                                playerEntity.ragDoll.Impulse = damage.HitDirection.normalized * config.S_Ragdoll.RagdollForce *
                                                               DamageFactor(realDamage);
                            }

                            break;

                        default:
                            var explosionConfig = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(46);
                            playerEntity.ragDoll.RigidBodyTransformName = "Bip01 Spine1";
                            playerEntity.ragDoll.Impulse = (damage.HitDirection.normalized + new Vector3(0, 1.732f)).normalized *
                                                           explosionConfig.S_Ragdoll.RagdollForce * DamageFactor(realDamage);
                            break;
                        }
                    }
                }
                catch (Exception e)
                {
                    _logger.Error("计算玩家死亡ragdoll运动信息失败", e);
                }
            }

            //_logger.DebugFormat("change player hp entityId:{0}, health {1}->{2}, state {3}, srcPlayerId:{4}, playerId:{5}, hurtType:{6}, weaponId:{7}",
            //    playerEntity.entityKey.Value.EntityId, playerEntity.gamePlay.CurHp, playerEntity.gamePlay.CurHp, playerEntity.gamePlay.LifeState, (srcPlayer != null) ? srcPlayer.playerInfo.PlayerId : 0, playerEntity.playerInfo.PlayerId, damage.type, damage.weaponId);
            return(teamList);
        }
Beispiel #17
0
 public void Reset()
 {
     GameRule      = new TimeGameRule(5);
     SelectedStage = StageType.BATTLE_FIELD;
 }
        private static List <PlayerEntity> OnePlayerHealthDamage(Contexts contexts, IGameRule gameRule, PlayerEntity srcPlayer, PlayerEntity playerEntity, PlayerDamageInfo damage, IDamageInfoCollector damageInfoCollector, bool isTeam)
        {
            if (playerEntity.gamePlay.IsDead())
            {
                return(null);
            }

            float curHp      = playerEntity.gamePlay.CurHp;
            float realDamage = damage.damage;

            if (gameRule != null)
            {
                realDamage = gameRule.HandleDamage(srcPlayer, playerEntity, damage);
            }
            if (null != damageInfoCollector)
            {
                damageInfoCollector.SetPlayerDamageInfo(srcPlayer, playerEntity, realDamage, (EBodyPart)damage.part);
            }
            if (!SharedConfig.IsOffline && !SharedConfig.IsServer)
            {
                return(null);
            }

            float ret = playerEntity.gamePlay.DecreaseHp(realDamage);

            damage.damage = ret;

            //玩家状态
            List <PlayerEntity> teamList = CheckUpdatePlayerStatus(playerEntity, damage, !isTeam && gameRule != null ? gameRule.Contexts : null);

            //保存最后伤害来源
            StatisticsData statisticsData = playerEntity.statisticsData.Statistics;

            if (statisticsData.DataCollectSwitch)
            {
                if (playerEntity.gamePlay.IsLastLifeState(EPlayerLifeState.Alive))
                {
                    statisticsData.IsHited = true;
                    if (null != srcPlayer)
                    {
                        statisticsData.LastHurtKey = srcPlayer.entityKey.Value;
                    }
                    else
                    {
                        statisticsData.LastHurtKey = EntityKey.Default;
                    }
                    statisticsData.LastHurtType     = damage.type;
                    statisticsData.LastHurtPart     = damage.part;
                    statisticsData.LastHurtWeaponId = damage.weaponId;
                }

                //谁击倒算谁的人头
                if (statisticsData.IsHited)
                {
                    if (gameRule != null)
                    {
                        PlayerEntity lastEntity = gameRule.Contexts.player.GetEntityWithEntityKey(statisticsData.LastHurtKey);
                        if (null != lastEntity)
                        {
                            srcPlayer = lastEntity;
                        }
                    }
                    damage.type     = statisticsData.LastHurtType;
                    damage.part     = statisticsData.LastHurtPart;
                    damage.weaponId = statisticsData.LastHurtWeaponId;
                }

                if (playerEntity.gamePlay.IsDead())
                {
                    //UI击杀信息
                    int killType = 0;
                    if (damage.part == (int)EBodyPart.Head)
                    {
                        killType |= (int)EUIKillType.Crit;
                    }
                    if (playerEntity.gamePlay.IsHitDown())
                    {
                        killType |= (int)EUIKillType.Hit;
                    }
                    damage.KillType = killType;
                    //UI击杀反馈
                    if (null != srcPlayer && srcPlayer.playerInfo.TeamId != playerEntity.playerInfo.TeamId)
                    {
                        int feedbackType = 0;
                        if (damage.part == (int)EBodyPart.Head)
                        {
                            //爆头
                            feedbackType |= 1 << (int)EUIKillFeedbackType.CritKill;
                        }
                        if (damage.IsOverWall)
                        {
                            //穿墙击杀
                            feedbackType |= 1 << (int)EUIKillFeedbackType.ThroughWall;
                        }
                        if (SharedConfig.IsServer && null != gameRule && gameRule.Contexts.session.serverSessionObjects.DeathOrder == 0 && srcPlayer.playerInfo.TeamId != playerEntity.playerInfo.TeamId)
                        {
                            //一血
                            feedbackType |= 1 << (int)EUIKillFeedbackType.FirstBlood;
                        }
                        if (playerEntity.playerInfo.PlayerId == srcPlayer.statisticsData.Statistics.RevengeKillerId)
                        {
                            //复仇
                            feedbackType |= 1 << (int)EUIKillFeedbackType.Revenge;
                            srcPlayer.statisticsData.Statistics.RevengeKillerId = 0L;
                        }
                        //武器
                        WeaponResConfigItem newConfig = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(damage.weaponId);
                        if (null != newConfig)
                        {
                            if (newConfig.SubType == (int)EWeaponSubType.Melee)
                            {
                                feedbackType |= 1 << (int)EUIKillFeedbackType.MeleeWeapon;
                            }
                            else if (newConfig.SubType == (int)EWeaponSubType.BurnBomb)
                            {
                                feedbackType |= 1 << (int)EUIKillFeedbackType.Burning;
                            }
                            else if (newConfig.SubType == (int)EWeaponSubType.Grenade)
                            {
                                feedbackType |= 1 << (int)EUIKillFeedbackType.Grenade;
                            }
                        }
                        if (feedbackType == 0)
                        {
                            //普通击杀
                            feedbackType = 1 << (int)EUIKillFeedbackType.Normal;
                        }
                        damage.KillFeedbackType = feedbackType;
                    }
                }

                //数据统计
                ProcessDamageStatistics(contexts, gameRule, srcPlayer, playerEntity, damage);
            }

            //击杀|击倒
            if (null != gameRule && playerEntity.gamePlay.IsDead())
            {
                gameRule.KillPlayer(srcPlayer, playerEntity, damage);
            }

            _logger.DebugFormat("change player hp entityId:{0}, health {1}->{2}, state {3}, srcPlayerId:{4}, playerId:{5}, hurtType:{6}, weaponId:{7}", playerEntity.entityKey.Value.EntityId, curHp, playerEntity.gamePlay.CurHp, playerEntity.gamePlay.LifeState, (srcPlayer != null) ? srcPlayer.playerInfo.PlayerId : 0, playerEntity.playerInfo.PlayerId, damage.type, damage.weaponId);

            return(teamList);
        }
 void InitializeGameRule()
 {
     interval = CHECK_WINNER_INTERVAL;
     gameRule = GameStateManager.instance.GameRule;
     EventManager.instance.StartListeningToOnGameOverEvent(new UnityAction(OnGameOver));
 }
Beispiel #20
0
        public static void ProcessDamageStatistics(IGameRule gameRule, PlayerEntity srcPlayer, PlayerEntity targetPlayer, PlayerDamageInfo damage)
        {
            if (null == targetPlayer)
            {
                return;
            }

            bool isTargetDead = targetPlayer.gamePlay.IsDead();

            if (isTargetDead)
            {
                targetPlayer.isFlagCompensation = false;
            }

            //攻击者
            if (null != srcPlayer)
            {
                bool isTeammate = srcPlayer.playerInfo.TeamId == targetPlayer.playerInfo.TeamId;
                if (isTeammate)
                {
                    return;
                }
                bool isKill    = isTargetDead;
                bool isHitDown = targetPlayer.gamePlay.IsHitDown();
                bool isCrit    = damage.part == (int)EBodyPart.Head;

                //总伤害量
                srcPlayer.statisticsData.Statistics.TotalDamage += damage.damage;

                //添加自己对别人的伤害记录
                srcPlayer.statisticsData.AddOpponentInfo(targetPlayer.entityKey.Value, srcPlayer.weaponLogicInfo.WeaponId, isKill, isHitDown, (int)damage.damage, targetPlayer.playerInfo);
                //添加别人对自己的伤害记录(受伤不算)
                if (targetPlayer.gamePlay.IsLastLifeState(EPlayerLifeState.Alive))
                {
                    targetPlayer.statisticsData.AddOtherInfo(srcPlayer.entityKey.Value, srcPlayer.weaponLogicInfo.WeaponId, isKill, isHitDown, (int)damage.damage, srcPlayer.playerInfo);
                    //有效伤害
                    srcPlayer.statisticsData.Statistics.PlayerDamage += damage.damage;
                }

                if (isTargetDead)
                {
                    if (srcPlayer.playerInfo.TeamId != targetPlayer.playerInfo.TeamId)
                    {
                        //击杀数
                        srcPlayer.statisticsData.Statistics.KillCount++;
                        srcPlayer.statisticsData.Statistics.LastKillTime = DateTime.Now.Millisecond;
                        if (isCrit)
                        {
                            srcPlayer.statisticsData.Statistics.CritKillCount++;
                        }
                        //连杀数(吃鸡模式)
                        srcPlayer.statisticsData.Statistics.EvenKillCount++;
                    }
                    else
                    {
                        //击杀队友
                        srcPlayer.statisticsData.Statistics.KillTeamCount++;
                    }
                    //最大击杀距离
                    srcPlayer.statisticsData.Statistics.MaxKillDistance = Mathf.Max(srcPlayer.statisticsData.Statistics.MaxKillDistance,
                                                                                    UnityEngine.Vector3.Distance(srcPlayer.position.Value, targetPlayer.position.Value));
                    if (damage.WeaponType == EWeaponSubType.Pistol)
                    {
                        //手枪击杀
                        srcPlayer.statisticsData.Statistics.PistolKillCount++;
                    }
                    else if (damage.WeaponType == EWeaponSubType.Grenade)
                    {
                        //手雷击杀
                        srcPlayer.statisticsData.Statistics.GrenadeKillCount++;
                    }
                }
                if (isHitDown)
                {
                    //击倒数
                    srcPlayer.statisticsData.Statistics.HitDownCount++;
                }
                if (isCrit)
                {
                    //总爆头数
                    srcPlayer.statisticsData.Statistics.CritCount++;
                }
            }

            //受击者
            //承受伤害量
            targetPlayer.statisticsData.Statistics.TotalBeDamage += damage.damage;
            if (isTargetDead)
            {
                //死亡次数
                targetPlayer.statisticsData.Statistics.DeadCount++;
                targetPlayer.statisticsData.Statistics.LastDeadTime = DateTime.Now.Millisecond;
                if (null == srcPlayer)
                {
                    targetPlayer.statisticsData.SetDeadType(damage.type);
                }
                else
                {
                    targetPlayer.statisticsData.AddKillerInfo(srcPlayer.entityKey.Value, srcPlayer.weaponLogicInfo.WeaponId, damage.type, srcPlayer.playerInfo);
                }
                if (SharedConfig.IsServer && null != gameRule)
                {
                    //死亡顺序
                    gameRule.Contexts.session.serverSessionObjects.DeathOrder++;
                    targetPlayer.statisticsData.Statistics.DeathOrder = gameRule.Contexts.session.serverSessionObjects.DeathOrder;
                    //存活时间
                    IEventArgs args      = (IEventArgs)gameRule.Contexts.session.commonSession.FreeArgs;
                    int        startTime = FreeUtil.ReplaceInt("{startWaitTime}", args);
                    int        curTime   = FreeUtil.ReplaceInt("{serverTime}", args);
                    targetPlayer.statisticsData.Statistics.AliveTime = (int)((curTime - startTime) * 0.001f);
                    if (null != srcPlayer)
                    {
                        //一血
                        if (targetPlayer.statisticsData.Statistics.DeathOrder == 1)
                        {
                            srcPlayer.statisticsData.Statistics.GetFirstBlood = true;
                        }
                        //助攻数
                        foreach (var other in targetPlayer.statisticsData.Battle.OtherDict.Values)
                        {
                            if (other.PlayerKey == srcPlayer.entityKey.Value)
                            {
                                continue;
                            }
                            PlayerEntity otherEntity = gameRule.Contexts.player.GetEntityWithEntityKey(other.PlayerKey);
                            if (null != otherEntity && srcPlayer.playerInfo.TeamId == otherEntity.playerInfo.TeamId)
                            {
                                //TODO 修改助攻的计算方式
                                otherEntity.statisticsData.Statistics.AssistCount++;
                            }
                        }
                    }
                }

                //Send Message
                if (SharedConfig.IsServer)
                {
                    SendStatisticsMessage(targetPlayer);
                }
                else if (SharedConfig.IsOffline)
                {
                    targetPlayer.statisticsData.IsShow = true;
                }
            }
        }
        public static void ProcessDamageStatistics(Contexts contexts, IGameRule gameRule, PlayerEntity srcPlayer, PlayerEntity targetPlayer, PlayerDamageInfo damage)
        {
            if (null == targetPlayer)
            {
                return;
            }

            bool isTargetDead = targetPlayer.gamePlay.IsDead();

            if (isTargetDead)
            {
                targetPlayer.isFlagCompensation = false;
                targetPlayer.AudioController().PlayDeadAudio();
            }

            var now = gameRule == null ? targetPlayer.time.ClientTime : gameRule.ServerTime;

            //攻击者
            if (null != srcPlayer)
            {
                bool isTeammate = srcPlayer.playerInfo.TeamId == targetPlayer.playerInfo.TeamId;

                bool isKill    = isTargetDead;
                bool isHitDown = targetPlayer.gamePlay.IsHitDown();
                bool isCrit    = damage.part == (int)EBodyPart.Head;
                var  srcStat   = srcPlayer.statisticsData.Statistics;

                targetPlayer.statisticsData.AddOtherInfo(srcPlayer.entityKey.Value, damage.weaponId, isKill, isHitDown, damage.damage, srcPlayer.playerInfo, now);

                //添加别人对自己的伤害记录(受伤不算)
                if (targetPlayer.gamePlay.IsLastLifeState(EPlayerLifeState.Alive) && !isTeammate)
                {
                    //添加自己对别人的伤害记录
                    srcPlayer.statisticsData.AddOpponentInfo(targetPlayer.entityKey.Value, damage.weaponId, isKill, isHitDown, damage.damage, targetPlayer.playerInfo, targetPlayer.statisticsData.Statistics.DeadCount);
                    //总伤害量
                    srcStat.TotalDamage += damage.damage;
                    //有效伤害
                    srcStat.PlayerDamage += damage.damage;
                }

                if (isTargetDead)
                {
                    if (!isTeammate)
                    {
                        //击杀数
                        srcStat.KillCount++;
                        srcStat.LastKillTime = now;
                        //爆头击杀(不包括近战)
                        if (isCrit && !damage.IsKnife)
                        {
                            srcStat.CritKillCount++;
                        }

                        //连杀数
                        srcStat.EvenKillCount++;
                        if (srcStat.EvenKillCount > srcStat.MaxEvenKillCount)
                        {
                            srcStat.MaxEvenKillCount = srcStat.EvenKillCount;
                        }

                        //最大击杀距离
                        srcStat.MaxKillDistance = Mathf.Max(srcStat.MaxKillDistance, Vector3.Distance(srcPlayer.position.Value, targetPlayer.position.Value));

                        if (damage.WeaponType == EWeaponSubType.Pistol)
                        {
                            srcStat.PistolKillCount++;                                             //手枪击杀
                        }
                        else if (damage.WeaponType == EWeaponSubType.Grenade)
                        {
                            srcStat.GrenadeKillCount++;                                                  //手雷击杀
                        }
                        if (targetPlayer.gamePlay.IsLastLifeState(EPlayerLifeState.Alive))
                        {
                            srcStat.HitDownCount++;
                        }
                    }
                    else
                    {
                        srcStat.KillTeamCount++;//击杀队友
                    }
                }

                //击倒数
                if (isHitDown && !isTeammate)
                {
                    srcStat.HitDownCount++;
                }

                //总爆头数(不包括近战)
                if (isCrit && !damage.IsKnife && !isTeammate)
                {
                    srcStat.CritCount++;
                }
            }

            //受击者
            var tarStat = targetPlayer.statisticsData.Statistics;

            //承受伤害量
            tarStat.TotalBeDamage += damage.damage;
            if (isTargetDead)
            {
                //死亡次数
                tarStat.DeadCount++;
                tarStat.LastDeadTime = now;
                if (null == srcPlayer)
                {
                    targetPlayer.statisticsData.SetDeadType(damage.type);
                }
                else
                {
                    targetPlayer.statisticsData.AddKillerInfo(srcPlayer.entityKey.Value, damage.weaponId, damage.type, srcPlayer.playerInfo);
                    //tarStat.AliveTime = (int)(gameRule.ServerTime - gameRule.GameStartTime) / 1000;
                    if (srcPlayer.playerInfo.TeamId != targetPlayer.playerInfo.TeamId)
                    {
                        contexts.session.serverSessionObjects.DeathOrder++;
                        tarStat.DeathOrder = contexts.session.serverSessionObjects.DeathOrder;
                        if (tarStat.DeathOrder == 1)
                        {
                            srcPlayer.statisticsData.Statistics.GetFirstBlood = true;
                        }
                    }
                    else
                    {
                        tarStat.DeathOrder = -1;
                    }
                }

                foreach (var other in targetPlayer.statisticsData.Battle.OtherDict.Values)
                {
                    PlayerEntity otherEntity = contexts.player.GetEntityWithEntityKey(other.PlayerKey);
                    if (null != otherEntity)
                    {
                        if (otherEntity.playerInfo.TeamId == targetPlayer.playerInfo.TeamId)
                        {
                            continue;
                        }

                        bool assistFlag = false;
                        if (null == srcPlayer)
                        {
                            if (now - other.timestamp <= 10000)
                            {
                                assistFlag = true;
                            }
                        }
                        else
                        {
                            if (other.PlayerKey == srcPlayer.entityKey.Value)
                            {
                                continue;
                            }

                            if (srcPlayer.playerInfo.TeamId == otherEntity.playerInfo.TeamId)
                            {
                                if (now - other.timestamp <= 10000)
                                {
                                    assistFlag = true;
                                }
                            }
                        }

                        if (assistFlag)
                        {
                            otherEntity.statisticsData.Statistics.AssistCount++;
                            int feedbackType = 0;
                            feedbackType |= 1 << (int)EUIKillFeedbackType.Cooperate;
                            SimpleProto message = FreePool.Allocate();
                            message.Key = FreeMessageConstant.ScoreInfo;
                            message.Ks.Add(3);
                            message.Bs.Add(false);
                            message.Ss.Add(otherEntity.playerInfo.PlayerName);
                            message.Ins.Add(0);
                            message.Ins.Add(0);
                            message.Ins.Add(feedbackType);
                            FreeMessageSender.SendMessage(otherEntity, message);
                        }
                    }
                }

                //Send Message
                if (SharedConfig.IsServer)
                {
                    SendStatisticsMessage(targetPlayer);
                }
                else if (SharedConfig.IsOffline)
                {
                    targetPlayer.statisticsData.IsShow = true;
                }
            }
        }
Beispiel #22
0
 public void SetUp()
 {
     _board            = new GameBoard();
     _gameStatus       = new GameStatus(_board);
     _gameRulesService = new GameRuleService(_gameStatus);
 }