private static void SendMessages(Coroner coroner)
 {
     var killerPlayer = coroner.KillerSpectator as Player;
     var killedPlayer = coroner.KilledSpectator as Player;
     var players = coroner.Game.DataEngine.Players;
     switch (coroner.DeathType)
     {
         default: throw new ApplicationException("Unexpected DeathType " + coroner.DeathType);
         case Coroner.DeathTypeType.Kill:
             CreateKillMessage(coroner.KillerSpectator, coroner.DamageInfo.Target.Pos);
             if (killerPlayer != null) killerPlayer.Messages.Add(new PlayerMessage(coroner.MessageToKiller, PlayerMessage.KILL_COLOR));
             if (killedPlayer != null) killedPlayer.Messages.Add(new PlayerMessage(coroner.MessageToCorpse, PlayerMessage.DEATH_COLOR));
             break;
         case Coroner.DeathTypeType.TeamKill:
             CreateTeamKillMessage(coroner.KillerSpectator, coroner.DamageInfo.Target.Pos);
             if (killerPlayer != null) killerPlayer.Messages.Add(new PlayerMessage(coroner.MessageToKiller, PlayerMessage.SUICIDE_COLOR));
             if (killedPlayer != null) killedPlayer.Messages.Add(new PlayerMessage(coroner.MessageToCorpse, PlayerMessage.DEATH_COLOR));
             break;
         case Coroner.DeathTypeType.Accident:
             CreateSuicideMessage(coroner.KilledSpectator, coroner.DamageInfo.Target.Pos);
             if (killedPlayer != null) killedPlayer.Messages.Add(new PlayerMessage(coroner.MessageToCorpse, PlayerMessage.SUICIDE_COLOR));
             break;
     }
     var bystanderMessage = new PlayerMessage(coroner.MessageToBystander, PlayerMessage.DEFAULT_COLOR);
     foreach (var plr in coroner.GetBystandingPlayers(players)) plr.Messages.Add(bystanderMessage);
     if (coroner.SpecialMessage != null)
     {
         var specialMessage = new PlayerMessage(coroner.SpecialMessage, PlayerMessage.SPECIAL_KILL_COLOR);
         foreach (var plr in players) plr.Messages.Add(specialMessage);
     }
 }
 private static void SendStats(Coroner coroner)
 {
     var stats = coroner.Game.Stats;
     switch (coroner.DeathType)
     {
         default: throw new ApplicationException("Invalid DeathType " + coroner.DeathType);
         case Coroner.DeathTypeType.Kill:
             stats.Send(new
             {
                 Killer = stats.GetStatsString(coroner.KillerSpectator),
                 Victim = stats.GetStatsString(coroner.KilledSpectator),
                 Pos = coroner.DamageInfo.Target.Pos,
             });
             break;
         case Coroner.DeathTypeType.TeamKill:
             coroner.Game.Stats.Send(new
             {
                 TeamKiller = stats.GetStatsString(coroner.KillerSpectator),
                 Victim = stats.GetStatsString(coroner.KilledSpectator),
                 Pos = coroner.DamageInfo.Target.Pos,
             });
             break;
         case Coroner.DeathTypeType.Accident:
             coroner.Game.Stats.Send(new
             {
                 Suicide = stats.GetStatsString(coroner.KilledSpectator),
                 Pos = coroner.DamageInfo.Target.Pos,
             });
             break;
     }
 }
Beispiel #3
0
 public void TestBystandersSuicide()
 {
     var info = new DamageInfo(_gob1).Bind(_gob1);
     var coroner = new Coroner(info);
     var bystanders = coroner.GetBystandingPlayers(AllPlayers).ToArray();
     Assert.AreEqual(new[] { _player2, _player3, _player4 }, bystanders);
 }
Beispiel #4
0
 public void TestBystandersKillLastDamager()
 {
     _arena.TotalTime = TimeSpan.FromSeconds(11);
     var info = DamageInfo.Unspecified.Bind(_gob1DamagedBy2);
     var coroner = new Coroner(info);
     var bystanders = coroner.GetBystandingPlayers(new[] { _player1, _player2, _player3 }).ToArray();
     Assert.AreEqual(new[] { _player3 }, bystanders);
 }
 public static void OnMinionDeath(Coroner coroner)
 {
     if (coroner.Game.NetworkMode == NetworkMode.Client) return;
     SendStats(coroner);
     SendMessages(coroner);
 }
Beispiel #6
0
 private void BotDeathHandler(Coroner coroner)
 {
     _bots.Remove(coroner.DamageInfo.Target);
 }
Beispiel #7
0
 public void TestBystandersUnspecifiedDeath()
 {
     var info = DamageInfo.Unspecified.Bind(_gob1);
     var coroner = new Coroner(info);
     var bystanders = coroner.GetBystandingPlayers(AllPlayers).ToArray();
     Assert.AreEqual(new[] { _player2, _player3, _player4 }, bystanders);
 }
Beispiel #8
0
 private void AssertTeamKillMessages(string teamKillPhrase, string killMessage, string deathMessage, string bystanderMessage)
 {
     Coroner.SetPhraseSets(new[] { "dummy" }, new[] { "dummy" }, new[] { teamKillPhrase }, new string[0]);
     var info = new DamageInfo(_gob4).Bind(_gob1);
     var coroner = new Coroner(info);
     Assert.AreEqual(_player4, coroner.KillerSpectator);
     Assert.AreEqual(Coroner.DeathTypeType.TeamKill, coroner.DeathType);
     Assert.AreEqual(killMessage, coroner.MessageToKiller);
     Assert.AreEqual(deathMessage, coroner.MessageToCorpse);
     Assert.AreEqual(bystanderMessage, coroner.MessageToBystander);
 }
Beispiel #9
0
 private void AssertSuicideMessages(string suicidePhrase, string deathMessage, string bystanderMessage)
 {
     Coroner.SetPhraseSets(new[] { suicidePhrase }, new[] { "dummy" }, new[] { "dummy" }, new string[0]);
     var info = new DamageInfo(_gob2Nature).Bind(_gob1);
     var coroner = new Coroner(info);
     Assert.AreEqual(null, coroner.KillerSpectator);
     Assert.AreEqual(Coroner.DeathTypeType.Accident, coroner.DeathType);
     Assert.AreEqual(deathMessage, coroner.MessageToCorpse);
     Assert.AreEqual(bystanderMessage, coroner.MessageToBystander);
 }
Beispiel #10
0
 public void TestLastDamagerTooLate()
 {
     _arena.TotalTime = TimeSpan.FromSeconds(30);
     var info = DamageInfo.Unspecified.Bind(_gob1DamagedBy2);
     Assert.AreEqual(BoundDamageInfo.SourceTypeType.Unspecified, info.SourceType);
     var coroner = new Coroner(info);
     Assert.AreEqual(Coroner.DeathTypeType.Accident, coroner.DeathType);
     Assert.AreEqual(null, coroner.KillerSpectator);
 }
Beispiel #11
0
 private void ShipDeathHandler(Coroner coroner)
 {
     if (Game.NetworkMode != NetworkMode.Client)
         _shipSpawnTime = Game.DataEngine.ArenaTotalTime + MOURNING_DELAY;
     Ship = null;
 }