示例#1
0
        public void OnHurt(Damager damager, Damageable damageable)
        {
            //if the player don't have control, we shouldn't be able to be hurt as this wouldn't be fair
            if (!PlayerInput.Instance.HaveControl)
            {
                return;
            }

            UpdateFacing(damageable.GetDamageDirection().x > 0f);
            damageable.EnableInvulnerability();

            m_Animator.SetTrigger(m_HashHurtPara);

            //we only force respawn if helath > 0, otherwise both forceRespawn & Death trigger are set in the animator, messing with each other.
            if (damageable.CurrentHealth > 0 && damager.forceRespawn)
            {
                m_Animator.SetTrigger(m_HashForcedRespawnPara);
            }

            m_Animator.SetBool(m_HashGroundedPara, false);
            hurtAudioPlayer.PlayRandomSound();

            //if the health is < 0, mean die callback will take care of respawn
            if (damager.forceRespawn && damageable.CurrentHealth > 0)
            {
                StartCoroutine(DieRespawnCoroutine(false, true));
            }
        }
示例#2
0
        //Si es herido
        public void OnHurt(Damager damager, Damageable damageable)
        {
            //if the player don't have control, we shouldn't be able to be hurt as this wouldn't be fair
            if (!PlayerInput.Instance.HaveControl)
            {
                return;
            }
            //Actualice la cara segun la direccion del daño obtenido
            UpdateFacing(damageable.GetDamageDirection().x > 0f); //si es mayor a cero lanzo el ataque hacia la derecha y me impacto en la izquerda
            damageable.EnableInvulnerability();                   //activa invulnerabilidad
            //Trigger de daño recibido al animador
            m_Animator.SetTrigger(m_HashHurtPara);                //Llama a HurtSMB que activa el flickering

            //solo forzamos la reaparición si helath > 0, de lo contrario, los activadores forceRespawn y Death se establecen en el animador, jugando entre sí.
            //we only force respawn if helath > 0, otherwise both forceRespawn & Death trigger are set in the animator, messing with each other.
            if (damageable.CurrentHealth > 0 && damager.forceRespawn)
            {
                m_Animator.SetTrigger(m_HashForcedRespawnPara);
            }
            //piso falso
            m_Animator.SetBool(m_HashGroundedPara, false);
            hurtAudioPlayer.PlayRandomSound();
            // si la salud es < 0, significa muerte la devolución de llamada tomara cuidado de reaparecer
            //if the health is < 0, mean die callback will take care of respawn
            if (damager.forceRespawn && damageable.CurrentHealth > 0)
            {
                StartCoroutine(DieRespawnCoroutine(false, true));
            }
        }
示例#3
0
        public Vector2 GetHurtDirection()
        {
            Vector2 damageDirection = damageable.GetDamageDirection();

            if (damageDirection.y < 0f)
            {
                return(new Vector2(Mathf.Sign(damageDirection.x), 0f));
            }

            float y = Mathf.Abs(damageDirection.x) * m_TanHurtJumpAngle;

            return(new Vector2(damageDirection.x, y).normalized);
        }
示例#4
0
        //obtenga la direccion del daño
        public Vector2 GetHurtDirection()
        {   //Obtiene de damageable la direccion del daño
            Vector2 damageDirection = damageable.GetDamageDirection();

            //si el ataque viene desde encima retorne la direccion de X y 0 en Y
            if (damageDirection.y < 0f)
            {
                return(new Vector2(Mathf.Sign(damageDirection.x), 0f));
            }
            //Para Y = valor absoluto de la direccion es decir positivo * tangente del angulo configurado en el start
            float y = Mathf.Abs(damageDirection.x) * m_TanHurtJumpAngle; /*valor en posivito de x (osea hacia arriba, lo que genera la misma distancia para y)  *  por la tangente de angulo 45 que es 1,
                                                                          * posteriormente multiplicado por la amplitud llamada hurtJumpSpeed en HurtSMB*/

            return(new Vector2(damageDirection.x, y).normalized);        //es clave normalizar ya que pequeños valores los transforma a escalar 1
        }