Beispiel #1
0
    IEnumerator WaitForExplode()
    {
        LoadingBar.SetFloat("Duration", 0.342f / timeBeforeExplosion);

        yield return(new WaitForSeconds(timeBeforeExplosion));

        if (burnState == 0)
        {
            Destroy(transform.GetChild(0).gameObject);

            for (int i = 0; i < getter.go.Count; i++)
            {
                if (getter.go[i].tag == "Props" || getter.go[i].tag == "Bomb")
                {
                    getter.go[i].GetComponent <Props>().ExplodeProps(bombForce * 100, new Vector2(transform.position.x, transform.position.y - 1.75f), bombRadius * 10);
                }

                if (getter.go[i].tag == "Player")
                {
                    if (owner.gameObject != getter.go[i])
                    {
                        ExplosionForce2D.AddExplosionForce(getter.go[i].GetComponent <Rigidbody2D>(), bombForce * 100, new Vector2(transform.position.x, transform.position.y - 2.5f), bombRadius * 10);
                    }
                }
            }

            burnState = 3;
        }
        else if (burnState == 1)
        {
            Destroy(this.gameObject);
        }
    }
Beispiel #2
0
    void ExplosionForce()
    {
        var explosionPos = transform.position;

        Collider2D[] colliders = Physics2D.OverlapCircleAll(explosionPos, radius);
        foreach (Collider2D hit in colliders)
        {
            if (hit == null || hit.tag == "Untagged")
            {
                continue;
            }
            Rigidbody2D rig2d = hit.GetComponent <Rigidbody2D>();
            switch (hit.tag)
            {
            case "Player":
                power = (float)ExplosionData.Player;
                hit.GetComponent <Player>().enabled = false;
                break;

            case "Bomb": power = (float)ExplosionData.Bomb; break;

            case "Enemy":
                power = (float)ExplosionData.Enemy;
                hit.GetComponent <Enemy>().enabled = false;
                break;

            case "OtherObjects": power = (float)ExplosionData.OtherObjects; break;

            case "Table": power = (float)ExplosionData.Table; break;

            case "Chair": power = (float)ExplosionData.Chair; break;
            }
            if (rig2d != null)
            {
                // if (hit.tag == "OtherObjects")
                // {
                //     rig2d.AddForceAtPosition(new Vector2(0, power), Vector2.up);

                // }
                // else
                // {
                //     ExplosionForce2D.AddExplosionForce(rig2d, power, transform.position, radius);
                // }
                var   dir  = (rig2d.transform.position - transform.position);
                float calc = 1 - (dir.magnitude / radius);
                if (calc <= 0)
                {
                    calc = 0;
                }
                Vector2 vt = dir.normalized * power * calc;
                // rig2d.AddForceAtPosition(vt, Vector2.up);
                ExplosionForce2D.AddExplosionForce(rig2d, power, explosionPos, radius);
                if (hit.tag == "Player" || hit.tag == "Enemy")
                {
                    StartCoroutine(Delay(hit));
                }
            }
        }
    }
 void Explosion()
 {
     Instantiate(rocketExplosion, transform.position, transform.rotation);
     Collider2D[] objects = Physics2D.OverlapCircleAll(transform.position, explosionRadius);
     foreach (Collider2D nearbyObjects in objects)
     {
         Rigidbody2D rb    = nearbyObjects.GetComponent <Rigidbody2D>();
         EnemyHealth enemy = nearbyObjects.GetComponent <EnemyHealth>();
         if (rb != null)
         {
             ExplosionForce2D.AddExplosionForce(rb, explosionForce * 100, transform.position, explosionRadius);
             if (rb.gameObject.tag == "Player")
             {
                 float proximity = (transform.position - rb.transform.position).magnitude;
                 float effect    = 1 - proximity / explosionRadius;
                 rb.GetComponent <PlayerHealth>().TakeDamage(25 * Mathf.RoundToInt(effect));
             }
         }
     }
 }
Beispiel #4
0
 public void ExplodeProps(float expForce, Vector3 expPosition, float expRadius)
 {
     ExplosionForce2D.AddExplosionForce(GetComponent <Rigidbody2D>(), expForce * 2, expPosition, expRadius * 10);
 }
 public static void Explode(Transform parentTranform, Collider2D other)
 {
     ExplosionForce2D.AddExplosionForce(other.GetComponent <Rigidbody2D>(), 3000, parentTranform.position, 1);
 }
 public static void Pull(Transform parentTranform, Collider2D other)
 {
     ExplosionForce2D.AddExplosionForce(other.GetComponent <Rigidbody2D>(), -640, parentTranform.position, (parentTranform.localScale.x) * 1.5f);
 }
Beispiel #7
0
    // Gonna work on it...

    void Connected_Nodes_Search_Initial_Call()
    {
        for (int i = 0; i < Num_Of_Columns; i++)
        {
            if (!MatrixGrid[0][i].GetComponent <BubbleProperties>().isEmpty)
            {
                FindConnectedNodes(MatrixGrid[0][i]);
            }
        }


        for (int i = 0; i < Num_Of_Rows; i++)
        {
            if (i % 2 == 0)
            {
                for (int j = 0; j < Num_Of_Columns; j++)
                {
                    if (connected_Flag_Cell[i][j] && !(Remaining_Colors.Contains(MatrixGrid[i][j].GetComponent <BubbleProperties>().BubbleColor)))
                    {
                        Remaining_Colors.Add(MatrixGrid[i][j].GetComponent <BubbleProperties>().BubbleColor);
                    }
                }
            }
            else
            {
                for (int j = 0; j < Num_Of_Columns - 1; j++)
                {
                    if (connected_Flag_Cell[i][j] && !(Remaining_Colors.Contains(MatrixGrid[i][j].GetComponent <BubbleProperties>().BubbleColor)))
                    {
                        Remaining_Colors.Add(MatrixGrid[i][j].GetComponent <BubbleProperties>().BubbleColor);
                    }
                }
            }
        }


        //Count For Cheers
        int falling_Count = 0;


        for (int i = 0; i < Num_Of_Rows; i++)
        {
            if (i % 2 == 0)
            {
                for (int j = 0; j < Num_Of_Columns; j++)
                {
                    if (!connected_Flag_Cell[i][j])
                    {
                        if (!MatrixGrid[i][j].GetComponent <BubbleProperties>().isEmpty)
                        {
                            GameObject temp = ObjectPool.GetPooledObject();
                            temp.transform.parent     = MatrixGrid[i][j].transform.parent;
                            temp.transform.position   = MatrixGrid[i][j].transform.position;
                            temp.transform.localScale = MatrixGrid[i][j].transform.localScale;
                            temp.GetComponent <FallingBubbleScript>().BubbleColor = MatrixGrid[i][j].GetComponent <BubbleProperties>().BubbleColor;
                            falling_Count++;
                            temp.SetActive(true);

                            int RandForce = UnityEngine.Random.Range(1000, 1200);
                            ExplosionForce2D.AddExplosionForce(temp.GetComponent <Rigidbody2D>(), RandForce, Vector2.up, 5);


                            MatrixGrid[i][j].GetComponent <BubbleProperties>().isEmpty = true;
                        }
                    }
                }
            }
            else
            {
                for (int j = 0; j < Num_Of_Columns - 1; j++)
                {
                    if (!connected_Flag_Cell[i][j])
                    {
                        if (!MatrixGrid[i][j].GetComponent <BubbleProperties>().isEmpty)
                        {
                            GameObject temp = ObjectPool.GetPooledObject();
                            temp.transform.parent     = MatrixGrid[i][j].transform.parent;
                            temp.transform.position   = MatrixGrid[i][j].transform.position;
                            temp.transform.localScale = MatrixGrid[i][j].transform.localScale;
                            temp.GetComponent <FallingBubbleScript>().BubbleColor = MatrixGrid[i][j].GetComponent <BubbleProperties>().BubbleColor;
                            falling_Count++;
                            temp.SetActive(true);
                            int RandForce = UnityEngine.Random.Range(1000, 1100);
                            ExplosionForce2D.AddExplosionForce(temp.GetComponent <Rigidbody2D>(), RandForce, Vector2.up, 5);
                            //print("Calling Fall Down...");



                            MatrixGrid[i][j].GetComponent <BubbleProperties>().isEmpty = true;
                            ////;
                        }
                    }
                }
            }
        }



        CheckLevelCleared();

        // Pivot check
        initialMid.SendMessage("MoveDown");
    }