/// <summary>
        ///     Plays the sound of the impact
        /// </summary>
        protected override void PlayImpactSound()
        {
            if (impactSounds.Count > 0)
            {
                var test = HitBy.GetComponent <AsteriaWeapons.BulletBase>();
                if (test)
                {
                    foreach (BulletImpactSounds sound in impactSounds)
                    {
                        if (sound.bullet == test.bulletType)
                        {
                            sound.impactSound.Play();
                            return;
                        }
                    }
                }
            }

            if (genericImpactSound)
            {
                genericImpactSound.Play();
            }
        }
Example #2
0
    //---------------------------------------------

    // Called by an ability when it hits the player.
    public void OnPlayerHit(Vector3 hitDirection, float multiplier, float damage, float cameraShakeDuration, float cameraShakeIntensity, HitBy hitBy)
    {
        playerHp.DecreaseHP(damage);
        int pIndex = (int)playerIndex;

        playerDamageInfo(pIndex, damage);

        int listIndex = Random.Range(0, hitAudioNames.Count);

        AudioManager.instance.PlayWithRandomPitch(hitAudioNames[listIndex]);

        if (multiplier > 0)
        {
            smokeTrail = Instantiate(hitDustTrail, gameObject.transform.position, Quaternion.identity) as GameObject;

            smokeTrail.transform.SetParent(gameObject.transform, true);
        }


        if (!isVibrating)
        {
            if (this.gameObject.activeInHierarchy) //To prevent it ffrom being called after players "die"
            {
                StartCoroutine(WaitToDisableVibrations());
            }
        }

        if (hitBy != HitBy.Storm || hitBy != HitBy.Tick)
        {
            direction           = hitDirection;
            knockbackMultiplier = multiplier;

            camera.ShakeCamera(cameraShakeDuration, cameraShakeIntensity);
            ApplyKnockback(direction, forceAmount, multiplier);

            states.SetStateTo(PlayerStates.PossibleStates.GotHit);
            StartCoroutine(RestoredFromHit());
        }

        if (hitBy == HitBy.Dash)
        {
            StartCoroutine(LightningDamageTick(damage));
        }
    }