IEnumerator ATTACK() { do { if (targetMob == null || targetMob.isDie) { setState(State.IDLE); break; } if (Vector2.Distance(targetMob.transform.position, transform.position) > atkRange) {//사거리 넘어감 targetMob = null; setState(State.IDLE); } else { //방향전환 if (transform.localScale.x == -1 && targetMob.transform.position.x > transform.position.x) { transform.localScale = new Vector3(1, 1, 1); } else if (transform.localScale.x == 1 && targetMob.transform.position.x < transform.position.x) { transform.localScale = new Vector3(-1, 1, 1); } //공격 doAttack(); yield return(new WaitForSeconds(1 / nowAtkSpeed)); } } while (!newState); }
static void defaultAttack(guardianAttackParameter gap, mobFSM target) { float criDamage = Random.Range(1f, 100f) <= gap.criChance ? gap.criDamage : 100f; if (target != null) { target.dealDamage(gap.atkPoint * criDamage / 100f, gap.defCut); } }
public static void attack(guardianAttackParameter gap, mobFSM target) { switch (gap.attackType) { case 0: defaultAttack(gap, target); break; case 1: break; default: break; } }
void detectEnemy() { GameObject[] allMonster = GameObject.FindGameObjectsWithTag("Monster"); foreach (GameObject g in allMonster) { if (Vector2.Distance(g.transform.position, transform.position) <= atkRange) { targetMob = g.GetComponent <mobFSM>(); if (targetMob.isDie) { continue; } } } }