SamplyGame.Missile.OnHit C# (CSharp) Method

OnHit() public method

public OnHit ( Aircraft target, bool killed, Urho.Node bulletNode ) : void
target Aircraft
killed bool
bulletNode Urho.Node
return void
		public override async void OnHit(Aircraft target, bool killed, Node bulletNode)
		{
			// show a small explosion when the missile reaches an aircraft. 
			base.OnHit(target, killed, bulletNode);
			var cache = Application.ResourceCache;
			var explosionNode = Scene.CreateChild();

			// play "boom" sound
			SoundSource soundSource = explosionNode.CreateComponent<SoundSource>();
			soundSource.Play(Application.ResourceCache.GetSound(Assets.Sounds.SmallExplosion));
			soundSource.Gain = 0.2f;

			explosionNode.Position = target.Node.WorldPosition;
			explosionNode.SetScale(1f);
			var particleEmitter = explosionNode.CreateComponent<ParticleEmitter2D>();
			particleEmitter.Effect = cache.GetParticleEffect2D(Assets.Particles.MissileTrace);
			var scaleAction = new ScaleTo(0.5f, 0f);
			await explosionNode.RunActionsAsync(scaleAction, new DelayTime(0.5f));
			explosionNode.Remove();
		}
	}