|
|
@@ -15,12 +15,26 @@ public class AttackTrigger : MonoBehaviour
|
|
|
public int offsetY = 1;
|
|
|
public float hitRate = 1;
|
|
|
[HideInInspector]public GameObject Miss;
|
|
|
+ public float criticalRandom;
|
|
|
+ public bool isRandom;
|
|
|
|
|
|
private void Awake()
|
|
|
{
|
|
|
owner = GetComponentInParent<Character>();
|
|
|
+
|
|
|
+ }
|
|
|
+ private void Update()
|
|
|
+ {
|
|
|
+ if (!isRandom)
|
|
|
+ {
|
|
|
+ criticalRandom = Random.Range(0f, 1f);
|
|
|
+ isRandom = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void OnDisable()
|
|
|
+ {
|
|
|
+ isRandom = false;
|
|
|
}
|
|
|
-
|
|
|
private void OnTriggerEnter(Collider other)
|
|
|
{
|
|
|
BeHitTrigger hitTrigger = other.GetComponent<BeHitTrigger>();
|
|
|
@@ -40,8 +54,9 @@ public class AttackTrigger : MonoBehaviour
|
|
|
trigedObjs.Add(hitTrigger);
|
|
|
if (Util.CheckCanHit(owner.tag, hitTrigger.owner.tag) && !hitTrigger.owner.isDie)
|
|
|
{
|
|
|
- if (Random.Range(0f, 1f) < owner.criticalChance)
|
|
|
+ if (criticalRandom < owner.criticalChance)
|
|
|
{
|
|
|
+
|
|
|
hitTrigger.BeHit((int)(damage * owner.criticalMultiplier), force
|
|
|
* owner.criticalMultiplier, changeHurt, repelValue);
|
|
|
GameObject effect = Instantiate(spiritsAttackEffect);
|