Exemplo n.º 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //Debug.Log(collision.transform.name);
        if (collision.transform.CompareTag("Enemy") && collision.transform.GetComponent <Insect>())
        {
            Insect collider = collision.transform.GetComponent <Insect>();

            TakeDamage(collider.CollisionDamage, collision.GetComponent <Insect>().GetCollisionVelocity(transform, rb.velocity));
            collider.TakeDamage(GetComponent <Insect>().CollisionDamage);
        }
    }
Exemplo n.º 2
0
    IEnumerator Dps()
    {
        // Delay before first damage
        yield return(new WaitForSeconds(Delay));


        while (appliedTimes < ApplyDamageNTimes)
        {
            print("Damaged!!");
            entity.TakeDamage(Damage);
            yield return(new WaitForSeconds(ApplyEveryNSeconds));

            appliedTimes++;
            print("appliedTimes!");
        }

        Destroy(this);
    }
Exemplo n.º 3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Honeycomb"))
        {
            //Destroy(collision.gameObject);
            if (honeycombBounce)
            {
                Vector2 velocity = GetComponent <Rigidbody2D>().velocity;
                Vector2 normal   = collision.transform.position - transform.position;
            }
            else
            {
                HoneycombPos hexPos = Utility.WorldPointToHoneycombGrid(collision.GetComponent <Honeycomb>().honeyGrid.position);
                collision.GetComponent <Honeycomb>().DamageHoneycomb(Damage);
                if (false) //for testing HoneycombPos.GetAdjecentHoneycomb()
                {
                    Map.StaticMap.GetHoneycomb(hexPos.GetAdjecentHoneycomb(0, 1)).honeycomb.GetComponent <Honeycomb>().DamageHoneycomb(10);
                    Map.StaticMap.GetHoneycomb(hexPos.GetAdjecentHoneycomb(1, 1)).honeycomb.GetComponent <Honeycomb>().DamageHoneycomb(10);
                    Map.StaticMap.GetHoneycomb(hexPos.GetAdjecentHoneycomb(1, -1)).honeycomb.GetComponent <Honeycomb>().DamageHoneycomb(10);
                    Map.StaticMap.GetHoneycomb(hexPos.GetAdjecentHoneycomb(0, -1)).honeycomb.GetComponent <Honeycomb>().DamageHoneycomb(10);
                    Map.StaticMap.GetHoneycomb(hexPos.GetAdjecentHoneycomb(-1, -1)).honeycomb.GetComponent <Honeycomb>().DamageHoneycomb(10);
                    Map.StaticMap.GetHoneycomb(hexPos.GetAdjecentHoneycomb(-1, 1)).honeycomb.GetComponent <Honeycomb>().DamageHoneycomb(10);
                }
                Destroy(gameObject);
            }
        }

        if (collision.transform.CompareTag("Enemy") && collision.transform.GetComponent <Insect>())
        {
            Insect collider = collision.transform.GetComponent <Insect>();


            collider.TakeDamage(Damage);
            FindObjectOfType <LevelHandler>().UpdatePlayerStats(1, 0);
            Destroy(gameObject);
        }
    }