/// <summary> /// Initializes a new instance of the <see cref="ShotFiredMessage"/> class. /// </summary> /// <param name="shot"> /// The shot. /// </param> public ShotFiredMessage(Shot shot) { this.Id = shot.Id; this.Position = shot.SimulationState.Position; this.Velocity = shot.SimulationState.Velocity; this.FiredByPlayer = shot.FiredByPlayer; this.MessageTime = NetTime.Now; this.FiredById = shot.FiredById; }
/// <summary> /// Initializes a new instance of the <see cref="ShotFiredArgs"/> class. /// </summary> /// <param name="shot"> /// The shot. /// </param> public ShotFiredArgs(Shot shot) { this.Shot = shot; }
/// <summary> /// The on shot fired. /// </summary> /// <param name="shot"> /// The shot. /// </param> protected void OnShotFired(Shot shot) { EventHandler<ShotFiredArgs> shotFired = this.ShotFired; if (shotFired != null) { shotFired(this, new ShotFiredArgs(shot)); } }
/// <summary> /// The fire shot. /// </summary> /// <param name="id"> /// The id. /// </param> /// <param name="position"> /// The position. /// </param> /// <param name="velocity"> /// The velocity. /// </param> /// <param name="firedById"> /// The fired by id. /// </param> /// <param name="playerFired"> /// The player fired. /// </param> /// <returns> /// </returns> public Shot FireShot(long id, Vector2 position, Vector2 velocity, long firedById, bool playerFired) { var shot = new Shot( id, this.spriteSheet, this.initialShotFrame, this.noOfShotFrames, this.shotCollisionRadius, new EntityState { Position = position, Velocity = velocity }, firedById, playerFired); this.shots.Add(shot); if (playerFired) { this.soundManager.PlayPlayerShot(); } else { this.soundManager.PlayEnemyShot(); } return shot; }