示例#1
0
 public void PlayTakeDamageAnimation(float delay = 0)
 {
     transform.DOPunchRotation(new Vector3(0, 0, 20), 0.5f)
     .SetDelay(delay)
     .OnStart(() =>
     {
         InstantiateSlash(GridPosition.x, GridPosition.y);
         audio.PlayTakeDamage();
     })
     .OnComplete(() =>
     {
         transform.rotation = Quaternion.identity;
     });
 }
示例#2
0
        private void OnEntityDamaged(float currentHealthPercentage)
        {
            transform.DOPunchRotation(new Vector3(0, 0, 20), 0.5f)
            .OnStart(() =>
            {
                InstantiateSlash(entityOwner.GridPosition.x, entityOwner.GridPosition.y);
                audio.PlayTakeDamage();
            })
            .OnComplete(() =>
            {
                transform.rotation = Quaternion.identity;
            });

            float clampedHealthPercentage = Mathf.Clamp01(currentHealthPercentage);

            HealthBarContainer.transform.DOShakePosition(0.5f, new Vector3(0.1f, 0.1f, 0));
            HealthBar.transform.DOScaleX(clampedHealthPercentage, 0.25f);
        }