示例#1
0
    void WasHit(GameObject Enemy)
    {
        if (miniHealthBarBackground != null)
        {
            miniHealthBarBackground.SetAlphaToOne();
            miniHealthBar.SetAlphaToOne();
        }
        Vector3 posDiff = transform.position - Enemy.transform.position;

        rb.AddForce(posDiff.normalized * knockbackStrength, ForceMode.Impulse);

        float damageTaken = Enemy.GetComponent <EnemyDamageDealt> ().damageDealt;

        if (godModeActive)
        {
            healthObject.TakeDamage(0.0f);
        }
        else
        {
            healthObject.TakeDamage(damageTaken);
        }

        ttc.ChangeColor(Color.red);

        ScreenShakeEffect.Shake();
        EnableInvincible();
    }
示例#2
0
    public void TakeDamage(Vector3 explosionPosition)
    {
        if (isShrinkDying || isShrinking || isInvincible)
        {
            return;
        }
        isGrowing = false;
        StartInvincibility();
        ttc.ChangeColor(Color.red);

        if (transform.localScale.x <= minScale)
        {
            Die();
        }
        else
        {
            AudioSource.PlayClipAtPoint(SphereHurt, Vector3.back * 500.0f, 0.6f);
            soh.WasHit();
            nextScaleTarget = transform.localScale.x - scaleIncrement;
            isShrinking     = true;
            rb.velocity     = Vector3.zero;
            rb.AddExplosionForce(explosionForce, explosionPosition, explosionRadius);
        }
    }