private void FixedUpdate() { if (thing.dead) { lr.enabled = false; return; } TimeFixedUpdate(); StateFixedUpdate(); switch (state) { case PlayerState.idle: if (stateActiveFrames[(int)PlayerState.idle] == 0) { //animator.CrossFade() lr.enabled = false; } break; case PlayerState.aim: { _changeDir(); } break; case PlayerState.lockOn: lr.SetPosition(0, transform.position); lr.SetPosition(1, (Vector3)direction * distance + transform.position); lr.startColor = Color.yellow; lr.endColor = Color.yellow; break; case PlayerState.dash: if (stateActiveFrames[(int)PlayerState.recover] == 0) { EnemyDash(); lr.enabled = false; } break; case PlayerState.recover: if (stateActiveFrames[(int)PlayerState.recover] == 0) { lr.enabled = false; } break; case PlayerState.isDead: return; } if (m_flipEnemy != null && state == PlayerState.aim) { m_flipEnemy.ProcessFlip(false); _changeDir(); } }
IEnumerator DashAction(int nDashCount) { if (busy) { yield break; } busy = true; yield return(new WaitForSeconds(dashDelay)); //m_animator.SetInteger() for (int i = 0; i < nDashCount; i++) { Vector3 direction; if (OnlyHorizontalDash == true) { direction = (new Vector3(player.position.x, transform.position.y, player.position.z) - transform.position).normalized; } else { direction = (player.position - transform.position).normalized; } float timer = 0f; m_animator.SetInteger(m_nAnimatorChargingPara, 1); m_animator.SetInteger(m_nAnimatorAttackPara, 0); while (timer < dashInteval) { body.velocity = new Vector2(0, 0); timer += Time.deltaTime; yield return(new WaitForEndOfFrame()); } m_enemyFlip.ProcessFlip(true); yield return(new WaitForSeconds(rushDelay)); m_animator.SetInteger(m_nAnimatorChargingPara, 0); m_animator.SetInteger(m_nAnimatorAttackPara, 1); m_bDrawGizmos = true; timer = 0f; while (timer < dashDuration) { Vector3 vecSource = new Vector2(transform.position.x, transform.position.y - DashHitOffsetY); Physics2D.IgnoreCollision(box, playerBox, true); body.velocity = direction * dashSpeed; float fAngle = Vector2.SignedAngle(transform.position, player.position); Collider2D[] cols = Physics2D.OverlapBoxAll(vecSource + direction * (box.size.x + hitboxWidth), new Vector2(hitboxWidth * 2, box.size.y), fAngle); foreach (Collider2D col in cols) { if (col.CompareTag("player")) { playerControl.Die(); } } timer += Time.deltaTime; yield return(new WaitForEndOfFrame()); Physics2D.IgnoreCollision(box, playerBox, false); } m_animator.SetInteger(m_nAnimatorChargingPara, 0); m_animator.SetInteger(m_nAnimatorAttackPara, 0); m_bDrawGizmos = false; timer = 0f; body.velocity = Vector2.zero; } m_nBombCounts = 0; m_bThrowBomb = true; m_animator.SetInteger(m_nAnimatorChargingPara, 0); m_animator.SetInteger(m_nAnimatorAttackPara, 0); StartCoroutine(StartAttackTimer()); busy = false; }