Exemplo n.º 1
0
    }    //move

    void OnTriggerEnter2D(Collider2D target)
    {
        if (!Player.isAlive)
        {
            return;
        }

        // first check if its a bomb
        if (target.tag == "bomb")
        {
            //SoundSetting
            if (GamePreferences.GetSoundSetting() == 1)
            {
                AudioSource.PlayClipAtPoint(bombAudioClip, gameObject.transform.position);
            }            //
            Debug.Log("got a bomb!");
            Destroy(target.gameObject);
            ExplodeAllBoxes();
        }
        else if (playerBoxColorString == "white")
        {
            Player.IncreaseScore(5);
            Explode(target.gameObject);
        }
        else if (target.gameObject.tag != playerBoxColorString)
        {
            if (GamePreferences.GetSoundSetting() == 1)
            {
                AudioSource.PlayClipAtPoint(deadAudioClip, gameObject.transform.position);
            }
            isAlive = false;
            Explode(gameObject);
            Debug.Log("DEAD!");
        }
        else if (target.gameObject.tag == playerBoxColorString)
        {
            if (GamePreferences.GetSoundSetting() == 1)
            {
                AudioSource.PlayClipAtPoint(pointAudioClip, gameObject.transform.position);
            }
            //PointAnimation
            CircleBoxPieces clone =
                Instantiate(point, target.transform.position, Quaternion.identity) as CircleBoxPieces;
            //adding force to up
            clone.GetComponent <Rigidbody2D>().AddForce(Vector3.up * 3500);
            Player.IncreaseScore(5);
            Explode(target.gameObject);
        }
    }    //triggerEnter2d
Exemplo n.º 2
0
    }    //generateCircleObjects

    void Explode()
    {
        Box.colorCode = AllColors.GET_RANDOM_COLOR_STRING();
        var trans = gameObject.transform;

        for (int i = 0; i < 12; i++)
        {
            var temp = trans.position;
            temp.x += (10f * Random.Range(-10, 10));
            temp.y += (5f * Random.Range(-10, 10));
            CircleBoxPieces clone = Instantiate(circleBoxPiece, temp, Quaternion.identity) as CircleBoxPieces;
            // adding force to sideways
            clone.GetComponent <Rigidbody2D>().AddForce(Vector3.right * Random.Range(-10, 10) * 500);
            //adding force to up
            clone.GetComponent <Rigidbody2D>().AddForce(Vector3.up * Random.Range(-10, -1) * 600);
        } //loop of explode
    }     //explode
Exemplo n.º 3
0
    }    //fixedUpdate

    void Explode()
    {
        Destroy(gameObject);
        var trans = gameObject.transform;

        for (int i = 0; i < 10; i++)
        {
            var temp = trans.position;
            temp.x += (5f * Random.Range(-10, 10));
            temp.y += (5f * Random.Range(-10, 10));
            CircleBoxPieces clone = Instantiate(circleBoxPiece, temp, Quaternion.identity) as CircleBoxPieces;
            // adding force to sideways
            clone.GetComponent <Rigidbody2D>().AddForce(Vector3.right * Random.Range(-10, 10) * 500);
            //adding force to up
            clone.GetComponent <Rigidbody2D>().AddForce(Vector3.up * Random.Range(1, 12) * 700);
        }        //loop of explode

        if (chooser == -5 && Player.isAlive)
        {
            //point 1
            CircleBoxPieces point = Instantiate(pointMinus10, trans.position, Quaternion.identity) as CircleBoxPieces;
            point.GetComponent <Rigidbody2D>().AddForce(Vector3.up * 5000);
        }
    }