Inheritance: MonoBehaviour
Esempio n. 1
0
    public void Update()
    {
        var vr = SteamVR.instance;

        LeftIsPressed  = GetIsPressed(vr, left);
        RightIsPressed = GetIsPressed(vr, right);

        if (LeftIsPressed && !leftWasPressed)
        {
            GameObject newBubble         = (GameObject)Instantiate(bubble, leftController.transform.position, Quaternion.identity);
            bubble     newBubbleBehavior = newBubble.GetComponent <bubble>();
            newBubbleBehavior.addVelocity((leftController.transform.position - leftOldPos) * 20);
            leftController.GetComponent <AudioSource>().Play();
        }

        if (RightIsPressed && !rightWasPressed)
        {
            GameObject newBubble = (GameObject)Instantiate(bubble, rightController.transform.position, Quaternion.identity);

            bubble newBubbleBehavior = newBubble.GetComponent <bubble>();
            newBubbleBehavior.addVelocity((rightController.transform.position - rightOldPos) * 20);
            rightController.GetComponent <AudioSource>().Play();
        }

        leftWasPressed  = LeftIsPressed;
        rightWasPressed = RightIsPressed;
        leftOldPos      = leftController.transform.position;
        rightOldPos     = rightController.transform.position;

        //Debug.Log(string.Format("Left Trigger: {0}    Right Trigger: {1}", LeftIsPressed, RightIsPressed));
    }
Esempio n. 2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.GetComponent <bubble>())
     {
         bubble b = collision.GetComponent <bubble>();
         value += b.getValue();
         UpdateUI();
         b.GetDestroyed();
         manager.UpdateUI();
     }
 }
Esempio n. 3
0
    private IEnumerator CreateBubbles()
    {
        while (mAllBubbles.Count < 5)
        {
            // Create and add
            GameObject newBubbleObject = Instantiate(mBubblePrefab, GetPlanePosition(), Quaternion.identity, transform);
            bubble     newBubble       = newBubbleObject.GetComponent <bubble>();

            //Setup bubble
            newBubble.mBubbleManager = this;
            mAllBubbles.Add(newBubble);

            yield return(new WaitForSeconds(0.5f));
        }
    }