public void attackFinished()
    {
        //attackDone = true;
        Collider2D hitBomb = Physics2D.OverlapCircle(hitSpace.transform.position, 0.3f, 1 << LayerMask.NameToLayer("Bomb"));

        if (hitBomb != null)
        {
            bombFunctions bomb = hitBomb.gameObject.GetComponent("bombFunctions") as bombFunctions;
            bomb.explode();
        }


        Collider2D hit = Physics2D.OverlapCircle(hitSpace.transform.position, 0.40f, 1 << LayerMask.NameToLayer("Player"));

        if (hit != null)
        {
            if (blood != null)
            {
                GameObject b = (GameObject)Instantiate(blood);
                b.transform.position = new Vector2(hit.gameObject.transform.position.x, hit.gameObject.transform.position.y);


                Vector3 dir = transform.position - blood.transform.position;
                dir.z = 0; dir.Normalize();
                float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
                b.transform.rotation = Quaternion.Slerp(blood.transform.rotation, Quaternion.Euler(0, 0, angle), 1f);
            }


            stats tStats = hit.gameObject.GetComponent("stats") as stats;
            tStats.damage(gameObject);
        }

        anim.SetBool("IsAttacking", false);
    }
Exemple #2
0
    public void attackFinished()
    {
        attackDone = true;


        Collider2D hitBomb = Physics2D.OverlapCircle(hitSpace.transform.position, 0.20f, 1 << LayerMask.NameToLayer("Bomb"));

        if (hitBomb != null)
        {
            bombFunctions bomb = hitBomb.gameObject.GetComponent("bombFunctions") as bombFunctions;
            bomb.explode();
        }

        float hitRadius = 0.25f;

        if (stat.isMonster)
        {
            hitRadius = 0.4f;
        }
        Collider2D hit = Physics2D.OverlapCircle(hitSpace.transform.position, hitRadius, 1 << LayerMask.NameToLayer("Victim"));

        if (hit != null)
        {
            Brain      temp  = hit.gameObject.GetComponent("Brain") as Brain;
            GameObject blood = (GameObject)Instantiate(temp.blood);
            blood.transform.position = new Vector2(hit.gameObject.transform.position.x, hit.gameObject.transform.position.y);


            Vector3 dir = transform.position - blood.transform.position;
            dir.z = 0; dir.Normalize();
            float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
            blood.transform.rotation = Quaternion.Slerp(blood.transform.rotation, Quaternion.Euler(0, 0, angle), 1f);

            stats tStats = hit.gameObject.GetComponent("stats") as stats;
            tStats.damage(gameObject);
        }
    }