private IEnumerator ToCombat() { controlable = false; enemyAnim.SetBool("Combat", true); yield return(waitForSworddraw); controlable = true; actionState = CharacterState.COMBAT; aIActionPhase = AIActionPhase.MOVETOPLAYER; }
private IEnumerator ToNormal() { controlable = false; enemyAnim.SetBool("Combat", false); enemyAnim.SetBool("MoveForward", false); yield return(waitForSworddraw); controlable = true; actionState = CharacterState.NORMAL; aIActionPhase = AIActionPhase.NONE; }
protected override void OnTakeDamage() { enemyAnim.SetTrigger("TakeDamage"); float decreastPosition = 0; if (isInvertFacing) { decreastPosition = (currentFacing) ? -moveBackScale : moveBackScale; } else { decreastPosition = (currentFacing) ? moveBackScale : -moveBackScale; } predictPosition = new Vector3(transform.position.x + decreastPosition, transform.position.y, transform.position.z); settingMoveSpeed = moveBackSpeed; isMoveBack = true; aIActionPhase = AIActionPhase.MOVEBACK; enemyAnim.SetBool("MoveForward", false); }
protected override void OnCombat() { base.OnCombat(); GameCore.combatController.isEnemyAttacking = isAttacking; GameCore.combatController.isEnemyParrying = isParring; if (controlable) { if (!m_enemyRayChecker.canCombat || GameCore.combatController.isPlayerDead) { StartCoroutine(ToNormal()); return; } if (GameCore.combatController.canCombat || m_enemyRayChecker.canCombat) { switch (aIActionPhase) { case AIActionPhase.MOVETOPLAYER: if (!isMoveAndAttack) { if (distanceBetweenPlayer > savePosition) { isMoving = true; var direction = (isInvertFacing) ? -1 : 1; FightStep((sbyte)direction); enemyAnim.SetBool("MoveForward", true); } else { enemyAnim.SetBool("MoveForward", false); if (haveAttackPredict) { if (!GameCore.combatController.isPlayerAttacking) { isMoveAndAttack = true; } } else { isMoveAndAttack = true; } } } else { if (distanceBetweenPlayer > attackPosition) { isMoving = true; var direction = (isInvertFacing) ? -1 : 1; FightStep((sbyte)direction); enemyAnim.SetBool("MoveForward", true); } else { enemyAnim.SetBool("MoveForward", false); aIActionPhase = AIActionPhase.ATTACK; } } break; case AIActionPhase.ATTACK: if (distanceBetweenPlayer < attackPosition) { aIActionPhase = AIActionPhase.MOVETOPLAYER; } if (GameCore.combatController.isPlayerAttacking && fightParryDelayCounter <= Time.time && isAttacking) { fightParryDelayCounter = Time.time + fightParryDelay; if (Random.value <= fightParryChance) { FightParry(); } } else if (isReayAttack) { if (Random.value <= fightAttackChance && fightAttackDelayCounter <= Time.time) { fightAttackDelayCounter = Time.time + fightAttackDelay; isAttacking = true; enemyAnim.SetTrigger("Attack"); isReayAttack = false; } } break; case AIActionPhase.MOVEBACK: if (isMoveBack) { isMoving = true; isMoveBack = false; } else if (!isMoving) { aIActionPhase = AIActionPhase.NONE; } break; case AIActionPhase.NONE: if (!GameCore.combatController.isPlayerAttacking) { Invoke("ToMovePhase", 1f); } break; } } else { StartCoroutine(ToNormal()); } } }
protected override void OnStart() { base.OnStart(); aIActionPhase = AIActionPhase.NONE; isReayAttack = true; }
private void ToMovePhase() { aIActionPhase = AIActionPhase.MOVETOPLAYER; }