Ejemplo n.º 1
0
 public void Setup()
 {
     _shooter = new Gobs.Ship { Pos = new Vector2(0, 0), Rotation = 0 };
     _gob1 = new MockGob { Name = "Gob1", Pos = new Vector2(100, 0) };
     _gob2 = new MockGob { Name = "Gob2", Pos = new Vector2(200, 0) };
     _gob3 = new MockGob { Name = "Gob3", Pos = new Vector2(300, 0) };
     _gob4 = new MockGob { Name = "Gob4", Pos = new Vector2(0, 100) };
     _gob5 = new MockGob { Name = "Gob5", Pos = new Vector2(0, 200) };
     _gob6 = new MockGob { Name = "Gob6", Pos = new Vector2(-100, 0) };
     _gob7 = new MockGob { Name = "Gob7", Pos = new Vector2(0, -100) };
     _potentialTargets = new[] { _gob1, _gob2, _gob3, _gob4, _gob5, _gob6 };
     _gun = new LightningGun();
     _gun.AttachTo(_shooter, GobUtils.ShipDevice.OwnerHandleType.PrimaryWeapon);
 }
Ejemplo n.º 2
0
 public void Setup()
 {
     CanonicalString.IsForLocalUseOnly = true;
     Spectator.CreateStatsData = spectator => new MockStats();
     _arena = new Arena();
     _ship1 = new Ship((CanonicalString)"Bugger") { Owner = _player1, MaxDamageLevel = 100, Arena = _arena };
     _ship2 = new Ship((CanonicalString)"Bugger") { Owner = _player2, MaxDamageLevel = 100, Arena = _arena };
     _ship3 = new Ship((CanonicalString)"Bugger") { Owner = _player3, MaxDamageLevel = 100, Arena = _arena };
     _avengers = new Team("Avengers", null);
     _xmen = new Team("X-Men", 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());
     SeizeShip(_player1, _ship1);
     SeizeShip(_player2, _ship2);
     SeizeShip(_player3, _ship3);
 }
Ejemplo n.º 3
0
 public void SeizeShip(Ship ship)
 {
     if (Ship == ship) return;
     Ship = ship;
     ship.Owner = this;
     ship.Death += MinionDeathHandler.OnMinionDeath;
     ship.Death += ShipDeathHandler;
     ship.SetDeviceType(ShipDevice.OwnerHandleType.PrimaryWeapon, Weapon1Name);
     ship.SetDeviceType(ShipDevice.OwnerHandleType.SecondaryWeapon, Weapon2Name);
     ship.SetDeviceType(ShipDevice.OwnerHandleType.ExtraDevice, ExtraDeviceName);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Like <see cref="Player.SeizeShip"/> but does less so that an AssaultWingCore instance isn't required.
 /// </summary>
 private void SeizeShip(Player player, Ship ship)
 {
     player.Ship = ship;
     ship.Owner = player;
 }
Ejemplo n.º 5
0
 private TimeSpan TimeUntilRepairStarts(Ship ship)
 {
     var now = Game.DataEngine.ArenaTotalTime;
     return AWMathHelper.Max(TimeSpan.Zero, AWMathHelper.Max(
         ship.LastDamageTakenTime + UNDAMAGED_TIME_REQUIRED - now,
         ship.LastWeaponFiredTime + PACIFIST_TIME_REQUIRED - now));
 }
Ejemplo n.º 6
0
 private bool ShouldNotifyPlayerAboutRepairPending(Ship ship)
 {
     return ship.Owner != null && Game.NetworkMode != Core.NetworkMode.Client
         && TimeUntilRepairStarts(ship) >= REPAIR_PENDING_NOTIFY_MIN;
 }
Ejemplo n.º 7
0
 private void RepairShip(Ship ship)
 {
     if (ShouldNotifyPlayerAboutRepairPending(ship)) ship.Owner.NotifyRepairPending();
     if (IsFullyRepaired(ship)) return;
     ship.Move *= _repairingMoveSlowdownFactor;
     if (!CanRepair(ship)) return;
     if (ship.Owner != null && !_lastRepairTimes.ContainsKey(ship))
     {
         ForcedNetworkUpdate = true;
         Game.Stats.Send(new
         {
             Docking = Game.Stats.GetStatsString(ship.Owner),
             Pos = ship.Pos,
         });
     }
     _lastRepairTimes[ship] = Game.GameTime.TotalGameTime;
     var elapsedSeconds = (float)Game.GameTime.ElapsedGameTime.TotalSeconds;
     ship.RepairDamage(_repairSpeed * elapsedSeconds);
     ship.ExtraDevice.Charge += _weapon1ChargeSpeed * elapsedSeconds;
     ship.Weapon2.Charge += _weapon2ChargeSpeed * elapsedSeconds;
 }
Ejemplo n.º 8
0
 private bool IsFullyRepaired(Ship ship)
 {
     return ship.DamageLevel == 0
         && ship.ExtraDevice.Charge == ship.ExtraDevice.ChargeMax
         && ship.Weapon2.Charge == ship.Weapon2.ChargeMax;
 }
Ejemplo n.º 9
0
 private bool CanRepair(Ship ship)
 {
     return TimeUntilRepairStarts(ship) == TimeSpan.Zero;
 }