private static List <PlayerEntity> CheckUpdatePlayerStatus(PlayerEntity player, PlayerDamageInfo damage, Contexts contexts) { GamePlayComponent gamePlay = player.gamePlay; if (gamePlay.IsLifeState(EPlayerLifeState.Alive)) { if (gamePlay.CurHp <= 0) { //存活队友 int aliveCount = 0; //存活队伍 HashSet <long> aliveTeams = new HashSet <long>(); if (null != contexts) { foreach (PlayerEntity other in contexts.player.GetEntities()) { if (other.hasPlayerInfo && other != player && other.gamePlay.IsLifeState(EPlayerLifeState.Alive)) { aliveTeams.Add(other.playerInfo.TeamId); if (other.playerInfo.TeamId == player.playerInfo.TeamId) { aliveCount++; } } } } if (damage.type == (int)EUIDeadType.Drown || /*|| damage.type == (int) EUIDeadType.VehicleBomb*/ player.stateInterface.State.GetCurrentPostureState() == PostureInConfig.Swim || player.stateInterface.State.GetCurrentPostureState() == PostureInConfig.Dive) { //直接死亡 gamePlay.ChangeLifeState(EPlayerLifeState.Dead, player.time.ClientTime); } else if (aliveCount == 0) { //自己 gamePlay.ChangeLifeState(EPlayerLifeState.Dead, player.time.ClientTime); //全队阵亡 if (null != contexts) { List <PlayerEntity> teamList = new List <PlayerEntity>(); foreach (PlayerEntity other in contexts.player.GetEntities()) { if (other.hasPlayerInfo && other != player && other.playerInfo.TeamId == player.playerInfo.TeamId && other.gamePlay.IsLifeState(EPlayerLifeState.Dying)) { teamList.Add(other); } } return(teamList); } } else if (GetTeamCapacity(contexts) > 1 && aliveTeams.Count > 1) { //受伤状态 gamePlay.ChangeLifeState(EPlayerLifeState.Dying, player.time.ClientTime); } else { gamePlay.ChangeLifeState(EPlayerLifeState.Dead, player.time.ClientTime); } } } else if (gamePlay.IsLifeState(EPlayerLifeState.Dying)) { if (gamePlay.InHurtedHp <= 0) { gamePlay.ChangeLifeState(EPlayerLifeState.Dead, player.time.ClientTime); } else { int aliveCount = 0; if (null != contexts) { foreach (PlayerEntity other in contexts.player.GetEntities()) { if (other.hasPlayerInfo && other != player && other.gamePlay.IsLifeState(EPlayerLifeState.Alive) && other.playerInfo.TeamId == player.playerInfo.TeamId) { aliveCount++; } } } if (aliveCount == 0) { gamePlay.ChangeLifeState(EPlayerLifeState.Dead, player.time.ClientTime); } } } return(null); }
private static List <PlayerEntity> CheckUpdatePlayerStatus(PlayerEntity player, PlayerDamageInfo damage, Contexts contexts, int now) { GamePlayComponent gamePlay = player.gamePlay; if (contexts == null && damage.InstantDeath) { gamePlay.ChangeLifeState(EPlayerLifeState.Dead, now); return(null); } if (contexts.session.commonSession.RoomInfo.TeamCapacity <= 1) { if (damage.InstantDeath || gamePlay.CurHp <= 0) { gamePlay.ChangeLifeState(EPlayerLifeState.Dead, now); } return(null); } else { switch (gamePlay.LifeState) { case (int)EPlayerLifeState.Alive: if (gamePlay.CurHp <= 0 || damage.InstantDeath) { int aliveCount = 0; List <PlayerEntity> teamList = new List <PlayerEntity>(); foreach (PlayerEntity other in contexts.player.GetInitializedPlayerEntities()) { if (!other.hasGamePlay) { continue; } if (other.playerInfo.PlayerId != player.playerInfo.PlayerId && other.playerInfo.TeamId == player.playerInfo.TeamId) { switch (other.gamePlay.LifeState) { case (int)EPlayerLifeState.Alive: aliveCount++; break; case (int)EPlayerLifeState.Dying: teamList.Add(other); break; default: break; } } } if (damage.InstantDeath || damage.type == (int)EUIDeadType.Bomb || damage.type == (int)EUIDeadType.Drown || player.stateInterface.State.GetCurrentPostureState() == PostureInConfig.Swim || player.stateInterface.State.GetCurrentPostureState() == PostureInConfig.Dive) { gamePlay.ChangeLifeState(EPlayerLifeState.Dead, now); return(aliveCount == 0 ? teamList : null); } if (aliveCount == 0) { gamePlay.ChangeLifeState(EPlayerLifeState.Dead, now); } else { gamePlay.ChangeLifeState(EPlayerLifeState.Dying, now); } return(aliveCount == 0 ? teamList : null); } break; case (int)EPlayerLifeState.Dying: if (damage.InstantDeath || gamePlay.InHurtedHp <= 0) { gamePlay.ChangeLifeState(EPlayerLifeState.Dead, now); } break; default: break; } return(null); } }