void stayInBounds()
    {
        // Turn around if at the end of the map
        if ((rb.velocity.x > 0 && transform.position.x > X_BOUND) ||
            (rb.velocity.x < 0 && transform.position.x < -X_BOUND))
        {
            //Finds Points and increments public variable
            GameObject   PointCounter = GameObject.Find("Points");
            PointCounter Points       = PointCounter.GetComponent <PointCounter> ();
            Points.point += 1;

            GameObject       playsound = GameObject.Find("Playbottle");
            playbottlescript sound     = playsound.GetComponent <playbottlescript>();
            sound.play();

            Destroy(gameObject);

            //rb.velocity = new Vector2 (rb.velocity.x * -1, rb.velocity.y);
        }

        // Keep in the y bounds
        if ((transform.position.y > Y_BOUND && rb.velocity.y > 0) || (transform.position.y < (-Y_BOUND) && rb.velocity.y < 0))
        {
            rb.velocity = new Vector2(rb.velocity.x / 5, 0);             //rb.velocity.y * -1);
        }
        // Make sure it stays in the same plane
        if (transform.position.z != 0)
        {
            transform.position = new Vector3(transform.position.x, transform.position.y, 0);
        }
    }
示例#2
0
    public void Reward(GameObject[] allTrash, string overload)
    {
        for (int i = 0; i < allTrash.Length; i++)
        {
            GameObject trashInstance = allTrash [i];
            Destroy(trashInstance);
        }
        GameObject       Squeakplay = GameObject.Find("Playsqueak");
        playbottlescript squeak     = Squeakplay.GetComponent <playbottlescript> ();

        squeak.play();
    }
示例#3
0
    public void Reward(GameObject[] allTrash)
    {
        for (int i = 0; i < allTrash.Length; i++)
        {
            GameObject   trashInstance = allTrash [i];
            GameObject   PointCounter  = GameObject.Find("Points");
            PointCounter Points        = PointCounter.GetComponent <PointCounter> ();
            Points.point += 1;

            Destroy(trashInstance);
        }
        GameObject       SwooshPlay = GameObject.Find("Playswoosh");
        playbottlescript swoosh     = SwooshPlay.GetComponent <playbottlescript> ();

        swoosh.play();
    }