Ejemplo n.º 1
0
    public void EnemyCollision(RaycastHit2D hit, ArrowMoviment arrow)
    {
        EnemyPart ep = hit.collider.gameObject.GetComponent <EnemyPart>();

        if (!ep._enemy.dead)
        {
            FindObjectOfType <AudioManager>().Play("basicArrow");
            communAction(arrow);
            ep.hit(damage, GameController.arrowsType.basic);
            arrow.transform.SetParent(ep.transform);

            if (ArrowDamage)
            {
                Instantiate(ArrowDamage, hit.collider.transform.position, Quaternion.identity);
            }
            Destroy(arrow.gameObject, 8);
        }
    }
Ejemplo n.º 2
0
    public void EnemyCollision(RaycastHit2D hit, ArrowMoviment arrow)
    {
        EnemyPart ep = hit.collider.gameObject.GetComponent <EnemyPart>();

        if (!ep._enemy.dead)
        {
            if (ArrowDamage)
            {
                Instantiate(ArrowDamage, hit.collider.transform.position, Quaternion.identity);
            }

            if (!partsHited.Contains(ep))
            {
                FindObjectOfType <AudioManager>().Play("piercingArrow");
                partsHited.Add(ep);
                ep.hit(damage, GameController.arrowsType.piercing);
            }
        }
    }
Ejemplo n.º 3
0
    void communAction(ArrowMoviment arrow)
    {
        Instantiate(explosionParticle, transform.position, Quaternion.identity);
        RaycastHit2D[] callisions = Physics2D.CircleCastAll(transform.position, explosionRadio, new Vector2(1, 1), 0, arrow.targetLayerMask);

        for (int i = 0; i < callisions.Length; i++)
        {
            GameObject go = callisions[i].collider.gameObject;
            if (go.tag == "Enemy")
            {
                EnemyPart ep = callisions[i].collider.gameObject.GetComponent <EnemyPart>();

                if (!enemiesHited.Contains(ep._enemy))
                {
                    enemiesHited.Add(ep._enemy);
                    ep.hit(damage, GameController.arrowsType.brust);
                }
            }
            else if (go.tag == "Item")
            {
                go.GetComponent <IItem>().Action();
                Destroy(go, 0.5f);
            }
            else if (go.tag == "Projetil")
            {
                go.GetComponent <Projetil>().damage(damage);
            }
        }

        arrow.collisionOccurred = true;
        arrow.arrowHead.SetActive(false);

        arrow._rBody.velocity    = Vector3.zero;
        arrow._rBody.isKinematic = true;
        arrow._rBody.constraints = RigidbodyConstraints.FreezeAll;
    }