public virtual void UpdateMoveHandToHand() { //Debug.Log("UpdateMoveHandToHand"); //Debug.Log("CloseCombat: " + CloseCombat); if (Grounded) { if (CloseCombat || !CanMove && NavMeshAgent != null) { CurrentAction = EnemyActions.Idle; if (NavMeshAgent.isActiveAndEnabled) { NavMeshAgent.Stop(); } Rigidbody.velocity = Vector3.zero; if (CanAttack) { StartCoroutine(Attack()); } } else { if (CharAnimator != null) { CharAnimator.SetFloat("speed", 1); } if (NavMeshAgent != null && NavMeshAgent.isActiveAndEnabled && NavMeshAgent.isOnNavMesh) { NavMeshAgent.SetDestination(MyCharacterController.Instance.transform.position); } } } }
public virtual IEnumerator Idle(float time) { CharAnimator.SetFloat("speed", 0); CurrentAction = EnemyActions.Idle; yield return(new WaitForSeconds(time)); RandomAction(); }
public virtual IEnumerator Attack(float waitTimeBeforeAttack = 0) { if (Attacking) { yield break; } else { CharAnimator.SetFloat("speed", 0); if (waitTimeBeforeAttack > 0) { yield return(new WaitForSeconds(waitTimeBeforeAttack)); } CurrentAction = EnemyActions.Attack; Attacking = true; } if (CloseCombat) { //if (MyCharacterController.Instance.Grounded && MyCharacterController.Instance.KoManager.Ko) //{ // ActivateEndOfAnimationTrigger = true; // var kickAttack = (Random.value < 0.5f); // if (kickAttack) // { // CharAnimator.SetTrigger("bottom_weak_attack_punch"); // MyCharacterController.Instance.TakeDamage("bottom_weak_attack2", 50f, transform); // } // else // { // CharAnimator.SetTrigger("bottom_weak_attack_kick"); // MyCharacterController.Instance.TakeDamage("bottom_weak_attack1", 50f, transform); // } // audio.PlayOneShot(Resources.Load<AudioClip>("Sounds/meleeJab2")); //} //if (Random.value < 0.5f) //{ ActivateEndOfAnimationTrigger = true; var kickAttack = (Random.value < 0.5f); if (kickAttack) { CharAnimator.SetTrigger("weak_attack_punch"); var weakAttackName = RightAttack ? "right_weak_attack1" : "left_weak_attack1"; MyCharacterController.Instance.TakeDamage(weakAttackName, 50f, transform); } else { CharAnimator.SetTrigger("weak_attack_kick"); var weakAttackName = RightAttack ? "right_weak_attack2" : "left_weak_attack2"; MyCharacterController.Instance.TakeDamage(weakAttackName, 50f, transform); } //audio.PlayOneShot(Resources.Load<AudioClip>("Sounds/meleeJab2")); RightAttack = !RightAttack; //} //else //{ // var rand = Random.value; // if (rand <= 0.33f) // { // ActivateEndOfAnimationTrigger = true; // CharAnimator.Play("Combo1"); // MyCharacterController.Instance.TakeDamage("combo1", 150f, transform); // audio.PlayOneShot(Resources.Load<AudioClip>("Sounds/pain2")); // audio.PlayOneShot(Resources.Load<AudioClip>("Sounds/mediumkick")); // yield return new WaitForSeconds(0.34f); // audio.PlayOneShot(Resources.Load<AudioClip>("Sounds/mediumpunch")); // yield return new WaitForSeconds(0.4f); // audio.PlayOneShot(Resources.Load<AudioClip>("Sounds/powerHit6")); // yield return new WaitForSeconds(0.3f); // audio.PlayOneShot(Resources.Load<AudioClip>("Sounds/mediumkick")); // } // else if (rand <= 0.66f) // { // yield return StartCoroutine(Combo2()); // } //} } //else //{ // if (Random.value < 0.33 && SpecialDistanceAttackEnabled) // { // yield return StartCoroutine(CastSpecialDistanceAttack()); // } // else // { // var nbBlast = Random.Range(4, 6) + 1; // yield return StartCoroutine(AttackWithBlast(nbBlast)); // } //} }