Ejemplo n.º 1
0
    //public GameObject instantiatedObj;
    void OnMouseDown()
    {
        if (!numMan.OutOfDarts)
        {
            source.PlayOneShot(popSound);
            colors = Random.Range(1, 4);
            splatter(colors);

            splatter1.GetComponent <Renderer> ().enabled = true;
            splatter2.GetComponent <Renderer> ().enabled = true;

            int randomNumber = Random.Range(1, 40);
            //This will check to make sure only unique numbers are under balloons!
            while (numMan.numbers.Contains(randomNumber))
            {
                //keep the numbers in bounds
                if (randomNumber < 40)
                {
                    randomNumber++;
                }
                else
                {
                    randomNumber--;
                }
                Debug.Log("CHANGED to a: " + randomNumber);
            }
            //set the object to the correct number
            GameObject Number = Resources.Load(randomNumber.ToString(), typeof(GameObject)) as GameObject;
            //add the number to the linked list
            numMan.numbers.Add(randomNumber);
            //when its finally set, draw the number on the screen
            if (Number != null)
            {
                Instantiate(Number, new Vector3(this.transform.position.x, this.transform.position.y, 40), Quaternion.identity);
            }
            numMan.CheckMatches();
            SwitchBalloon(false);
        }
    }
    //public GameObject instantiatedObj;
    void OnMouseDown()
    {
        if (!bonusMan.startBonusGame)
        {
            if (!numMan.OutOfTix)
            {
                if (!numMan.OutOfDarts)
                {
                    source.Play();
                    //colors = Random.Range(1, 4);
                    splatter(colors);

                    //splatter1.GetComponent<Renderer>().enabled = true;
                    //splatter2.GetComponent<Renderer>().enabled = true;

                    GameObject splatterd = Resources.Load("P" + Random.Range(1, 15).ToString(), typeof(GameObject)) as GameObject;
                    if (splatterd != null)
                    {
                        Debug.Log("SPLATTAD");
                        float rndSize = Random.Range(1.5f, 2.5f);
                        float rndRot  = Random.Range(0, 360);
                        splatterd.transform.localScale = new Vector3(rndSize, rndSize, rndSize);
                        splatterd.transform.rotation   = new Quaternion(0, 0, rndRot, 0);
                        Instantiate(splatterd, new Vector3(this.transform.position.x, this.transform.position.y, 41), Quaternion.identity);
                    }

                    else
                    {
                        numGenClass.SetMaxNum(numGenClass.GetInitMaxNum());
                    }
                    int randomNumber = Random.Range(1, numGenClass.GetMaxNum());
                    //int randomNumber = 41;

                    //int randomNumber = 41;
                    //This will check to make sure only unique numbers are under balloons!
                    while (numMan.numbers.Contains(randomNumber))
                    {
                        //keep the numbers in bounds
                        if (randomNumber < numGenClass.GetMaxNum())
                        {
                            randomNumber++;
                        }
                        else
                        {
                            randomNumber--;
                        }
                        Debug.Log("CHANGED to a: " + randomNumber);
                    }
                    //set the object to the correct number
                    GameObject Number = Resources.Load(randomNumber.ToString(), typeof(GameObject)) as GameObject;
                    //add the number to the linked list
                    numMan.numbers.Add(randomNumber);
                    //when its finally set, draw the number on the screen
                    if (Number != null)
                    {
                        Instantiate(Number, new Vector3(this.transform.position.x, this.transform.position.y, 40), Quaternion.identity);
                    }
                    if (randomNumber >= 41)
                    {
                        bonusMan.startBonusGame = true;
                        numGenClass.SetMaxNum(40);
                        numGenClass.SetAlreadyBonus(true);
                        Debug.Log("YAY BONUS");
                    }
                    numMan.CheckMatches();
                    SwitchBalloon(false);
                }
            }
        }
    }