示例#1
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);
 }
示例#2
0
 public void Setup()
 {
     _arena = new Arena();
     _avengers = new Team("Avengers", null);
     _player1 = new Player(null, "Player 1", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls());
     _player2 = new Player(null, "Player 2", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls());
     _player3 = new Player(null, "Player 3", CanonicalString.Null, CanonicalString.Null, CanonicalString.Null, new UI.PlayerControls());
     _player2.AssignTeam(_avengers);
     _player3.AssignTeam(_avengers);
     _gob1 = new Gob { ID = 10, Owner = _player1, MaxDamageLevel = 100, Arena = _arena };
     _gob1DamagedBy2 = new Gob { ID = 11, Owner = _player1, MaxDamageLevel = 100, Arena = _arena };
     _gob2 = new Gob { ID = 2, Owner = _player2, MaxDamageLevel = 100, Arena = _arena };
     _gob3 = new Gob { ID = 3, Owner = _player3, MaxDamageLevel = 100, Arena = _arena };
     _gobNature = new Gob { ID = 4, Owner = null, MaxDamageLevel = 100, Arena = _arena };
     _info1Hit1 = new DamageInfo(_gob1).Bind(_gob1);
     _info2Hit1 = new DamageInfo(_gob2).Bind(_gob1);
     _info3Hit2 = new DamageInfo(_gob3).Bind(_gob2);
     _infoNatureHit1 = new DamageInfo(_gobNature).Bind(_gob1);
     _arena.TotalTime = TimeSpan.FromSeconds(10);
     _gob1DamagedBy2.InflictDamage(10, new DamageInfo(_gob2));
     _info1DamagedBy2 = DamageInfo.Unspecified.Bind(_gob1DamagedBy2);
 }
示例#3
0
 public override void InflictDamage(float damageAmount, DamageInfo cause)
 {
     if (damageAmount < 0) throw new ArgumentOutOfRangeException("damageAmount");
     if (damageAmount == 0) return;
     if (IsNewborn) return;
     if (ReceivingDamage != null) damageAmount = ReceivingDamage(damageAmount, cause);
     if (damageAmount == 0) return;
     LastDamageTakenTime = Game.DataEngine.ArenaTotalTime;
     if (Owner != null) Owner.IncreaseShake(damageAmount);
     base.InflictDamage(damageAmount, cause);
 }
示例#4
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);
 }
示例#5
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);
 }
示例#6
0
 private float ReceivingDamageHandler(float damageAmount, DamageInfo cause)
 {
     var requiredCharge = _chargeUsageMultiplier * damageAmount;
     if (_inactivationTime <= Owner.Game.GameTime.TotalGameTime) return damageAmount;
     if (Charge < requiredCharge)
     {
         CreateBlockEffect(_blockFailSound, _blockFailPengs, ref _lastFailEffectTime);
         return damageAmount;
     }
     Charge -= requiredCharge;
     CreateBlockEffect(_blockSuccessSound, _blockSuccessPengs, ref _lastSuccessEffectTime);
     return _receivedDamageMultiplier * damageAmount;
 }
示例#7
0
 public BoundDamageInfo(DamageInfo info, Gob target)
     : base(info)
 {
     if (target == null) throw new ArgumentNullException("target");
     Target = target;
 }
示例#8
0
 public DamageInfo(DamageInfo info)
     : this(info.Cause)
 {
 }
示例#9
0
 static DamageInfo()
 {
     Unspecified = new DamageInfo();
 }