IEnumerator OnTriggerEnter(Collider col) { if (col.gameObject.tag == power_tag) { life--; if (life == 0) { GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0); GetComponent <GolenMoviment>().enabled = false; sound.playDieSound(false); anim.SetTrigger("Die"); yield return(new WaitForSeconds(10f)); Destroy(gameObject); } bool is_atack = golen_atack.is_atack; if (is_atack) { sound.playDamageSound(false); anim.SetTrigger("Damage"); yield return(new WaitForSeconds(1f)); anim.SetTrigger("Atack"); sound.playAtackSound(false); } else { GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0); sound.playDamageSound(false); anim.SetTrigger("Damage"); GetComponent <GolenMoviment>().enabled = false; yield return(new WaitForSeconds(1f)); anim.SetTrigger("Walk"); GetComponent <GolenMoviment>().enabled = true; sound.playWalkSound(true); } } else { if (col.gameObject.tag == "firestorm") { if (is_alive) { life--; // Debug.Log(life); if (life == 0) { GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0); GetComponent <GolenMoviment>().enabled = false; golen_atack.is_atack = false; //yield return new WaitForSeconds(.5f); GetComponent <Rigidbody>().AddForce(new Vector3(0, 0, 250)); yield return(new WaitForSeconds(.5f)); GetComponent <Rigidbody>().velocity = new Vector3(0, 0, 0); sound.playDieSound(false); anim.SetTrigger("Die"); GetComponent <SphereCollider>().enabled = false; yield return(new WaitForSeconds(10f)); Destroy(gameObject); } else { if (life > 0) { GetComponent <GolenMoviment>().enabled = false; golen_atack.is_atack = false; sound.playDamageSound(false); anim.SetTrigger("Damage"); GetComponent <Rigidbody>().AddForce(new Vector3(0, 0, 250)); yield return(new WaitForSeconds(1f)); anim.SetTrigger("Walk"); GetComponent <Rigidbody>().velocity = (new Vector3(0, 0, 0)); GetComponent <GolenMoviment>().enabled = true; } } } } } }
//public bool is_start_magic = false; IEnumerator Start() { atk_scope_anim = GetComponent <Animation>(); sound = GetComponent <GolenSoundController>(); player = GameObject.FindGameObjectWithTag("player_damage").GetComponent <PlayerDamage>(); while (true) { if (currentGesture == "CLOSE") { // Debug.Log("Starting Magic"); sound.playRoarSound(false); StartCoroutine(StartMagic()); hand_magic_atack.SetActive(true); yield return(new WaitForSeconds(5f)); hand_magic_atack.SetActive(false); StopCoroutine(StartMagic()); sound.stopRoarSound(false); // Debug.Log("Ending_Magic"); } /* * if (currentGesture == "THUMB") * { * Debug.Log("Starting Defense"); * hand_magic_defense.SetActive(true); * StartCoroutine(StartDefense()); * yield return new WaitForSeconds(5f); * hand_magic_defense.SetActive(false); * StopCoroutine(StartDefense()); * Debug.Log("Ending_Defense"); * } */ stateMachine = currentGesture; yield return(new WaitForSeconds(.2F)); } IEnumerator StartMagic() { while (true) { string secont_gesture = currentGesture; if (secont_gesture == "OPEN") { hand_magic_atack.SetActive(false); sound.stopRoarSound(false); sound.playAtackSound(false); //Debug.Log("Shooting"); Instantiate_Prefab(fireball, right_scope.transform.position); // Debug.Log("BOLA DE FOGO, METEOOOORO"); //yield return new WaitForSeconds(.5f); break; } if (secont_gesture == "LOVE") { hand_magic_atack.SetActive(false); defense_fire.SetActive(true); sound.stopRoarSound(false); sound.playAtackSound(false); yield return(new WaitForSeconds(2f)); defense_fire.SetActive(false); break; } yield return(new WaitForSeconds(.1f)); } } }