public void GetDamage(float targetAttack, float targetHit, float flinchRate, GameObject atkEffect, AudioClip atksfx) { //Calculate Hit targetHit += UnityEngine.Random.Range(-10, 30); if (playerStatus.statusCal.spd - targetHit > 0) //Attack Miss { InitTextDamage(Color.white, "Miss"); SoundManager.instance.PlayingSound("Attack_Miss"); } else { int damage = Mathf.FloorToInt((targetAttack - playerStatus.statusCal.def) * UnityEngine.Random.Range(0.8f, 1.2f)); if (damage <= 5) { damage = UnityEngine.Random.Range(1, 11); // if def < enemy attack } //Play SFX if (atksfx) { AudioSource.PlayClipAtPoint(atksfx, transform.position); } //Spawn Effect if (atkEffect) { Instantiate(atkEffect, transform.position, Quaternion.identity); } InitTextDamage(Color.red, damage.ToString()); playerStatus.statusCal.hp -= damage; GetDamageColorReset(); if (playerStatus.statusCal.hp <= 0) { playerSkill.CastBreak(); playerStatus.statusCal.hp = 0; ctrlAnimState = ControlAnimationState.Death; } else { flinchValue -= flinchRate; if (flinchValue <= 0) { if (ctrlAnimState == ControlAnimationState.Cast || ctrlAnimState == ControlAnimationState.ActiveSkill) { playerSkill.CastBreak(); } ctrlAnimState = ControlAnimationState.TakeAtk; flinchValue = 100; playerSkill.oneShotResetTarget = false; } } } }