コード例 #1
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (jetpack.UsingJet)
     {
         audioPlayer.PlaySound(JetAudioClip, Volume);
     }
 }
コード例 #2
0
        /// <summary>
        /// Shoots the projectile in direction of player.
        /// </summary>
        public void ShootProjectile()
        {
            var projectile = ObjectManager.instance.GetObject(Projectile.name, ProjectileSpawnLocation.position);

            var projRigidbody = projectile.GetComponent <Rigidbody2D> ();

            if (!projRigidbody)
            {
                Debug.LogError("Projectile should have Rigidbody2D attached");
                return;
            }

            var heading   = player.position - transform.position;
            var distance  = heading.magnitude;
            var direction = heading / distance;

            projRigidbody.AddForce(direction * ProjectileForce);

            _audio.PlaySound(ShootAudioClip, 1f);
        }
コード例 #3
0
 void Start()
 {
     _audio.PlaySound(BackgroundAudioTracks [Random.Range(0, BackgroundAudioTracks.Length)], Volume, true);
 }
コード例 #4
0
 /// <summary>
 /// Burst moves towards the player. Called by animation.
 /// </summary>
 public void BurstMoveTowardsPlayer()
 {
     _rigidbody2D.AddForce((player.position - transform.position).normalized * (MoveBurstForce * Time.deltaTime), ForceMode2D.Impulse);
     _audio.PlaySound(MoveAudio, 0.5f);
 }
コード例 #5
0
 /// <summary>
 /// Plays the audio clip when enemy activates.
 /// </summary>
 public void PlayNearbyAudio()
 {
     _audio.PlaySound(PlayerNearbyAudio, 1f, Random.Range(0.6f, 1.6f));
 }
コード例 #6
0
 /// <summary>
 /// Kill the specified enemy and applys knockback force.
 /// </summary>
 /// <param name="projectilePosition">Projectile position.</param>
 /// <param name="force">Force.</param>
 public void Kill(Vector3 projectilePosition, float force)
 {
     _audio.PlaySound(SoundOnDeath, 0.8f);
     startTime = Time.time;
     RepelFromPositionWithForce(projectilePosition, force);
 }
コード例 #7
0
 private void OnCollectiblePickUp(CollectiblePickedUpEvent e)
 {
     _audio.PlaySound(PickUpAudio, 0.5f);
     _light.intensity += e.LightAmount;
     _light.range     += e.RadiusAmount;
 }
コード例 #8
0
 /// <summary>
 /// Plays the explosion sound.
 /// </summary>
 public void PlayExplosionSound()
 {
     _audio.PlaySound(ExplosionClip, 1f);
 }
コード例 #9
0
        /// <summary>
        /// Plays random clip on player step.
        /// </summary>
        public void PlayStepAudio()
        {
            var stepSound = StepClips [Random.Range(0, StepClips.Length)];

            audioPlayer.PlaySound(stepSound, 0.8f);
        }