예제 #1
0
 void Attack()
 {
     timer = 0f;
     if (playerHealth.currentHealth > 0)
     {
         playerHealth.TakeDamage(attackDamage);
     }
 }
예제 #2
0
    private void OnTriggerEnter2D(Collider2D hitInfo)
    {
        health Health = hitInfo.GetComponent <health>();

        if (Health != null)
        {
            Health.TakeDamage();
        }
    }
    /// <summary>
    /// This function works  when there is collision with the shootable layer and calls the TakeDamage function.
    /// </summary>
    /// <param name="collision"></param>
    public void OnCollisionEnter(Collision collision)
    {
        GameObject hit    = collision.transform.parent.gameObject;
        health     health = hit.GetComponent <health>();

        if (health != null)
        {
            health.TakeDamage(10);
        }
    }
예제 #4
0
    void OnCollisionEnter(Collision other)
    {
        if (!isServer)
        {
            return;
        }
        if (!juji)
        {
            if (isplayerout)
            {
                if ((transform.position - me.transform.position).sqrMagnitude >= 30000)
                {
                    return;
                }
            }
        }
        GameObject hit     = other.gameObject;
        player     player1 = hit.GetComponent <player>();
        health     health  = hit.GetComponent <health>();
        defendjh   jh      = hit.GetComponent <defendjh>();

        if (hit != me)
        {
            if (health != null)
            {
                if (player1.isleaving)
                {
                    player1.nodemage = true;
                }
                if (player1.nodemage)
                {
                    Destroy(gameObject);
                    return;
                }
                if (health.isdeath)
                {
                    return;
                }
                health.TakeDamage(4);
                Destroy(gameObject);
            }
            if (jh != null)
            {
                if (isred1 != hit.GetComponent <defendjh>().isred)
                {
                    jh.TakeDamage(10);
                    Destroy(gameObject);
                }
            }
        }
    }
예제 #5
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        health health = hitInfo.GetComponent <health>();

        if (health != null)
        {
            if (health.currentHealth > 0)
            {
                health.TakeDamage(damage);
            }

            Debug.Log(health.name + " " + damage + " " + health.currentHealth);

            var impact = Instantiate(impactEffect, transform.position, transform.rotation);

            Destroy(gameObject);
            Destroy(impact, 1);
        }
    }