public void Fire() { var projectile = _projectileFactory.Create(_cannonEndTransform); projectile.Launch(); ShotFired.Invoke(); }
public void Shoot() { if (_nextFire >= 0) { return; } _nextFire = Settings.FireRate; if (Settings.CurrentAmmo > 0 || Settings.AIUseInfiniteAmmo) { Settings.ShootAudioEvent?.PlayOneShot(_gunEndAudioSource); Settings.CurrentAmmo--; if (Settings.IsRaycast) { ShootRaycast(); } else { ShootProjectile(); } ShotFired?.Invoke(); } else { Settings.EmptyAmmoAudioEvent?.PlayOneShot(_gunEndAudioSource); } }
public void FireShot(ShotInfo shot) { shot.CreateTimeStamp = GameTime.Now; MsgShotBegin shotMessage = new MsgShotBegin(); if (shot.Owner == null) { shotMessage.PlayerID = BZFlag.Data.Players.PlayerConstants.ServerPlayerID; } else { shotMessage.PlayerID = shot.Owner.PlayerID; } shotMessage.ShotID = shot.PlayerShotID; shotMessage.Team = shot.TeamColor; shotMessage.TimeSent = (float)shot.FireTimestamp; shotMessage.Position = shot.InitalPostion; shotMessage.Velocity = shot.InitalVector; shotMessage.Lifetime = (float)shot.Lifetime; if (shot.SourceFlag != null) { shotMessage.Flag = shot.SourceFlag.FlagAbbv; } lock (ShotList) ShotList.Add(shot); Players.SendToAll(shotMessage, false); ShotFired?.Invoke(this, shot); shot.Allow = true; }
public async Task Handle(ShotFired message) { var gameToUpdate = await _read.Get <GameDetails>(message.GameId); gameToUpdate.Players[message.AggressorPlayer].Board.AddShotFired(message.Target); gameToUpdate.Players[message.TargetPlayer].Board.AddShotReceived(message.Target); gameToUpdate.Turn += 1; gameToUpdate.Version = message.Version; await _save.Put(gameToUpdate); }
private void ShootBullet() { Bullet bullet = BulletPooler.Instance.GetPooledObject(); Vector3 direction = (enemy.Target.position - bulletSpawnPoint.position).normalized; bullet.transform.position = bulletSpawnPoint.position; bullet.Launch(projectileLayer.MaskToLayer(), direction, config.BulletSpeed, Element.None); ShotFired?.Invoke(); }
void InvokeOnShotFired(IProjectile projectile) { try { ShotFired?.Invoke(this, projectile); } catch (Exception e) { Urho.IO.Log.Write(LogLevel.Debug, $"There was an unexpected exception during the invocation of {nameof(ShotFired)}: {e.Message}"); } }
private void FireMissileShot(Vector2 fireAngle) { ShotFiredEventArgs args = new ShotFiredEventArgs { Location = _turretSprite.WorldLocation, Velocity = fireAngle * WeaponSpeed, ShotType = ShotType.Missile }; ShotFired?.Invoke(this, args); _missileTimer.Reset(); }
private IEnumerator Shoot() { rateOfFireHandler = false; isShooting = true; PreShootMethod(); StartCoroutine(ShootMethod()); ShotFired?.Invoke(); PostShootMethod(); yield return(new WaitForSeconds(RateOfFire)); isShooting = false; rateOfFireHandler = true; }
public void FireShot() { ShotFiredEventArgs args = new ShotFiredEventArgs { Location = Location + _gunOffset, ShotSpeed = ShotSpeed, FiredBy = FiredBy.Enemy, Damage = EnemyShotDamage // Don't know directional velocity because we don't know where the player is }; ShotFired?.Invoke(this, args); }
private IEnumerator FiringLoop() { while (health.IsAlive) { Bullet bullet = BulletPooler.Instance.GetPooledObject(); Vector3 direction = bulletSpawnPoint.forward; bullet.transform.position = bulletSpawnPoint.transform.position; bullet.Launch(projectileLayer.MaskToLayer(), direction, _playerConfig.BulletSpeed, elementDataObject.Value); ShotFired?.Invoke(); yield return(new WaitForSeconds(_playerConfig.FireRate)); } }
private void FireShot() { if (_shotTimer.Completed) { ShotFiredEventArgs args = new ShotFiredEventArgs { Location = Location + _gunOffset, Velocity = new Vector2(0, -1), // player can only fire on one direction ShotSpeed = ShotSpeed, FiredBy = FiredBy.Player // ShotBy = ShotBy.Player }; ShotFired?.Invoke(this, args); _shotTimer.Reset(); } }
private void FireTripleShot(Vector2 fireAngle) { Vector2 baseWeaponVector = fireAngle * WeaponSpeed; double baseAngle = Math.Atan2(baseWeaponVector.Y, baseWeaponVector.X); double offset = MathHelper.ToRadians(TripleWeaponSplitAngleDegrees); ShotFiredEventArgs shot1 = new ShotFiredEventArgs { Location = _turretSprite.WorldLocation, Velocity = baseWeaponVector, ShotType = ShotType.Bullet }; ShotFiredEventArgs shot2 = new ShotFiredEventArgs { Location = _turretSprite.WorldLocation, Velocity = new Vector2( (float)Math.Cos(baseAngle - offset), (float)Math.Sin(baseAngle - offset) ) * baseWeaponVector.Length(), ShotType = ShotType.Bullet }; ShotFiredEventArgs shot3 = new ShotFiredEventArgs { Location = _turretSprite.WorldLocation, Velocity = new Vector2( (float)Math.Cos(baseAngle + offset), (float)Math.Sin(baseAngle + offset) ) * baseWeaponVector.Length(), ShotType = ShotType.Bullet }; ShotFired?.Invoke(this, shot1); ShotFired?.Invoke(this, shot2); ShotFired?.Invoke(this, shot3); _shotTimer.Reset(); }
/// <summary> /// Triggered regulary with wave input data. /// Here we will analyze the audio data and detect shots. /// When shots are detected the ShotFired() is invoked. /// </summary> /// <param name="sender">Sender</param> /// <param name="e">WaveInEventArgs. This one has a buffer byte array that represents audio data.</param> private void ReadingAvailableAudioData(object sender, WaveInEventArgs e) { // Transform the byte array to a MemoryStream var stream = new MemoryStream(); stream.Write(e.Buffer, 0, e.BytesRecorded); stream.Position = 0; // Process the audio to detect shots var shotsFound = _shotDetector.ProcessAudio(stream); // The stopwatch needs to be running, or we will just discard those shots that occured before the Start if (!_stopWatch.IsRunning) { return; } // Shots found if (shotsFound.Length > 0) { // Invoke the ShotFired event, that MainWindow will catch ShotFired.Invoke(this, new ShotEventArgs(shotsFound)); } }
private void EnemyShotFired(object sender, ShotFiredEventArgs e) { ShotFired?.Invoke(sender, e); }
internal void Notify(ShotFired e) => Body.FaceToward(e.Target);
internal static void InvokeShotFiredSecondary(WeaponScript weapon, int burstCount) => ShotFired?.Invoke(null, new WeaponFireEventArgs(weapon.gameObject) { IsPrimaryFire = false, BurstCount = burstCount });
private void OnShotFired(ShotFired obj) { Sound.SoundEffect("SFX/rifle-1.wav", DefaultVolume).Play(); }
private void OnShotFired(ShotFired e) => e.Attacker.Notify(e);