Exemplo n.º 1
0
    public override void TakeDamage(float amount, Vector2 knockBackForce, bool flinch, HealthScript attacker = null, float freezeDelay = 0.0f, Collider2D gotHitCollider = null)
    {
        if (playerFever.feverMode == false && consuming.consuming == false)
        {
            currentHealth -= amount;

            GetComponent <PlayerController>().AddForce(knockBackForce.x, knockBackForce.y);

            if (flinch)
            {
                anim.Play("Player_Flinch");
                GetComponent <PlayerSkill>().resetSkillTimer();
            }

            if (gotHitCollider)
            {                                                                                                                                                         // Pass attacker (their health scripts) and 'this object's collider that was hit' as argument for hiteffect instantiation.
                Vector3    hitPos         = gotHitCollider.bounds.ClosestPoint(new Vector3(attacker.transform.position.x, attacker.transform.position.y + 0.86f, 0)); // 0.86f is the shoulder height of yasushi.
                GameObject hitEffectInst  = Instantiate(hitEffect, hitPos, attacker.transform.rotation);
                Vector3    hitEffectScale = hitEffectInst.transform.localScale;
                hitEffectScale.x *= Mathf.Sign(attacker.transform.position.x - gotHitCollider.transform.position.x);
                hitEffectInst.transform.localScale = hitEffectScale;
            }

            if (attacker != null && freezeDelay > 0)
            {
                attacker.FreezeFrames(freezeDelay);
                FreezeFrames(freezeDelay);
            }

            comboUI.ComboReset();
            hitBoxes.DeactivateRightHitBox1();
            hitBoxes.DeactivateRightHitBox2();
            hitBoxes.DeactivateRightHitBox3();
            hitBoxes.DeactivateRightChargebox();
            takeDamage = true;
            GetComponent <PlayerAttack> ().attacking   = false;
            GetComponent <PlayerAttack> ().chargeTimer = 0;
            anim.SetBool("chargingup", false);
            anim.SetBool("charged", false);
            camShake.Shake(0.1f, 0.1f);
            sfx.PlayFlinch();
        }
        else
        {
            return;
        }
    }