void OnTriggerStay2D(Collider2D other)
    {
        if (damageCountdown > 0)
        {
            switch (other.tag)
            {
            case "Player":
                PlayerHealth    playerHealth     = other.GetComponent <PlayerHealth>();
                ActorPlayer     otherActorPlayer = other.GetComponent <ActorPlayer>();
                VibrateJoystick otherJoystick    = other.GetComponent <VibrateJoystick>();
                //Debug.Log("Hurt Player" + actorPlayer.input.facingDirection);
                playerHealth.Hurt(0, new Vector2(actorPlayer.inpt.facingDirection * 15 * DirectionalPush.x, input.AxisY() * DirectionalPush.y));
                otherJoystick.SetVibrating(true);
                otherActorPlayer.isStunned = true;
                jet.SmallRefill();
                break;

            case "Enemy":
                EnemyHealth enemyHealth = other.GetComponent <EnemyHealth>();
                if (enemyHealth != null)
                {
                    //Debug.Log("Hurt Enemy" + actorPlayer.input.facingDirection);
                    enemyHealth.Hurt(damage, actorPlayer.input.facingDirection);
                }
                break;
            }
        }
    }
Example #2
0
 void Awake()
 {
     maxHealth       = health;
     cc              = GetComponent <CharacterController2D>();
     invulCountdown  = 0;
     vibrateJoystick = GetComponent <VibrateJoystick>();
 }
Example #3
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     switch (collision.gameObject.tag)
     {
     case "Player":
         PlayerHealth    playerHealth   = collision.gameObject.GetComponent <PlayerHealth>();
         VibrateJoystick playerJoystick = collision.gameObject.GetComponent <VibrateJoystick>();
         playerJoystick.SetVibrating(true);
         playerHealth.Hurt(damage, (transform.rotation.eulerAngles.z <90 && transform.rotation.eulerAngles.z> -90)?1:-1);
         break;
     }
     Kill();
 }
Example #4
0
    /*private void OnTriggerStay2D(Collider2D other)
     * {
     *  int dir = (other.transform.position.x > transform.position.x) ? 1 : -1;
     *  vidajugador = other.GetComponentInParent<PlayerHealth>();
     *  if (vidajugador != null)
     *      vidajugador.Hurt(daño, dir);
     * }*/

    private void OnTriggerEnter2D(Collider2D other)
    {
        int dir = (other.transform.position.x > transform.position.x) ? 1 : -1;

        vidajugador     = other.GetComponentInParent <PlayerHealth>();
        vibrateJoystick = other.GetComponent <VibrateJoystick>();
        if (vidajugador != null)
        {
            vidajugador.Hurt(daño, dir);
        }
        if (vibrateJoystick)
        {
            vibrateJoystick.SetVibrating(true);
        }
    }