public virtual void OnHit(Aircraft target, bool killed, Node bulletNode) { var body = bulletNode.GetComponent<RigidBody>(); if (body != null) body.Enabled = false; bulletNode.SetScale(0); }
public override void OnHit(Aircraft target, bool killed, Node bulletNode) { var soundSource = Node.CreateComponent<SoundSource>(); soundSource.Gain = 0.1f; soundSource.Play(Application.ResourceCache.GetSound(Assets.Sounds.Powerup)); base.OnHit(target, killed, bulletNode); ((SamplyGame)Application).OnCoinCollected(); }
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(); }