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; }
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); } } }
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); }
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); } }
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); }
public void TryFire(ShipDevice.OwnerHandleType ownerHandleType, Control control) { DeviceUsagesToClients[ownerHandleType] = GetDevice(ownerHandleType).TryFire(control.State); }
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); } }
private void WeaponFiredHandler(ShipDevice.OwnerHandleType ownerHandleType) { if (ownerHandleType == OwnerHandleType.ExtraDevice || !_active) return; DeactivateCloak(); Owner.Game.SoundEngine.PlaySound(_breakOutSoundName, Owner); }
private void TryFire(ShipDevice.OwnerHandleType ownerHandleType) { var control = Controls[ownerHandleType]; if (!control.HasSignal) return; Ship.TryFire(ownerHandleType, control); }
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); }
public FiringOperator(ShipDevice device) { _device = device; }
private void WeaponFiredHandler(ShipDevice.OwnerHandleType ownerHandle) { if (ownerHandle != ShipDevice.OwnerHandleType.SecondaryWeapon) return; if (_isSingleUse) TimeOut(); }