SamplyGame.XamarinCube.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 cube reaches an aircraft. 
			base.OnHit(target, killed, bulletNode);
			var cache = Application.ResourceCache;
			var explosionNode = Scene.CreateChild();
			SoundSource soundSource = explosionNode.CreateComponent<SoundSource>();
			soundSource.Play(Application.ResourceCache.GetSound(Assets.Sounds.SmallExplosion));
			soundSource.Gain = 0.3f;
			explosionNode.Position = target.Node.WorldPosition;
			explosionNode.SetScale(1.6f);
			var particleEmitter = explosionNode.CreateComponent<ParticleEmitter2D>();
			particleEmitter.Effect = cache.GetParticleEffect2D(Assets.Particles.Explosion);
			ScaleBy scaleBy = new ScaleBy(0.3f, 0.1f);
			await explosionNode.RunActionsAsync(scaleBy, new DelayTime(1f));
			explosionNode.Remove();
		}
	}
XamarinCube