Exemplo n.º 1
0
    public void Damage(float damage, Vector3 knockBackDir, float knockBack)
    {
        if (!isHurt)
        {
            isHurt = true;
            hurtVFX.BeginFlash();
            currHealth -= damage;
            ObjectPoolManager.Spawn(deathVFX, transform.position, transform.rotation);
            IAudio player = ObjectPoolManager.Spawn(audioPlayerPrefab.gameObject, transform.position, transform.rotation).GetComponent <IAudio>();
            player.SetUpAudioSource(AudioManager.instance.GetSound("BugsSplat"));
            player.PlayAtRandomPitch();
            DamageNumber dmgVFX = ObjectPoolManager.Spawn(hurtNumber, transform.position, Quaternion.identity).GetComponent <DamageNumber>();
            if (dmgVFX != false)
            {
                dmgVFX.Init();
                dmgVFX.SetTextValuesAtScale(damage, maxHealth, knockBackDir, 2f);
            }
            if (currHealth <= 0.0f)
            {
                DisableBroodDelegate();
            }

            Invoke("ResetHurt", hurtTime);
        }
    }
Exemplo n.º 2
0
    public void Damage(float damage, Vector3 knockBackDir, float knockBack)
    {
        if (currentStage != BossStage.Transition)
        {
            if (!isHurt && !isDead)
            {
                hurtVFX.BeginFlash();
                ObjectPoolManager.Spawn(deathVFX, transform.position, transform.rotation);
                IAudio player = ObjectPoolManager.Spawn(audioPlayerPrefab.gameObject, transform.position, transform.rotation).GetComponent <IAudio>();
                player.SetUpAudioSource(AudioManager.instance.GetSound("BugsSplat"));
                player.PlayAtRandomPitch();
                isHurt      = true;
                currHealth -= damage;
                if (currHealth < 0f)
                {
                    currHealth = 0f;
                }
                DamageNumber dmgVFX = ObjectPoolManager.Spawn(hurtNumber, transform.position, Quaternion.identity).GetComponent <DamageNumber>();
                if (dmgVFX != false)
                {
                    dmgVFX.Init();
                    dmgVFX.SetTextValuesAtScale(damage, MaxHealth, knockBackDir, 10);
                }

                if (currHealth / MaxHealth <= currentStageTrigger)
                {
                    currHealth = MaxHealth * currentStageTrigger;
                    EnterTransition();
                }
                healthBar.UpdateValue(currHealth);
                Invoke("ResetHurt", hurtTime);
            }
        }
    }
Exemplo n.º 3
0
    protected void Damage(float damage, Vector2 knockBackDir, float knockBack)
    {
        if (!isHurt)
        {
            if (canBeHurt)
            {
                if (navComp.enabled)
                {
                    navComp.Stop();
                    navComp.enabled = false;
                }
                rb.AddForce(knockBackDir * knockBack, ForceMode2D.Impulse);
                ObjectPoolManager.Spawn(deathVFX, transform.position, transform.rotation);
                IAudio player = ObjectPoolManager.Spawn(audioPlayerPrefab.gameObject, transform.position, transform.rotation).GetComponent <IAudio>();
                player.SetUpAudioSource(AudioManager.instance.GetSound("BugHurt"));
                player.PlayAtRandomPitch();
                canBeHurt = false;
                isHurt    = true;
                hurtVFX.BeginFlash();
                currentHealth -= damage;
                this.knockBack = knockBack * knockBackDir;
                DamageNumber dmgVFX = ObjectPoolManager.Spawn(hurtNumber, transform.position, Quaternion.identity).GetComponent <DamageNumber>();
                if (dmgVFX != false)
                {
                    dmgVFX.Init();
                    dmgVFX.SetTextValues(damage, settings.maxHealth, knockBackDir);
                }

                if (currentHealth <= 0)
                {
                    KillEnemy();
                }
            }
        }
    }
Exemplo n.º 4
0
    public static void Spawn(Vector2 position, float value, float duration = 0.4f, float spawnDistance = 0.5f, float minDistance = 0.7f, float maxDistance = 0.95f)
    {
        GameObject go = ObjectPool.Instantiate(Spawnables.I.DamageNumber, PoolType.DAMAGE_NUMBER);

        go.transform.position = position;

        DamageNumber number = go.GetComponent <DamageNumber>();

        number.Value            = value;
        number.Duration         = duration;
        number.SpawnDistance    = spawnDistance;
        number.RandomDistance.x = minDistance;
        number.RandomDistance.y = maxDistance;

        number.Init();
    }