/// <summary> /// Damage the ship /// </summary> /// <param name="damage">Amount to damage the ship by</param> void DamageShip(object sender, BulletHitEventArgs e) { if (e.HitCollider == this.cCollider) { if (this.cHealth.ApplyDamage(e.ShotDamage) <= 0f) { this.DestroyShip(); } } }
/// <summary> /// Hit by bullet (should only be triggered when active) /// </summary> /// <param name="sender">the bullet that hit this shield</param> /// <param name="e">the arguments describing the event</param> private void TakeHit(object sender, BulletHitEventArgs e) { if (e.HitCollider == this.collider && state == ShieldState.ACTIVE) { this.shieldHealthFloat -= e.ShotDamage; if (this.shieldHealthFloat <= 0f) { this.shieldHealthFloat = 0f; this.state = ShieldState.REGENERATING; this.collider.enabled = false; this.renderer.enabled = false; } } }
private void BulletManager_BulletHit(object i_Sender, BulletHitEventArgs i_EventArgs) { if (i_EventArgs.Target is IEnemy) { this.Score += (i_EventArgs.Target as IEnemy).Score; } }