Exemple #1
0
    IEnumerator Explode(Vector3 direction)
    {
        yield return(new WaitForSeconds(2f));

        for (int i = 0; i < player.boostCount; i++)
        {
            RaycastHit hit;

            Physics.Raycast(transform.position + new Vector3(0, 0.5f, 0), direction, out hit, i);

            if (!hit.collider)
            {
                GameObject explosion = Instantiate(explosionEffect, transform.position + i * direction, Quaternion.identity);
                Destroy(gameObject);
                Destroy(explosion, 0.5f);
            }
            else if (hit.collider.transform.gameObject.CompareTag("uWall"))
            {
                break;
            }
            else if (hit.collider.transform.gameObject.CompareTag("dWall"))
            {
                hit.collider.gameObject.SetActive(false);
                p.DropPowerup(hit.collider.gameObject.transform.position);
                break;
            }
        }
    }