Beispiel #1
0
 private void Hit()
 {
     Collider2D[] collisions = Physics2D.OverlapCircleAll(transform.position, GetComponent <CircleCollider2D>().radius + 0.02f);
     foreach (Collider2D collision in collisions)
     {
         if (hits.Contains(collision.gameObject))
         {
             continue;
         }
         hits.Add(collision.gameObject);
         if (collision.CompareTag("Entity"))
         {
             collision.GetComponent <Entity>().StoneHit(GetComponent <Rigidbody2D>().velocity);
         }
         if (collision.CompareTag("Dragon"))
         {
             if (transform.localScale.x > 0.5f)
             {
                 collision.GetComponent <DragonScript>().Lightning();
                 collision.GetComponent <DragonScript>().Lightning();
             }
             collision.GetComponentInParent <DragonScript>().StoneHit(GetComponent <Rigidbody2D>().velocity);
         }
         if (collision.CompareTag("Player"))
         {
             if (transform.localScale.x > 0.5f)
             {
                 collision.GetComponent <PlayerController>().Lightning();
             }
             //collision.GetComponent<PlayerController>().StoneHit(GetComponent<Rigidbody2D>().velocity);
         }
         TODO.Here(); // Others fire functions
     }
 }
Beispiel #2
0
    void Explode()
    {
        lightningObject.SetActive(true);

        GetComponent <SpriteRenderer>().enabled = false;
        Destroy(GetComponent <Rigidbody2D>());
        GetComponent <Collider2D>().enabled = false;

        List <GameObject> received = new List <GameObject>();

        Collider2D[] collisions = Physics2D.OverlapCircleAll(transform.position, explodeRadius / 2);
        foreach (Collider2D collision in collisions)
        {
            if (received.Contains(collision.gameObject))
            {
                continue;
            }
            received.Add(collision.gameObject);
            if (collision.CompareTag("Entity"))
            {
                collision.GetComponent <Entity>().Lightning();
            }
            if (collision.CompareTag("Dragon"))
            {
                collision.GetComponentInParent <DragonScript>().Lightning();
            }
            if (collision.CompareTag("Player"))
            {
                collision.GetComponent <PlayerController>().Lightning();
            }
            TODO.Here(); // Others fire functions
        }

        StartCoroutine(DecayParticles());
    }
Beispiel #3
0
    private void Hit()
    {
        List <GameObject> received = new List <GameObject>();

        Collider2D[] collisions = Physics2D.OverlapCircleAll(transform.position, GetComponent <CircleCollider2D>().radius / 2 + 0.1f);
        foreach (Collider2D collision in collisions)
        {
            if (received.Contains(collision.gameObject))
            {
                continue;
            }
            received.Add(collision.gameObject);
            if (collision.CompareTag("Entity"))
            {
                collision.GetComponent <Entity>().Regen();
            }
            if (collision.CompareTag("Dragon"))
            {
                collision.GetComponentInParent <DragonScript>().leftRegenIterations += 5;
            }
            if (collision.CompareTag("Player"))
            {
                collision.GetComponent <PlayerController>().Regen();
            }
            TODO.Here(); // Others fire functions
        }
        StartCoroutine(Expire());
    }
Beispiel #4
0
    private void Explode()
    {
        Destroy(Instantiate(explosionPrefab, transform.position, Quaternion.identity, PlayerController.instance.objectZero), 2f);

        GetComponent <SpriteRenderer>().enabled = false;
        Destroy(GetComponent <Rigidbody2D>());
        GetComponent <Collider2D>().enabled = false;

        Collider2D[] collisions = Physics2D.OverlapCircleAll(transform.position, explodeRadius / 2f);

        List <GameObject> received = new List <GameObject>();

        foreach (Collider2D collision in collisions)
        {
            if (received.Contains(collision.gameObject))
            {
                continue;
            }
            received.Add(collision.gameObject);
            if (collision.CompareTag("Entity"))
            {
                collision.GetComponent <Entity>().Explosion(transform.position);
                continue;
            }
            if (collision.CompareTag("Player"))
            {
                collision.GetComponent <PlayerController>().Explosion(transform.position);
                continue;
            }
            if (collision.CompareTag("Dragon"))
            {
                collision.GetComponentInParent <DragonScript>().Explosion(transform.position);
            }
            if (collision.GetComponent <Rigidbody2D>())
            {
                collision.GetComponent <Rigidbody2D>().velocity = ((collision.transform.position - transform.position + Vector3.up).normalized) * 40f;
            }
            if (collision.GetComponent <Blockade>())
            {
                collision.GetComponent <Blockade>().Explode();
            }
            TODO.Here(); // Others fire functions
        }

        StartCoroutine(DecayParticles());
    }