コード例 #1
0
ファイル: Ship.cs プロジェクト: vvnurmi/assaultwing
 private ShipDevice.FiringResult Merge(ShipDevice.FiringResult a, ShipDevice.FiringResult b)
 {
     if (a == ShipDevice.FiringResult.Success || b == ShipDevice.FiringResult.Success) return ShipDevice.FiringResult.Success;
     if (a == ShipDevice.FiringResult.Failure || b == ShipDevice.FiringResult.Failure) return ShipDevice.FiringResult.Failure;
     if (a == ShipDevice.FiringResult.NotReady || b == ShipDevice.FiringResult.NotReady) return ShipDevice.FiringResult.NotReady;
     return ShipDevice.FiringResult.Void;
 }
コード例 #2
0
ファイル: Ship.cs プロジェクト: vvnurmi/assaultwing
 public ShipDevice.FiringResult this[ShipDevice.OwnerHandleType ownerHandleType]
 {
     get
     {
         switch (ownerHandleType)
         {
             case ShipDevice.OwnerHandleType.PrimaryWeapon: return Weapon1;
             case ShipDevice.OwnerHandleType.SecondaryWeapon: return Weapon2;
             case ShipDevice.OwnerHandleType.ExtraDevice: return ExtraDevice;
             default: throw new ApplicationException("Invalid owner handle " + ownerHandleType);
         }
     }
     set
     {
         switch (ownerHandleType)
         {
             case ShipDevice.OwnerHandleType.PrimaryWeapon: Weapon1 = Merge(Weapon1, value); break;
             case ShipDevice.OwnerHandleType.SecondaryWeapon: Weapon2 = Merge(Weapon2, value); break;
             case ShipDevice.OwnerHandleType.ExtraDevice: ExtraDevice = Merge(ExtraDevice, value); break;
             default: throw new ApplicationException("Invalid owner handle " + ownerHandleType);
         }
     }
 }
コード例 #3
0
ファイル: Ship.cs プロジェクト: vvnurmi/assaultwing
 private void SetDevice(ShipDevice.OwnerHandleType ownerHandle, ShipDevice device)
 {
     switch (ownerHandle)
     {
         case ShipDevice.OwnerHandleType.PrimaryWeapon: Weapon1 = device; break;
         case ShipDevice.OwnerHandleType.SecondaryWeapon: Weapon2 = device; break;
         case ShipDevice.OwnerHandleType.ExtraDevice: ExtraDevice = device; break;
         default: throw new ApplicationException("Invalid owner handle " + ownerHandle);
     }
     device.AttachTo(this, ownerHandle);
     Game.DataEngine.Devices.Add(device);
 }
コード例 #4
0
ファイル: Ship.cs プロジェクト: vvnurmi/assaultwing
 private ShipDevice GetDevice(ShipDevice.OwnerHandleType ownerHandleType)
 {
     switch (ownerHandleType)
     {
         case ShipDevice.OwnerHandleType.PrimaryWeapon: return Weapon1;
         case ShipDevice.OwnerHandleType.SecondaryWeapon: return Weapon2;
         case ShipDevice.OwnerHandleType.ExtraDevice: return ExtraDevice;
         default: throw new ApplicationException("Invalid owner handle " + ownerHandleType);
     }
 }
コード例 #5
0
ファイル: Ship.cs プロジェクト: vvnurmi/assaultwing
 public void SetDeviceType(ShipDevice.OwnerHandleType deviceType, CanonicalString typeName)
 {
     switch (deviceType)
     {
         case ShipDevice.OwnerHandleType.PrimaryWeapon: Weapon1Name = typeName; break;
         case ShipDevice.OwnerHandleType.SecondaryWeapon: Weapon2Name = typeName; break;
         case ShipDevice.OwnerHandleType.ExtraDevice: ExtraDeviceName = typeName; break;
         default: throw new ApplicationException("Unknown Weapon.OwnerHandleType " + deviceType);
     }
     var oldDevice = GetDevice(deviceType);
     if (oldDevice != null) Game.DataEngine.Devices.Remove(oldDevice);
     var newDevice = ShipDevice.Create(Game, typeName);
     SetDevice(deviceType, newDevice);
 }
コード例 #6
0
ファイル: Ship.cs プロジェクト: vvnurmi/assaultwing
 public void TryFire(ShipDevice.OwnerHandleType ownerHandleType, Control control)
 {
     DeviceUsagesToClients[ownerHandleType] = GetDevice(ownerHandleType).TryFire(control.State);
 }
コード例 #7
0
ファイル: Ship.cs プロジェクト: vvnurmi/assaultwing
 public override ChargeProvider GetChargeProvider(ShipDevice.OwnerHandleType deviceType)
 {
     switch (deviceType)
     {
         case ShipDevice.OwnerHandleType.PrimaryWeapon:
             return new ChargeProvider(() => int.MaxValue, () => 0);
         case ShipDevice.OwnerHandleType.SecondaryWeapon:
             return new ChargeProvider(() => _weapon2ChargeMax, () => _weapon2ChargeSpeed);
         case ShipDevice.OwnerHandleType.ExtraDevice:
             return new ChargeProvider(() => _extraDeviceChargeMax, () => _extraDeviceChargeSpeed);
         default: throw new ApplicationException("Unknown ship device type " + deviceType);
     }
 }
コード例 #8
0
ファイル: Cloak.cs プロジェクト: vvnurmi/assaultwing
 private void WeaponFiredHandler(ShipDevice.OwnerHandleType ownerHandleType)
 {
     if (ownerHandleType == OwnerHandleType.ExtraDevice || !_active) return;
     DeactivateCloak();
     Owner.Game.SoundEngine.PlaySound(_breakOutSoundName, Owner);
 }
コード例 #9
0
ファイル: Player.cs プロジェクト: vvnurmi/assaultwing
 private void TryFire(ShipDevice.OwnerHandleType ownerHandleType)
 {
     var control = Controls[ownerHandleType];
     if (!control.HasSignal) return;
     Ship.TryFire(ownerHandleType, control);
 }
コード例 #10
0
ファイル: Player.cs プロジェクト: vvnurmi/assaultwing
 public void OnWeaponFired(ShipDevice device)
 {
     if (!Minions.Contains(device.Owner)) return;
     Game.Stats.Send(new
     {
         Fired = Game.Stats.GetStatsString(this),
         Role = device.OwnerHandle,
         Type = device.TypeName.Value,
         Pos = device.Owner.Pos,
     });
     // FIXME: It could be possible that the device does not belong to Ship.
     if (device.OwnerHandle != ShipDevice.OwnerHandleType.ExtraDevice) Ship.LastWeaponFiredTime = Game.DataEngine.ArenaTotalTime;
     if (WeaponFired != null) WeaponFired(device.OwnerHandle);
 }
コード例 #11
0
ファイル: FiringOperator.cs プロジェクト: vvnurmi/assaultwing
 public FiringOperator(ShipDevice device)
 {
     _device = device;
 }
コード例 #12
0
 private void WeaponFiredHandler(ShipDevice.OwnerHandleType ownerHandle)
 {
     if (ownerHandle != ShipDevice.OwnerHandleType.SecondaryWeapon) return;
     if (_isSingleUse) TimeOut();
 }