示例#1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        // 半空中被接着
        if (other.tag == "Player")
        {
            AudioSource.PlayClipAtPoint(pickupClip, GameObject.Find("Main Camera").transform.position);
            PlayerHealth playerHealth = other.GetComponent <PlayerHealth>();

            // 加血
            playerHealth.health += healthBonus;
            if (playerHealth.health > 100)
            {
                playerHealth.health = 100;
            }

            // 更新血条.
            playerHealth.UpDateHealthBar();

            // 开启新协程
            pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());

            // 销毁医疗包
            Destroy(transform.root.gameObject);
        }
        // 落在地面
        else if (other.tag == "ground" && !landed)
        {
            anim.SetTrigger("Land");

            transform.parent = null;
            gameObject.AddComponent <Rigidbody2D>();
            landed = true;
        }
    }
示例#2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        // 碰到英雄
        if (other.tag == "Player")
        {
            PlayerHealth playerHealth = other.GetComponent <PlayerHealth>();

            // 加血
            playerHealth.health += healthBonus;
            playerHealth.health  = Mathf.Clamp(playerHealth.health, 0f, 100f);           //限制血条在0-100

            // 更新血条
            playerHealth.UpdateHealthBar();

            // 启动一个新的道具产生协程
            pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());

            // Play the collection sound.
            //AudioSource.PlayClipAtPoint(collect,transform.position);

            // 销毁急救包
            Destroy(transform.root.gameObject);
        }
        // 碰到地面
        else if (other.tag == "ground" && !landed)
        {
            // 触发动画触发器
            anim.SetTrigger("Land");
            transform.parent = null;                 //销毁父物体
            gameObject.AddComponent <Rigidbody2D>(); //将他自己弄成刚体
            landed = true;
        }
    }
示例#3
0
 void OnTriggerEnter2D(Collider2D col)
 {
     // If the player hits the trigger...
     if (col.gameObject.tag == "Player")
     {
         // .. stop the camera tracking the player
         GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFollow> ().enabled = false;
         Instantiate(splash, col.transform.position, transform.rotation);
         Destroy(col.gameObject);
         GameObject.FindGameObjectWithTag("GameOverText").GetComponent <GUIText> ().enabled = true;
         StartCoroutine("ReloadGame");
     }
     else if (col.gameObject.tag == "Pickup")
     {
         Destroy(col.gameObject);
         pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());
     }
     else if (col.gameObject.tag == "Enemy")
     {
         // ... instantiate the splash where the enemy falls in.
         Instantiate(splash, col.transform.position, transform.rotation);
         Destroy(col.gameObject);
     }
     else
     {
         Destroy(col.gameObject);
     }
 }
示例#4
0
    public void Explode()
    {
        layBombs.bombLaid = false;

        pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());

        Collider2D enemies = Physics2D.OverlapCircleAll(transform.position, bombRadius, 1 << LayerMask.NameToLayer("Enemies"));

        forEach(Collider2D en in enemies)
        {
            Rigidbody2D rb = en.GetComponent <Rigidbody2D>();

            if (rb != null && rb.tag == "Enemy")
            {
                rb.gameObject.GetComponent <Enemy>().HP = 0;
                Vector3 deltaPos = rb.transform.position - transform.position;
                Vector3 force    = deltaPos.normalized * bombForce;
                rb.addForce(force);
            }
        }

        explosionFX.transform.position = transform.position;
        explosionFX.play();

        Instantiate(explosion, transform.position, Quaternion.identity);

        AudioSource.PlayClipAtPoint(boom, transform.position);

        Destroy(gameObject);
    }
示例#5
0
    void OnTriggerEnter2D(Collider2D other)
    {
        // 半空中被接着
        if (other.tag == "Player")
        {
            PlayerHealth playerHealth = other.GetComponent <PlayerHealth>();

            GameObject.FindGameObjectWithTag("PickupSpawner").GetComponent <AudioSource>().clip = boom;
            GameObject.FindGameObjectWithTag("PickupSpawner").GetComponent <AudioSource>().Play();

            // 加血
            playerHealth.health += healthBonus;
            if (playerHealth.health > 100)
            {
                playerHealth.health = 100;
            }

            // 更新血条.
            playerHealth.UpdateHealthBar();

            // 销毁医疗包
            Destroy(transform.root.gameObject);
            // 开启新协程
            pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());
        }
        // 落在地面
        else if (other.tag == "ground" && !landed)
        {
            anim.SetTrigger("Land");

            transform.parent = null;
            gameObject.AddComponent <Rigidbody2D>();
            landed = true;
        }
    }
示例#6
0
    void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log(other.tag);
        // 如果碰到玩家
        if (other.tag == "Player")
        {
            // 播放音效
            AudioSource.PlayClipAtPoint(pickupClip, transform.position);

            // 增加玩家的炸弹数量
            other.GetComponent <LayBombs>().bombCount++;

            // 在协程中继续制造空降包
            pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());

            // 释放游戏对象
            Destroy(transform.root.gameObject);
        }
        else if (other.tag == "Ground" && !landed)
        {
            // 如果碰到建筑或UFO
            // 触发落地动画
            anim.SetTrigger("Land");
            // 解除与父物体的连接
            GameObject parent = transform.parent.gameObject;
            transform.parent = null;
            // 添加刚体属性
            gameObject.AddComponent <Rigidbody2D>();
            // 标识为已经落地
            landed = true;
            // 删除父级对象
            Destroy(parent);
        }
    }
示例#7
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Player")
        {
            PlayerHealth playerHealth = collision.GetComponent <PlayerHealth>();

            playerHealth.health += healthBouns;
            playerHealth.health  = Mathf.Clamp(playerHealth.health, 0f, 100f);

            playerHealth.UpdateHealthBar();

            pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());

            AudioSource.PlayClipAtPoint(collect, transform.position);

            Destroy(transform.root.gameObject);
        }
        else
        {
            if (collision.tag == "ground" && !landed)
            {
                anim.SetTrigger("Land");

                transform.parent = null;
                gameObject.AddComponent <Rigidbody2D>();
                landed = true;
            }
        }
    }
示例#8
0
    void OnTriggerEnter2D(Collider2D other)
    {
        // If the player enters the trigger zone...
        if (other.CompareTag("Player"))
        {
            // Get a reference to the player health script.
            Vitality playerHealth = other.GetComponent <Vitality>();

            // Increasse the player's health by the health bonus but clamp it at 100.
            playerHealth.health += healthBonus;
            playerHealth.health  = Mathf.Clamp(playerHealth.health, 0f, 100f);

            // Update the health bar.
            playerHealth.UpdateHealthBar();

            // Trigger a new delivery.
            pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());

            // Play the collection sound.
            AudioSource.PlayClipAtPoint(collect, transform.position);

            // Destroy the crate.
            Destroy(transform.root.gameObject);
        }
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        // If the player enters the trigger zone...
        if (other.tag == "Player")
        {
            // Get a reference to the player health script.
            DogHealth playerHealth = other.GetComponent <DogHealth>();

            // Increasse the player's health by the health bonus but clamp it at 100.
            playerHealth.health += healthBonus;
            playerHealth.health  = Mathf.Clamp(playerHealth.health, 0f, 100f);

            // Update the health bar.
            //playerHealth.UpdateHealthBar();

            // Trigger a new delivery.
            pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());

            // Play the collection sound.
            AudioSource.PlayClipAtPoint(collect, transform.position);

            // Destroy the crate.
            Destroy(transform.root.gameObject);
        }
        // Otherwise if the crate hits the ground...
        else if (other.tag == "ground" && !landed)
        {
            // ... set the Land animator trigger parameter.
            anim.SetTrigger("Land");

            transform.parent = null;
            gameObject.AddComponent <Rigidbody2D>();
            landed = true;
        }
    }
示例#10
0
    void Update()
    {
        bool fire1 = Input.GetButtonDown("Fire1");
        bool fire2 = Input.GetButtonDown("Fire2") && hasRocket;

        if (fire1 || fire2)
        {
            anim.SetTrigger("Shoot");
            GetComponent <AudioSource>().Play();
            Vector2 barrel = playerCtrl.aimDirection * weaponRadius;
            Vector3 point  = new Vector3(transform.position.x + barrel.x, transform.position.y + barrel.y, transform.position.z);

            Rigidbody2D fireRocket;
            float       fireSpeed;

            if (fire1)
            {
                fireRocket = grenade;
                fireSpeed  = grenadeSpeed;
            }
            else
            {
                fireRocket = rocket;
                fireSpeed  = rocketSpeed;
                hasRocket  = false;
                pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());
            }
            Rigidbody2D bulletInstance = Instantiate(fireRocket, point, Quaternion.Euler(new Vector3(0, 0, playerCtrl.aimAngle))) as Rigidbody2D;
            bulletInstance.velocity = playerCtrl.aimDirection * fireSpeed;
        }
        nukeHUD.enabled = hasRocket;
    }
示例#11
0
    public void OnExplode()
    {
        // The player is now free to lay bombs when he has them.
        layBombs.bombLaid = false;

        // Make the pickup spawner start to deliver a new pickup.
        pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());
    }
 static public int DeliverPickup(IntPtr l)
 {
     try {
         PickupSpawner self = (PickupSpawner)checkSelf(l);
         self.DeliverPickup();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#13
0
    public void Explode()
    {
        // The player is now free to lay bombs when he has them.
        layBombs.bombLaid = false;

        // Make the pickup spawner start to deliver a new pickup.
        pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());

        // Find all the colliders on the Enemies layer within the bombRadius.
        Collider2D[] enemies = Physics2D.OverlapCircleAll(transform.position, bombRadius, 1 << LayerMask.NameToLayer("Enemies"));

        // For each collider...
        foreach (Collider2D en in enemies)
        {
            // Check if it has a rigidbody (since there is only one per enemy, on the parent).
            Rigidbody2D rb = en.rigidbody2D;
            if (rb != null && (rb.tag == "Enemy" || rb.tag == "Enemy2"))
            {
                // Find the Enemy script and set the enemy's health to zero.
                if (rb.tag == "Enemy")
                {
                    rb.gameObject.GetComponent <Enemy>().HP = 0;
                }
                else
                {
                    rb.gameObject.GetComponent <Enemy2>().HP = 0;
                }

                // Find a vector from the bomb to the enemy.
                Vector3 deltaPos = rb.transform.position - transform.position;

                // Apply a force in this direction with a magnitude of bombForce.
                Vector3 force = deltaPos.normalized * bombForce;
                rb.AddForce(force);
            }
        }

        // Set the explosion effect's position to the bomb's position and play the particle system.
        explosionFX.transform.position = transform.position;
        explosionFX.Play();

        // Instantiate the explosion prefab.
        Instantiate(explosion, transform.position, Quaternion.identity);

        // Play the explosion sound effect.
        AudioSource.PlayClipAtPoint(boom, transform.position);

        // Destroy the bomb.
        Destroy(gameObject);
    }
示例#14
0
文件: Bomb.cs 项目: Eva-yy/yy
    public void Explode()
    {
        // 英雄可再次释放炮弹
        layBombs.bombLaid = false;

        // 启动新道具协程,随机产生一个道具降落
        pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());

        // 在杀伤范围内查找敌人
        Collider2D[] enemies = Physics2D.OverlapCircleAll(transform.position, bombRadius, 1 << LayerMask.NameToLayer("Enemy"));

        // 遍历所有查找到的敌人
        foreach (Collider2D en in enemies)
        {
            // 获得敌人刚体
            Rigidbody2D rb = en.GetComponent <Rigidbody2D>();
            if (rb != null && rb.tag == "Enemy")
            {
                // 访问Enemy脚本并且将敌人血量制为0
                rb.gameObject.GetComponent <Enemy>().HP = 0;

                // 炮弹到敌人的向量
                Vector3 deltaPos = rb.transform.position - transform.position;

                // 给敌人一个杀伤力
                Vector3 force = deltaPos.normalized * bombForce;
                rb.AddForce(force);
            }
        }

        // 播放爆炸后粒子效果
        explosionFX.transform.position = transform.position;
        explosionFX.Play();

        // 实例化爆炸背景图
        Instantiate(explosion, transform.position, Quaternion.identity);


        // 销毁Bomb
        Destroy(gameObject);
    }
示例#15
0
    void OnTriggerEnter2D(Collider2D other)
    {
        // If the player enters the trigger zone...
        if (other.tag == "Player")
        {
            // Get a reference to the player health script.
            PlayerHealth playerHealth = other.GetComponent <PlayerHealth>();

            // Increasse the player's health by the health bonus but clamp it at 100.
            playerHealth.health += healthBonus;
            playerHealth.health  = Mathf.Clamp(playerHealth.health, 0f, 100f);

            // Update the health bar.
            playerHealth.UpdateHealthBar();

            // Trigger a new delivery.
            pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());

            // Play the collection sound.
            AudioSource.PlayClipAtPoint(collect, transform.position);

            // Destroy the crate.
            Destroy(transform.root.gameObject);
        }
        // Otherwise if the crate hits the ground...
        else if (other.tag == "ground" && !landed)
        {
            // ... set the Land animator trigger parameter.
            anim.SetTrigger("Land");
            // Remove the rigidbody from the parent to stop the parachute falling
            Destroy(transform.parent.GetComponent <Rigidbody2D>());

            // Detach the crate itself from the parent object by making its parent null
            transform.parent = null;
            // Add a rigidbody to the crate so it can fall off of ledges and down slopes
            gameObject.AddComponent <Rigidbody2D>();
            // stop any of the landing actions recurring
            landed = true;
        }
    }
示例#16
0
    void OnTriggerEnter2D(Collider2D other)
    {
        Debug.Log(other.tag);
        // 如果碰到玩家
        if (other.tag == "Player")
        {
            // 引用玩家键康状态脚本
            PlayerHealth playerHealth = other.GetComponent <PlayerHealth>();

            //给玩家增加生命值
            playerHealth.HP += healthBonus;
            playerHealth.HP  = Mathf.Clamp(playerHealth.HP, 0f, 100f);

            // 更新玩家生命条
            playerHealth.UpdateHealthBar();

            // 在协程中继续制造空降包
            pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());

            // 播放音效
            AudioSource.PlayClipAtPoint(collect, transform.position);

            // 释放游戏对象
            Destroy(transform.root.gameObject);
        }
        else if (other.tag == "Ground" && !landed)
        {
            // 如果碰到建筑、UFO等
            // 触发落地动画
            anim.SetTrigger("Land");

            // 支掉降落伞和父对象
            transform.parent = null;
            // 添加刚体属性,让玩家可以碰撞
            gameObject.AddComponent <Rigidbody2D>();
            // 标志为落地状态
            landed = true;
        }
    }
示例#17
0
    // Update is called once per frame
    void Update()
    {
        if (stage == 2 && Input.GetButtonDown("Fire1"))
        {
            stage++;
            timeElapsed = 0f;
            PickUp.DeliverPickup();
        }

        //Main switch statements that controls which stage to play
        timeElapsed += Time.deltaTime;
        switch (stage)
        {
        case 0:
            //Beginning movement sequence
            if ((2.5f - timeElapsed) < 0)
            {
                MovementValue        = 0;
                PokemonMusic.enabled = true;
                stage++;
            }
            break;

        case 1:
            StartBattleSequence();
            break;

        case 2:
            BattleSequence();
            break;

        case 3:
            FinalSequence();
            break;

        default:
            break;
        }
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        // 炸弹还在半空被接住
        if (other.tag == "Player")
        {
            GameObject.FindGameObjectWithTag("PickupSpawner").GetComponent <AudioSource>().clip = boom;
            GameObject.FindGameObjectWithTag("PickupSpawner").GetComponent <AudioSource>().Play();
            // 销毁炮弹
            Destroy(transform.root.gameObject);
            pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());
        }
        // 掉地上
        else if (other.tag == "ground" && !landed)
        {
            anim.SetTrigger("Land");
            transform.parent = null;
            gameObject.AddComponent <Rigidbody2D>();
            landed = true;
        }
        LayBombs lay = other.GetComponent <LayBombs>();

        lay.bombCount++;
    }
示例#19
0
    void OnTriggerEnter2D(Collider2D other)
    {
        // If the player enters the trigger zone...
        if (other.tag == "Player")
        {
            // Trigger a new delivery.
            pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());
            // ... play the pickup sound effect.
            AudioSource.PlayClipAtPoint(pickupClip, transform.position);

            // Destroy the crate.
            Destroy(transform.root.gameObject);
        }
        // Otherwise if the crate lands on the ground...
        else if (other.tag == "dimian" && !landed)
        {
            // ... set the animator trigger parameter Land.
            anim.SetTrigger("Land");
            transform.parent = null;
            gameObject.AddComponent <Rigidbody2D>();
            landed = true;
        }
    }
示例#20
0
    public void Explode()
    {
        layBombs.bombLaid = false;                                   // Hero可再次释放Bomb,如何修改为可连续释放Bomb?

        pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup()); // 启动产生新道具协程

        // 在杀伤范围内查找敌人
        int nLayer = 1 << LayerMask.NameToLayer("enemy");

        Collider2D[] enemies = Physics2D.OverlapCircleAll(transform.position, bombRadius, nLayer);

        foreach (Collider2D en in enemies)
        {
            Rigidbody2D enemyBody = en.GetComponent <Rigidbody2D>();
            if (enemyBody != null && enemyBody.tag == "Enemy")
            {
                enemyBody.gameObject.GetComponent <Enemy>().HP = 0;

                Vector3 deltaPos = enemyBody.transform.position - transform.position;

                Vector3 force = deltaPos.normalized * bombForce;
                enemyBody.AddForce(force);
            }
        }

        GetComponent <AudioSource>().clip = boom;
        GetComponent <AudioSource>().Play();
        // 播放爆炸后粒子效果
        explosionFX.transform.position = transform.position;
        explosionFX.Play();

        // 实列化爆炸背景圆
        Instantiate(explosion, transform.position, Quaternion.identity);

        // 销毁Bomb
        Destroy(gameObject);
    }
示例#21
0
    void OnTriggerEnter2D(Collider2D other)
    {
        // If the player enters the trigger zone...
        if (other.tag == "Player")
        {
            // Get a reference to the player health script.
            PlayerHealth playerHealth = other.GetComponent <PlayerHealth>();

            // Increasse the player's health by the health bonus but clamp it at 100.
            playerHealth.health += healthBonus;
            playerHealth.health  = Mathf.Clamp(playerHealth.health, 0f, 100f);

            // Update the health bar.
            playerHealth.UpdateHealthBar();

            // Trigger a new delivery.
            pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());

            // Play the collection sound.
            GameObject sounder  = GameObject.Find("foregrounds");
            ExtAudio   extaudio = sounder.GetComponent <ExtAudio>();
            extaudio.sounding.clip = extaudio.healthPickup;
            extaudio.sounding.Play();
            Destroy(transform.root.gameObject);
        }
        // Otherwise if the crate hits the ground...
        else if (other.tag == "ground" && !landed)
        {
            // ... set the Land animator trigger parameter.
            anim.SetTrigger("Land");

            transform.parent = null;
            gameObject.AddComponent <Rigidbody2D>();
            landed = true;
        }
    }
    public void Explode()
    {
        if (PickupSpawner.bmbCount == 10)
        {
        }
        else if (PickupSpawner.bmbCount < 10)
        {
            PickupSpawner.bmbCount++;
            LayBombs.HUDcount++;
        }
        Debug.Log(PickupSpawner.bmbCount.ToString());
        //Sprite number2 = Resources.Load("number2", typeof(Sprite)) as Sprite;
        //Sprite number2 = Resources.Load<Sprite>("number2");
        // The player is now free to lay bombs when he has them.
        layBombs.bombLaid = false; //true olunca ilk drop'tan sonraki bomba alındığında bomba yollamıyor

        /*var prop = GameObject.FindGameObjectsWithTag("myProp");
         * //SpriteRenderer sp = parentObject.FindComponentInChildWithTag<SpriteRenderer>("LiquidColor");
         * SpriteRenderer[] _spriteRenderer;
         * _spriteRenderer = new SpriteRenderer[prop.Length];
         * for (int i = 0; i < _spriteRenderer.Length; i++)
         * {
         *  _spriteRenderer[i] = prop[i].GetComponent<SpriteRenderer>();
         * }
         * foreach (SpriteRenderer aS in _spriteRenderer)
         * {
         *  aS.sprite = number2;
         *  Debug.Log(aS.sprite);
         * }
         */
        //layBombs.bombCount = 1 kontrolünü buradan yönet
        // Make the pickup spawner start to deliver a new pickup.
        pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());

        // Find all the colliders on the Enemies layer within the bombRadius.
        Collider2D[] enemies = Physics2D.OverlapCircleAll(transform.position, bombRadius, 1 << LayerMask.NameToLayer("Enemies"));

        // For each collider...
        foreach (Collider2D en in enemies)
        {
            // Check if it has a rigidbody (since there is only one per enemy, on the parent).
            Rigidbody2D rb = en.GetComponent <Rigidbody2D>();
            if (rb != null && rb.tag == "Enemy")
            {
                // Find the Enemy script and set the enemy's health to zero.
                rb.gameObject.GetComponent <Enemy>().HP = 0;

                // Find a vector from the bomb to the enemy.
                Vector3 deltaPos = rb.transform.position - transform.position;

                // Apply a force in this direction with a magnitude of bombForce.
                Vector3 force = deltaPos.normalized * bombForce;
                rb.AddForce(force);
            }
        }

        // Set the explosion effect's position to the bomb's position and play the particle system.
        explosionFX.transform.position = transform.position;
        explosionFX.Play();

        // Instantiate the explosion prefab.
        Instantiate(explosion, transform.position, Quaternion.identity);

        // Play the explosion sound effect.
        AudioSource.PlayClipAtPoint(boom, transform.position);

        // Destroy the bomb.
        Destroy(gameObject);
    }
示例#23
0
    public void Explode()
    {
        // The player is now free to lay bombs when he has them.
        layBombs.bombLaid = false;

        // Make the pickup spawner start to deliver a new pickup.
        pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup());

        // Find all the colliders on the Enemies layer within the bombRadius.
        //Collider2D[] enemies = Physics2D.OverlapCircleAll(transform.position, bombRadius, 1 << LayerMask.NameToLayer("Enemies"));
        Collider2D[] hitColliders = Physics2D.OverlapCircleAll(transform.position, 2f);

        Collider2D enemyCollider = hitColliders.Where(h => h.tag == "Enemy").FirstOrDefault();

        if (enemyCollider != null)
        {
            Rigidbody2D rb = enemyCollider.GetComponent <Rigidbody2D>();
            // Find the Enemy script and set the enemy's health to zero.
            rb.gameObject.GetComponent <Enemy>().HP = 0;

            // Find a vector from the bomb to the enemy.
            Vector3 deltaPos = rb.transform.position - transform.position;

            // Apply a force in this direction with a magnitude of bombForce.
            Vector3 force = deltaPos.normalized * bombForce;
            rb.AddForce(force);
        }

        Collider2D obstacleHit = hitColliders.Where(h => h.tag != "Bullet" && h.tag != "Player" && h.tag != "Bullet" && h.tag != "BombPickup" && h.tag != "PlatformEnd" && !h.isTrigger).FirstOrDefault();

        if (obstacleHit != null)
        {
            BoxCollider2D boxCollider = obstacleHit.gameObject.GetComponent <BoxCollider2D>();
            //Creates explosion crater setting pixels to alpha 0
            transform.GetComponent <PixelsToAlpha>().UpdateTexture(new Vector2(transform.position.x, transform.position.y), boxCollider.gameObject, boxCollider, radius, Gun.Weapons.Bomb);
        }
        else
        {
            FinalExplosion();
        }


        //// For each collider...
        //foreach (Collider2D en in hitColliders)
        //{
        //    // Check if it has a rigidbody (since there is only one per enemy, on the parent).
        //    Rigidbody2D rb = en.GetComponent<Rigidbody2D>();
        //    if (rb != null && rb.tag == "Enemy")
        //    {
        //        // Find the Enemy script and set the enemy's health to zero.
        //        rb.gameObject.GetComponent<Enemy>().HP = 0;

        //        // Find a vector from the bomb to the enemy.
        //        Vector3 deltaPos = rb.transform.position - transform.position;

        //        // Apply a force in this direction with a magnitude of bombForce.
        //        Vector3 force = deltaPos.normalized * bombForce;
        //        rb.AddForce(force);
        //    }
        //    else if (en.tag != "Bullet" && en.tag != "Player" && en.tag != "Bullet" && en.tag != "BombPickup" && en.tag != "PlatformEnd" && !en.isTrigger)
        //    {
        //        BoxCollider2D boxCollider = en.gameObject.GetComponent<BoxCollider2D>();

        //        //explodePixels = false;
        //        //Creates explosion crater setting pixels to alpha 0
        //        //PixelsToAlpha.UpdateTexture(new Vector2(transform.position.x, transform.position.y), en.gameObject, boxCollider, radius);

        //    }
        //}
    }