void ataqueCargado() { stateInfoAtaqueCargado = anim.GetCurrentAnimatorStateInfo(0); atacando = stateInfoAtaqueCargado.IsName("Jugador_Slash"); if (Input.GetKeyDown(KeyCode.LeftAlt)) { anim.SetTrigger("cargando"); movePrevent = true; aura.AuraStart(); } else { if (Input.GetKeyUp(KeyCode.LeftAlt)) { anim.SetTrigger("atacando"); if (aura.IsLoaded()) { angulo = Mathf.Atan2(anim.GetFloat("movY"), anim.GetFloat("movX")) * Mathf.Rad2Deg; slashObj = Instantiate(slashCargado, transform.position, Quaternion.AngleAxis(angulo, Vector3.forward)); slash = slashObj.GetComponent <Slash>(); slash.mov.x = anim.GetFloat("movX"); slash.mov.y = anim.GetFloat("movY"); } aura.AuraStop(); StartCoroutine(habilitarMovimiento(0.2f)); } } }
void SlashAttack() { AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0); bool loading = stateInfo.IsName("Player_Slash"); if (Input.GetKeyDown(KeyCode.LeftAlt) && manabar.Usable(20)) { anim.SetTrigger("loading"); aura.AuraStart(); } else if (Input.GetKeyUp(KeyCode.LeftAlt) && manabar.Usable(20)) { anim.SetTrigger("attacking"); if (aura.IsLoaded()) { float angle = Mathf.Atan2(anim.GetFloat("movY"), anim.GetFloat("movX")) * Mathf.Rad2Deg; GameObject slashObj = Instantiate(slashPrefab, transform.position, Quaternion.AngleAxis(angle, Vector3.forward)); Slash slash = slashObj.GetComponent <Slash>(); slash.mov.x = anim.GetFloat("movX"); slash.mov.y = anim.GetFloat("movY"); manabar.Gastar(20); } aura.AuraStop(); StartCoroutine(EnableMovementAfter(0.4f)); } if (loading) { movePrevent = true; } }
void SlashAttack() { // Buscamos el estado actual mirando la información del animador AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0); bool charging = stateInfo.IsName("p_slash"); // Ataque a distancia if (Input.GetKeyDown(KeyCode.R)) { anim.SetTrigger("charging"); aura.AuraStart(); AudioPlayer.clip = SwordCharge; AudioPlayer.Play(); AudioPlayer.loop = true; } else if (Input.GetKeyUp(KeyCode.R)) { AudioPlayer.loop = false; anim.SetTrigger("attacking"); if (aura.IsLoaded()) { // Para que se mueva desde el principio tenemos que asignar un // valor inicial al movX o movY en el edtitor distinto a cero AudioPlayer.clip = SwordSlash; AudioPlayer.Play(); float angle = Mathf.Atan2( anim.GetFloat("movY"), anim.GetFloat("movX") ) * Mathf.Rad2Deg; GameObject slashObj = Instantiate( slashPrefab, transform.position, Quaternion.AngleAxis(angle, Vector3.forward) ); Slash slash = slashObj.GetComponent <Slash>(); slash.mov.x = anim.GetFloat("movX"); slash.mov.y = anim.GetFloat("movY"); } aura.AuraStop(); StartCoroutine(EnableMovementAfter(0.4f)); } // Prevenimos el movimiento mientras cargamos if (charging) { movePrevent = true; } }
void SlashAttack() { // Buscamos el estado actual mirando la información del animador stateInfo = anim.GetCurrentAnimatorStateInfo(0); attacking = stateInfo.IsName("Player_Attack"); loading = stateInfo.IsName("Player_Slash"); // Ataque a distancia if (Input.GetButton("Attack") && !attacking && !PauseMenu.gameIsPaused) { movePrevent = true; chargedAttackTime += Time.deltaTime; anim.SetTrigger("loading"); if (chargedAttackTime >= aura.getTimeBeforePlay()) { aura.AuraStart(); } } else if (aura.IsLoaded() && !attacking && !PauseMenu.gameIsPaused) { chargedAttackTime = 0.0f; anim.SetTrigger("attacking"); float vol = UnityEngine.Random.Range(volLowRange, volHighRange); source.PlayOneShot(swordSlashClip, vol); // Para que se mueva desde el principio tenemos que asignar un // valor inicial al movX o movY en el edtitor distinto a cero float angle = Mathf.Atan2( anim.GetFloat("movY"), anim.GetFloat("movX") ) * Mathf.Rad2Deg; GameObject slashObj = Instantiate( slashPrefab, transform.position, Quaternion.AngleAxis(angle, Vector3.forward) ); Slash slash = slashObj.GetComponent <Slash>(); slash.mov.x = anim.GetFloat("movX"); slash.mov.y = anim.GetFloat("movY"); aura.AuraStop(); StartCoroutine(EnableMovementAfter(0.4f)); } else { StartCoroutine(EnableMovementAfter(0.4f)); } }
void SlashAttack() { // Buscamos el estado actual mirando la información del animador AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0); bool loading = stateInfo.IsName("Player_Slash"); // Ataque a distancia if (Input.GetKeyDown("n")) { sfxMAn.PlayerPowerCharging.Play(); anim.SetTrigger("Loading"); aura.AuraStart(); } else if (Input.GetKeyUp("n")) { anim.SetTrigger("Attacking"); if (aura.IsLoaded()) { sfxMAn.PlayerPowerRelease.Play(); // Para que se mueva desde el principio tenemos que asignar un // valor inicial al movX o movY en el edtitor distinto a cero float angle = Mathf.Atan2( anim.GetFloat("movY"), anim.GetFloat("movX") ) * Mathf.Rad2Deg; GameObject slashObj = Instantiate( SlashPrefab, transform.position, Quaternion.AngleAxis(angle, Vector3.forward) ); Slash slash = slashObj.GetComponent <Slash>(); slash.mov.x = anim.GetFloat("movX"); slash.mov.y = anim.GetFloat("movY"); } aura.AuraStop(); // esperar momentos y reactivar movimiento StartCoroutine(EnableMovementAfter(0.4f)); } // Prevenimos el movimiento mientras cargamos if (loading) { movPrevent = true; } }
void AtaqueHechizo() { //buscamos el estado actual del jugador con la informacion del animador AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0); bool loading = stateInfo.IsName("Player_Hechizo"); //comprueba si esta esta animacion //detectamos el ataque va abajo de todo por la prioridad if (Input.GetKeyDown(KeyCode.LeftShift)) //comprueba si apreto la tecla y si no estoy atacando ya { anim.SetTrigger("Loading"); //seteo el trigger a true aura.AuraStart(); //pone la animacion del aura a funcionar } else if (Input.GetKeyUp(KeyCode.LeftShift)) { anim.SetTrigger("Idle"); if (aura.IsLoaded()) //si esta cargada el aura crea la instancia del hechizo //conseguir rotacion de un vector { float angle = Mathf.Atan2(anim.GetFloat("movY"), anim.GetFloat("movX")) * Mathf.Rad2Deg; //siempre eje Y primero y la ultima funcion pasa de radianes a grados //instanciamos el hechizo pasamos prefab la pos del jugador el angulo o direccion vector forward siemore es hacia adelante GameObject hechizoObj = Instantiate(hechizoPrefab, transform.position, Quaternion.AngleAxis(angle, Vector3.forward)); //le damos movimiento llamando a su funcion de hechizo.cs le seteamos al vector 2 los valores almacenados en el blend tree de walking Hechizo hechizo = hechizoObj.GetComponent <Hechizo> (); hechizo.mov.x = anim.GetFloat("movX"); hechizo.mov.y = anim.GetFloat("movY"); } aura.AuraStop(); //detiene la animacion del aura //esperamos un poco antes de darle movimiento otra vez StartCoroutine(EnableMovAfter(0.4f)); } //privamos el movimiento al estar cargando if (loading) { movePrevent = true; } }
void UpdateChargedAttack() { AnimatorStateInfo stateInfo = anim.GetCurrentAnimatorStateInfo(0); bool chargingAttack = stateInfo.IsName("Player Charge"); if (Input.GetKeyDown(KeyCode.LeftAlt)) { anim.SetTrigger("charging"); aura.AuraStart(); } else if (Input.GetKeyUp(KeyCode.LeftAlt)) { anim.SetTrigger("attacking"); if (aura.IsCharged()) { float angle = Mathf.Atan2(anim.GetFloat("movY"), anim.GetFloat("movX")) * Mathf.Rad2Deg; GameObject slashObj = Instantiate(slashPrefab, transform.position, Quaternion.AngleAxis(angle, Vector3.forward)); Slash slash = slashObj.GetComponent <Slash> (); slash.mov.x = anim.GetFloat("movX"); slash.mov.y = anim.GetFloat("movY"); } aura.AuraStop(); StartCoroutine(EnableMovementAfter(0.4f)); } if (chargingAttack) { preventMovement = true; } }