Exemplo n.º 1
0
    public static CameraShakeAgent Create(Camera camera, float duration, float amount = 0.5f, float degradationFactor = 1f)
    {
        if (camera == null)
        {
            return(null);
        }

        CameraShakeAgent instance = camera.gameObject.AddComponent <CameraShakeAgent>();

        instance.duration          = duration;
        instance.amount            = amount;
        instance.degradationFactor = degradationFactor;

        return(instance);
    }
Exemplo n.º 2
0
    private void TakeDamage(float amount)
    {
        if (amount == 0)
        {
            return;
        }

        currentHealth -= amount;
        currentHealth  = Mathf.Clamp(currentHealth, 0, MaxHealth);

        if (currentHealth <= 0)
        {
            IsGameover = true;
        }

        OnPlayerHealthChanged(new PlayerHealthChangedEventArgs(this, currentHealth + amount, currentHealth));
        if (amount < 0)
        {
            return;
        }
        CameraShakeAgent.Create(Camera.main, 0.1f, 0.1f);
        spriteRenderer.color = HurtColourTint;
        lastTakeDamageTime   = Time.time;
    }
Exemplo n.º 3
0
 public void Shock(float duration, float cameraShakeAmount = 0.5f, float cameraShakeDegradationFactor = 1)
 {
     Freeze(duration);
     CameraController.Instance.Freeze(duration);
     CameraShakeAgent.Create(duration, cameraShakeAmount, cameraShakeDegradationFactor);
 }