/// <summary> /// Cette méthode permet de détecter le changement et la fin d'une animation (lorsque l'on est en mode combat). Ainsi on peut repasser le booléen Attacking à 'false'. /// </summary> private void CheckEndOfAttackAnimation() { var state = CharAnimator.GetCurrentAnimatorStateInfo(0); if (Attacking) { if (!_checkEndAnim) { if (_currentAttackState != state.nameHash) { _currentAttackState = state.nameHash; _checkEndAnim = true; } } else if (_currentAttackState != state.nameHash || (state.normalizedTime > 1 && !CharAnimator.IsInTransition(0))) { ActivateEndOfAnimationTrigger = false; Attacking = false; _checkEndAnim = false; StartCoroutine(WaitAndRandomAction(Random.Range(0.5f, 1.5f))); } } else { _currentAttackState = state.nameHash; } }
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 override void Animation() { if (!Grounded && !Climbing) { CharAnimator.jump(true); } else { CharAnimator.jump(false); } if ((Rigbody.velocity.x != 0) && Grounded) { CharAnimator.walk(Mathf.Abs(Rigbody.velocity.x)); } else { CharAnimator.walk(Mathf.Abs(0)); } if (Climbing) { CharAnimator.climb(Mathf.Abs(Rigbody.velocity.x + Rigbody.velocity.y)); } else { CharAnimator.climb(Mathf.Abs(Rigbody.velocity.x + Rigbody.velocity.y)); } }
public virtual IEnumerator Idle(float time) { CharAnimator.SetFloat("speed", 0); CurrentAction = EnemyActions.Idle; yield return(new WaitForSeconds(time)); RandomAction(); }
protected override void Die() { base.Die(); CharAnimator.die(true); AudioManager.instance.PlaySoundFX(1); AudioManager.instance.PlaySoundTrack(1); GameManager.instance.IsOver = true; }
void Start() { charSlot = GetComponentInParent <CharSlot>(); entityColor = GetComponentInChildren <EntityColor>(); charAnimator = GetComponent <CharAnimator>(); type = tag; vidaAtual = vidaMax; SetupUIBar(); KillCount = 0; LastKillCount = 0; }
protected IEnumerator AttackWithBlast(int nbBlast) { while (nbBlast != 0) { --nbBlast; CharAnimator.SetTrigger("blast"); var rot = Quaternion.LookRotation(transform.position - MyCharacterController.Instance.transform.position); var blast = Resources.Load <GameObject>("Prefabs/Fireball"); Instantiate(blast, RightAttack ? RightHand.position : LeftHand.position, rot); RightAttack = !RightAttack; Audio.PlayOneShot(Resources.Load <AudioClip>("Sounds/kiblast")); yield return(new WaitForSeconds(0.6f)); } Attacking = false; 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)); // } //} }
/// <summary> /// Méthode qui permet de gérer les encaissement de notre personnage ainsi que ses esquives /// </summary> public override void ApplyDamage(TakeDamageModel model) { base.ApplyDamage(model); var relativePos = MyCharacterController.Instance.transform.position - transform.position; var lookRot = Quaternion.LookRotation(relativePos); transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, lookRot.eulerAngles.y, transform.rotation.eulerAngles.z); if (!model.Default) { var dodge = (model.CanDodge && Random.value <= DodgeProbability); CharAnimator.SetBool("dodge", dodge); CharAnimator.SetBool("hit_right_attack", model.RightAttack); switch (model.AttackTypes) { case AttackTypes.Weak: { CharAnimator.SetTrigger("hit_weak_attack"); if (!dodge) { ActivateEndOfHitAnimationTrigger = true; GettingHit = true; Life -= (200 * model.AttackMultiplicator); PlayRandomPainAudioClip(); if (_weakHitParticle == null) { _weakHitParticle = Resources.Load <GameObject>("Particles/CFX_Prefabs_Mobile/Hits/CFXM_Hit_A Red"); } if (_weakHitParticle != null) { Instantiate(_weakHitParticle, transform.position, Quaternion.identity); } ApplyExpulsion(transform.forward * 5); } else { Dodge(); } } break; case AttackTypes.Medium: { CharAnimator.SetTrigger("hit_medium_attack"); if (!dodge) { GettingHit = true; Life -= 300; PlayRandomPainAudioClip(); if (_mediumHitParticle == null) { _mediumHitParticle = Resources.Load <GameObject>("Particles/CFX_Prefabs_Mobile/Hits/CFXM_Hit_A Red"); } if (_mediumHitParticle != null) { Instantiate(_mediumHitParticle, transform.position, Quaternion.identity); } StartCoroutine(WaitAndRandomAction(Random.Range(0.5f, 1.5f))); } else { Dodge(); } } break; case AttackTypes.Strong: { CharAnimator.SetTrigger("hit_strong_attack"); ActivateEndOfHitAnimationTrigger = true; GettingHit = true; Life -= 4000; PlayRandomPainAudioClip(); if (_weakHitParticle == null) { _weakHitParticle = Resources.Load <GameObject>("Particles/CFX_Prefabs_Mobile/Hits/CFXM_Hit_A Red"); } Instantiate(_weakHitParticle, transform.position, Quaternion.identity); } break; case AttackTypes.Combo: CharAnimator.SetTrigger("hit_punch_combo"); ActivateEndOfHitAnimationTrigger = true; GettingHit = true; Life -= 7000; PlayRandomPainAudioClip(); if (_weakHitParticle == null) { _weakHitParticle = Resources.Load <GameObject>("Particles/CFX_Prefabs_Mobile/Hits/CFXM_Hit_A Red"); } Instantiate(_weakHitParticle, transform.position, Quaternion.identity); break; } } else { CharAnimator.SetBool("dodge", false); // L'attaque possède la propriété "Default" a true, cela signifie qu'elle a été générée probablement via un animation event // On va devoir donc retrouver les propriètés de l'attaque uniquement grâce au nom de la capacité. switch (model.SkillName) { case "dash_attack": { GettingHit = true; Life -= 100; // _animator.Play("ReceivePunchComboAttack"); RandomAction(); } break; case "sword_combo_1": { GettingHit = true; Life -= 200; CharAnimator.Play("ReceivePunchComboAttack"); Rigidbody.AddForce(Vector3.up * 10f); RandomAction(); } break; //case "weak_combo": // { // StartCoroutine(PlayComboAttackHit()); // Life -= 200; // } // break; //case "throw": // Instantiate(Resources.Load("CFXM_Text Wham"), transform.position, Quaternion.identity); // CharAnimator.SetBool("swung", true); // Life -= 200; // GettingHit = false; // RandomAction(); // break; //case "kiai": // Instantiate(Resources.Load("CFXM_Text Wham"), transform.position, Quaternion.identity); // CharAnimator.SetTrigger("hit_kiai"); // Life -= 30; // GettingHit = false; // RandomAction(); // break; //case "low_kick": // Life -= 50; // var hit = Resources.Load("CFXPrefabs_Mobile/Hits/CFXM_Hit_C White") as GameObject; // Instantiate(hit, transform.position, Quaternion.identity); // _animator.Play("ReceiveLowKick"); // _gettingHit = false; // RandomAction(); // break; //case "spiral_kick": // Life -= 300; // var boum = Resources.Load("CFXPrefabs_Mobile/Texts/CFXM_Text Boom") as GameObject; // Instantiate(boum, transform.position, Quaternion.identity); // var dir = (transform.position - MyCharacterController.Instance.transform.position).normalized; // dir.y = 1; // rigidbody.AddForce(dir * 350f); // RandomAction(); // break; //case "projection_up_kick": // Life -= 300; // rigidbody.AddForce(transform.up * 1000); // CharAnimator.Play("Hit Blow Back"); // break; //case "kamehameha": // Life -= 1000; // var direction = transform.position - model.Emitter.position; // rigidbody.AddForce(direction * 100); // break; default: Debug.LogError(string.Format("Technque inconnue: {0}", model.SkillName)); break; } } }