예제 #1
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));
        }
    }
예제 #2
0
 void Shaker()
 {
     camera.ShakeCamera(cameraShakeDuration, cameraShakeIntensity);
 }